utils/mediactl
2024-04-18 09:34:58 +04:00

38 lines
577 B
Bash
Executable file

#!/bin/sh
vol_pct=5
sink_id=$(pw-dump Node Device | sed -n "/$(pactl get-default-sink)/,/\}/p" | grep object.id | grep -o '[0-9]*')
setvol () {
wpctl set-volume "$sink_id" "${vol_pct}%$1"
}
togglemute() {
wpctl set-mute "$sink_id" toggle
}
notifyvol () {
notify-send "$(wpctl get-volume "$sink_id")"
}
case "$1" in
"volup")
setvol +
notifyvol
;;
"voldown")
setvol -
notifyvol
;;
"volmute")
togglemute
notifyvol
;;
"playpause")
notify-send "$(playerctl play-pause 2>&1)"
;;
*)
echo 'Available: volup, voldown, volmute, playpause'
;;
esac