dotfiles/.scripts/foobar2000.sh

43 lines
868 B
Bash
Raw Normal View History

2023-09-26 17:12:28 +02:00
#!/bin/sh
# Required: foo_runcmd
export WINEPREFIX="$HOME/.local/share/wineprefixes/foobar2000"
foobar2000_cmd="$HOME/.foobar2000/foobar2000.exe"
function start_foobar2000 {
[[ "$XDG_SESSION_TYPE" == 'wayland' ]] && opt="DISPLAY="
hyprctl dispatch exec "$opt beefweb_mpris" > /dev/null
while ! pgrep foobar2000.exe &> /dev/null; do
sleep 0.1
done
foo_runcmd '/runcmd=Playback/Volume/Set to -21 dB'
for ((i = 0 ; i < 10 ; i++)); do
foo_runcmd '/runcmd=Playback/Volume/Down'
done
}
function foo_runcmd {
wine "$foobar2000_cmd" "${@}" &> /dev/null
}
case "$1" in
-vu|volume-up)
foo_runcmd '/runcmd=Playback/Volume/Up';;
-vd|volume-down)
foo_runcmd '/runcmd=Playback/Volume/Down';;
-pp|play-pause)
if ! pgrep foobar2000.exe &> /dev/null; then
start_foobar2000
fi
foo_runcmd '/playpause';;
*)
echo "Invalid option."
exit 1;;
esac