summaryrefslogtreecommitdiff
path: root/notification_wrapper.sh
diff options
context:
space:
mode:
Diffstat (limited to 'notification_wrapper.sh')
-rwxr-xr-xnotification_wrapper.sh141
1 files changed, 141 insertions, 0 deletions
diff --git a/notification_wrapper.sh b/notification_wrapper.sh
new file mode 100755
index 0000000..91a7b07
--- /dev/null
+++ b/notification_wrapper.sh
@@ -0,0 +1,141 @@
+#!/bin/bash
+
+# echo "This is $0"
+# echo "This is \$BASH_SOURCE: $BASH_SOURCE"
+
+export DISPLAY=":0.0"
+export XDG_RUNTIME_DIR=/run/user/$(id -u)
+
+##------------------------------DEFAULT NOTIFICATION------------------------------##
+
+FLAG=true
+CALLER=$( ps -o comm= $PID )
+SUMMARY="Default Notification - CALLER:$CALLER "
+ICONS="$HOME/stuf/customization/icons"
+ICON="$ICONS/ENE.png"
+TIME=5000
+
+##------------------------------ECHO NOTIFICATION------------------------------##
+
+#DOESN'T WORK, FIGURE OUT WHY ONE DAY
+
+[[ $( grep "echo" <<< "$CALLER" ) ]] && SUMMARY="Echo" && DESCRIPTION=$1 && ICON="$ICONS/ENE.png"
+
+##------------------------------RSYNC NOTIFICATION------------------------------##
+
+[[ $( grep "wide_rsync" <<< "$CALLER" ) && "$2" =~ "WRSYNC" ]] && SUMMARY="Wide Rsync" && DESCRIPTION=$1 && TIME=15000 && [[ "$2" == "WRSYNCSUCC" ]] && ICON="$ICONS/yayoiooo.png" || ICON="$ICONS/yayoiclose.png"
+
+##------------------------------KEYMAPPER NOTIFICATION------------------------------##
+
+[[ $( grep "keymap_toggler" <<< "$CALLER" ) && "$2" == "KEYTOG" ]] && SUMMARY="Key Mapper" && DESCRIPTION=$1 && ICON="$ICONS/erikahorni.png"
+
+##------------------------------DISCORD MEDIA STREAMER NOTIFICATION------------------------------##
+
+[[ $( grep "minivac" <<< "$CALLER" ) && "$2" == "MINIVAC" ]] && SUMMARY="MiniVAC" && DESCRIPTION=$1 && TIME=15000 && ICON="$ICONS/holic.gif"
+
+##------------------------------VOICE CHANGER NOTIFICATION------------------------------##
+
+[[ $( grep "voice_changer" <<< "$CALLER" ) && "$2" == "VOICHANG" ]] && SUMMARY="Voice Changer" && DESCRIPTION=$1 && TIME=15000 && ICON="$ICONS/holic.gif"
+
+##------------------------------NEWSBOAT NOTIFICATION------------------------------##
+
+[[ $( grep "newsboat" <<< "$CALLER" ) ]] && SUMMARY="Newsboat" && DESCRIPTION=$1 && ICON="$ICONS/kizukawablob.png"
+
+##------------------------------FIND LAST NOTIFICATION------------------------------##
+[[ $( grep "findlast" <<< "$CALLER" ) && "$2" == "FINDLAST" ]] && SUMMARY="Find last filename" && DESCRIPTION=$1 && ICON="$ICONS/shupogaki.png"
+
+##------------------------------DL HELPER (CLIPBOARD VER.) NOTIFICATION------------------------------##
+if [[ $( grep "dl_helper" <<< "$CALLER" ) && "$2" == "DLHELPER" ]]; then
+ SUMMARY="DL Helper (clipboard ver.)" && DESCRIPTION=$()
+ [[ $1 -eq 0 ]] && { DESCRIPTION="Copied link successfully dl'd" ; ICON="$ICONS/rhodeslogo.png" ; } || { DESCRIPTION="ERROR - Couldn't dl copied link" ; ICON="$ICONS/rhodeslogo.png" ; }
+ #CHANGE ICON
+fi
+
+##------------------------------CMUS NOTIFICATION------------------------------##
+
+if [[ $( grep cmus <<< "$CALLER" ) ]]; then
+
+ SUMMARY="Cmus"
+
+
+ # ARGUMENT PROCESSING
+
+ while test $# -ge 2
+ do
+ eval _$1='$2'
+ shift
+ shift
+ done
+
+
+ # ARGUMENT FORMATTING
+ ### for some reason processing $_duration of certain files completely erases all the other args,
+ ### so the three lines below have to be above it
+ ### echo $@ if you don't believe me
+
+
+ # ${} Parameter expansion
+ # $() Command substitution
+
+ [[ $_artist == "" ]] && _artist="N/A"
+ [[ $_title == "" ]] && [[ ${_title=$_file} == "" ]] && _title="N/A"
+ [[ $_status != *playing* ]] && FLAG=0
+
+ # DURATION FORMATTING
+
+ if [[ $_duration != "" ]]; then
+ h=$(($_duration / 3600))
+ m=$(($_duration % 3600))
+
+ duration=""
+ test $h -gt 0 && dur="$h:"
+ duration="$dur$(printf '%02d:%02d' $(($m / 60)) $(($m % 60)))"
+ else
+ duration="N/A"
+ fi
+
+
+ # DESCRIPTION FORMATTING
+ ICON="$ICONS/rikanom.png"
+ DESCRIPTION="Now playing: "$_title" ["$duration"]\nArtist: "$_artist
+fi
+
+##------------------------------PLAY SCRIPT QUEUE NOTIFICATION------------------------------##
+
+[[ $( grep "wide_play" <<< "$CALLER" ) && "$2" == "WIDEPLAY" ]] && SUMMARY="Songs currently in queue:" && DESCRIPTION=$1 && ICON="$ICONS/rikanom.png"
+
+##------------------------------ROTATION DAEMON NOTIFICATION------------------------------##
+
+if [[ $( grep "wide_rotat" <<< "$CALLER" ) && "$2" == "WIDEROT" ]]; then
+
+ OUTPUT=$1
+ ICON="$ICONS/tenshi1.png"
+ SUMMARY="Pape"
+ DESCRIPTION=""
+ [[ $( grep -i "killed" <<< "$OUTPUT" ) ]] && DESCRIPTION="Pape rotation daemon killed (PID: " || DESCRIPTION="Pape rotation daemon spawned (PID: " && DESCRIPTION="${DESCRIPTION}$(echo "$OUTPUT" | head -n 1 | sed -r "s/[^0-9]*//g"))"
+ [[ $( grep -i "bmp\|gif\|jpg\|jpeg\|png" <<< "$OUTPUT" ) ]] && DESCRIPTION="Current Pape: $OUTPUT"
+
+fi
+
+##------------------------------CLIPBOARD TREATER DAEMON NOTIFICATION------------------------------##
+
+if [[ $( grep clipboard_treat <<< "$CALLER" ) && "$2" == "CLIPTREAT" ]]; then
+
+ OUTPUT=$1
+ ICON="$ICONS/tenshi2.png"
+ SUMMARY="Clipboard Treater $2"
+ DESCRIPTION=""
+ [[ $( grep -i "killed" <<< "$OUTPUT" ) ]] && DESCRIPTION="Clipboard treater daemon killed (PID: " || DESCRIPTION="Clipboard treater daemon spawned (PID: " && DESCRIPTION="${DESCRIPTION}$(echo "$OUTPUT" | head -n 1 | sed -r "s/[^0-9]*//g"))"
+
+fi
+
+
+##------------------------------THE ACTUAL NOTIFICATION------------------------------##
+
+#notify-send -u low -t 5000 -i ~/stuf/tsubasatwinneofetch.jpg "$SUMMARY" "$DESCRIPTION"
+#notify-send -u low -t 5000 -i ~/stuf/red.jpg "$SUMMARY" "$1"
+$FLAG && notify-send -u low -t $TIME -i $ICON "$SUMMARY" "$DESCRIPTION"
+
+##------------------------------MAKE NOTIFICATIONS FOR OTHER SCRIPTS------------------------------##
+
+