diff options
author | davidpkj <davidpenkow1@gmail.com> | 2024-09-16 22:48:05 +0200 |
---|---|---|
committer | davidpkj <davidpenkow1@gmail.com> | 2024-09-16 22:48:05 +0200 |
commit | 06de26be5328a13477942593daf06f417e830736 (patch) | |
tree | 6de86872623fac470ad5ce0d8cb8dd0fb8e6859b /scripts/.local/bin/personal/musctl | |
parent | 646aa3fdeca4466e5d4c4ff7db6b9686582516c6 (diff) |
Diffstat (limited to 'scripts/.local/bin/personal/musctl')
-rwxr-xr-x | scripts/.local/bin/personal/musctl | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/scripts/.local/bin/personal/musctl b/scripts/.local/bin/personal/musctl index cca7b8d..6bfbd16 100755 --- a/scripts/.local/bin/personal/musctl +++ b/scripts/.local/bin/personal/musctl @@ -1,33 +1,38 @@ #!/bin/bash -STATE="$(mpc | grep -o playing)" -NAME="$(basename "$(mpc current)")" +# A script to manage the music player daemon (mpd) on my system +# Depends on: mpd, playerctl, libnotify +# By David Penkowoj, 2024-09-16 -notify() { - if [[ -n "$STATE" ]]; then - notify-send "Currently playing" "${NAME%.*}" - else - notify-send "MPD is currently paused" - fi +music_state="$(mpc | grep -o playing)" +music_name="$(basename "$(mpc current)")" + +notify_music() { + if [[ -n "$music_state" ]]; then + notify-send "Currently playing" "${music_name%.*}" + else + notify-send "MPD is currently paused" + fi } case "$1" in - "previous") - mpc -q prev - playerctl -s previous - ;; - "toggle") - mpc -q toggle - playerctl -s play-pause - ;; - "next") - mpc -q next - playerctl -s next - ;; - "notify") - notify - ;; - *) - echo "[ Error ] Unknown command" - ;; + "previous") + mpc -q prev + playerctl -s previous + ;; + "toggle") + mpc -q toggle + playerctl -s play-pause + ;; + "next") + mpc -q next + playerctl -s next + ;; + "notify") + notify_music + ;; + *) + printf "[ Error ] Usage: musctl [previous|toggle|next|notify]" + exit 1 + ;; esac |