aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2015-05-16 16:28:40 +0200
committerDuncaen <mail@duncano.de>2015-05-16 16:28:40 +0200
commit49784a2a2b98d67c5b2c2e607a4f9e2d07ad6270 (patch)
treef0fef85aa691b94bdc26934c5c33d326ee3ec7db
parent37e9e2d08d87d7a8e98b42fc430c1d15e822f11f (diff)
downloaddotfiles-49784a2a2b98d67c5b2c2e607a4f9e2d07ad6270.tar.gz
bin/dmenu_playerctl: remeber last volume action for faster up/down
-rwxr-xr-xbin/dmenu_playerctl22
1 files changed, 17 insertions, 5 deletions
diff --git a/bin/dmenu_playerctl b/bin/dmenu_playerctl
index 6199e90..64cbe41 100755
--- a/bin/dmenu_playerctl
+++ b/bin/dmenu_playerctl
@@ -28,18 +28,30 @@ player_menu() {
}
volume_menu() {
+ cmds="Up\nDown"
while :
do
- VOL=$(echo "$(playerctl -p $1 volume) * 100" | bc)
- VOL=${VOL%.*}
- ret=$(echo "Up\nDown" | ${DMENU} -p "$1: $VOL" -i | tr '[A-Z]' '[a-z]')
+ vol=$(echo "$(playerctl -p $1 volume) * 100" | bc)
+ vol=${vol%.*}
+ ret=$(echo "$cmds" | ${DMENU} -p "$1: $vol" -i | tr '[A-Z]' '[a-z]')
case "$ret" in
- up) playerctl -p $1 volume $(echo "($VOL + 5) / 100" | bc -l) ;;
- down) playerctl -p $1 volume $(echo "($VOL - 5) / 100" | bc -l) ;;
+ up)
+ playerctl -p $1 volume $(echo "($vol + 5) / 100" | bc -l)
+ cmds="Up\nDown"
+ ;;
+ down)
+ playerctl -p $1 volume $(echo "($vol - 5) / 100" | bc -l)
+ cmds="Down\nUp"
+ ;;
*)
[ -z "$ret" ] && break
[ -n "$(echo $ret | tr -d '[[:digit:]]')" ] && break
playerctl -p $1 volume $(echo "$ret / 100" | bc -l)
+ if [ "$ret" -gt "$vol" ]; then
+ cmds="Up\nDown"
+ else
+ cmds="Down\nUp"
+ fi
;;
esac
done