feat: notification management with minor visuals and mpd cleanup
This commit is contained in:
28
utils/notifications/audio.sh
Executable file
28
utils/notifications/audio.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
audio_icon="~/.config/custom_icons/audio.png"
|
||||
audio_percentage=$(pactl get-sink-volume @DEFAULT_SINK@ | gawk 'match($0, / ([0-9]+)%/, a) {print a[1]}')
|
||||
|
||||
# FIXME: this would create an issue on the notification 1527 since it will remove it
|
||||
# The alternative is storing the id with id=$(notify-send -p ...) and conditionally including the "-r $old_id" (because it locks the id in)
|
||||
id=1527 # HACK: dirty but works
|
||||
|
||||
case $1 in
|
||||
"audio_up")
|
||||
notify-send -c Audio -r $id -i ~/.config/custom_icons/audio.png "Output Audio" "Up to $audio_percentage%"
|
||||
;;
|
||||
"audio_down")
|
||||
notify-send -c Audio -r $id -i ~/.config/custom_icons/audio.png "Output Audio" "Down to $audio_percentage%"
|
||||
;;
|
||||
"audio_unmute")
|
||||
notify-send -c Audio -r $id -i ~/.config/custom_icons/audio.png "Output Audio" "Unmuted"
|
||||
;;
|
||||
"audio_mute")
|
||||
notify-send -c Audio -r $id -i ~/.config/custom_icons/audio.png "Output Audio" "Muted"
|
||||
;;
|
||||
"mic_mute")
|
||||
notify-send -c Audio -r $id -i ~/.config/custom_icons/audio.png "Input Audio" "Muted"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
36
utils/notifications/mpd.sh
Executable file
36
utils/notifications/mpd.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
icon_file="/tmp/mpd_cover.jpg"
|
||||
backup_file="/home/dqnid/.config/custom_icons/music.png"
|
||||
final_icon_route="$icon_file"
|
||||
id=5657 # HACK: dirty but works
|
||||
|
||||
notify() {
|
||||
mpc readpicture "$(mpc current -f %file%)" > $icon_file
|
||||
song_title=$(mpc current -f %Title%)
|
||||
song_artist=$(mpc current -f %albumartist%)
|
||||
|
||||
# check image
|
||||
is_image=$(cat $icon_file | grep volume | grep repeat)
|
||||
if [[ ${#is_image} > 0 ]]; then
|
||||
final_icon_route="$backup_file"
|
||||
else
|
||||
final_icon_route="$icon_file"
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
"playing")
|
||||
notify-send -i $final_icon_route -t 6000 -r $id "Currently playing $song_artist" "$song_title"
|
||||
;;
|
||||
"paused")
|
||||
notify-send -i $final_icon_route -t 6000 -r $id "Player paused" "$song_title"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
while true; do
|
||||
status=$(mpc idle player &>/dev/null && mpc status)
|
||||
echo "$status" | grep "\[playing\]" &>/dev/null && notify && notify "playing"
|
||||
echo "$status" | grep "\[paused\]" &>/dev/null && notify && notify "paused"
|
||||
done
|
||||
Reference in New Issue
Block a user