summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorboredpasta <boredpasta@tutanota.com>2023-07-17 17:29:14 +0300
committerboredpasta <boredpasta@tutanota.com>2023-07-17 17:45:45 +0300
commit289051ee3ce04da6c07f5374fa5ba1c7606cf9d7 (patch)
tree40135159dc196d4bfbe7a97bb5c1de791111b2b1
parent70a17dbad95de2858111c141ddbe611c075f8271 (diff)
mpc-notify: refactor
-rwxr-xr-xmpc-notify116
1 files changed, 61 insertions, 55 deletions
diff --git a/mpc-notify b/mpc-notify
index 3c4604e..ac0ced0 100755
--- a/mpc-notify
+++ b/mpc-notify
@@ -33,65 +33,71 @@ default_song_icon="media-playback-start"
# issue an mpc command based on arguments and assemble notification message
case "$command" in
- "")
- # use defaults
+"")
+ # use defaults
+ song_head="Now Playing"
+ use_preview=1
+ ;;
+"toggle")
+ mpc -q toggle
+ state="$(mpc status %state%)"
+ case "$state" in
+ "playing")
song_head="Now Playing"
use_preview=1
;;
- "toggle")
- mpc -q toggle
- state="$(mpc status %state%)"
- if [ "$state" = "playing" ]; then
- song_head="Now Playing"
- use_preview=1
- elif [ "$state" = "paused" ]; then
- song_head="Paused"
- song_icon="media-playback-pause"
- fi
- ;;
- "shuffle")
- mpc -q shuffle
- song_head="Shuffled Playlist"
- song_icon="media-playlist-shuffle"
- ;;
- "single")
- mpc -q single
- state="$(mpc status %single%)"
- if [ "$state" = "on" ]; then
- song_head="Single Mode: On"
- elif [ "$state" = "once" ]; then
- song_head="Single Mode: Once"
- elif [ "$state" = "off" ]; then
- song_head="Single Mode: Off"
- fi
- song_icon="multimedia-player"
- ;;
- "random")
- mpc -q random
- state="$(mpc status %random%)"
- if [ "$state" = "on" ]; then
- song_head="Random Mode: On"
- elif [ "$state" = "off" ]; then
- song_head="Random Mode: Off"
- fi
- song_icon="media-eject"
- ;;
- "repeat")
- mpc -q repeat
- state="$(mpc status %repeat%)"
- if [ "$state" = "on" ]; then
- song_head="Repeat Mode: On"
- elif [ "$state" = "off" ]; then
- song_head="Repeat Mode: Off"
- fi
- song_icon="media-playlist-repeat"
- ;;
- *)
- mpc -q "$command"
- # Don't notify if mpc changed song because ncmpcpp would notify on
- # song change.
- [ "$command" = "next" ] || [ "$command" = "prev" ] && exit
+ "paused")
+ song_head="Paused"
+ song_icon="media-playback-pause"
;;
+ esac
+ ;;
+"shuffle")
+ mpc -q shuffle
+ song_head="Shuffled Playlist"
+ song_icon="media-playlist-shuffle"
+ ;;
+"single")
+ mpc -q single
+ state="$(mpc status %single%)"
+ case "$state" in
+ "on")
+ song_head="Single Mode: On";;
+ "once")
+ song_head="Single Mode: Once";;
+ "off")
+ song_head="Single Mode: Off";;
+ esac
+ song_icon="multimedia-player"
+ ;;
+"random")
+ mpc -q random
+ state="$(mpc status %random%)"
+ case "$state" in
+ "on")
+ song_head="Random Mode: On";;
+ "off")
+ song_head="Random Mode: Off";;
+ esac
+ song_icon="media-eject"
+ ;;
+"repeat")
+ mpc -q repeat
+ state="$(mpc status %repeat%)"
+ case "$state" in
+ "on")
+ song_head="Repeat Mode: On";;
+ "off")
+ song_head="Repeat Mode: Off";;
+ esac
+ song_icon="media-playlist-repeat"
+ ;;
+*)
+ mpc -q "$command"
+ # don't notify if mpc changed song because ncmpcpp would notify on
+ # song change anway
+ [ "$command" = "next" ] || [ "$command" = "prev" ] && exit
+ ;;
esac
# use album preview for song icon