#!/bin/bash # A script to manage the music player daemon (mpd) on my system # Depends on: mpd, playerctl, libnotify # By David Penkowoj, 2024-09-16 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_music ;; *) printf "[ Error ] Usage: musctl [previous|toggle|next|notify]" exit 1 ;; esac