From e7d250adfedab60136ec882c480fe18085a1bf9a Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 23 Nov 2022 21:44:03 -0500 Subject: [PATCH] Music control script. --- scripts/music_controler.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/music_controler.sh diff --git a/scripts/music_controler.sh b/scripts/music_controler.sh new file mode 100755 index 0000000..afd76ad --- /dev/null +++ b/scripts/music_controler.sh @@ -0,0 +1,35 @@ +#!/bin/bash + + +run_command() { + playerctl -p '%any,chromium,firefox' $1 + sleep 0.25 +} + +show_info() { + info="$( playerctl -p '%any,chromium,firefox' metadata -f '"{{title}}" by "{{artist}}" from "{{album}}"')" + local count=1 + while [[ $count -le 10 ]] && [[ "$info" == "$oldInfo" ]]; do + info="$(playerctl -p '%any,chromium,firefox' metadata -f '"{{title}}" by "{{artist}}" from "{{album}}"')" + ((count++)) + sleep 0.25 + done + notify-send "$info" + exit 0 +} + + + oldInfo="$(playerctl -p '%any,chromium,firefox' metadata -f '"{{title}}" by "{{artist}}" from "{{album}}"')" +case "${1}" in + "prev") run_command "previous";show_info;; + "play") run_command "play";show_info;; + "pause") run_command "play-pause";; + "stop") run_command "stop";; + "next") run_command "next";show_info;; + "shuf") run_command "shuffle toggle";; + "info") unset oldInfo;show_info;; + "decvol") run_command "volume 0.05-";; + "incvol") run_command "volume 0.05+";; +esac + +exit 0