dotfiles

configuration files
git clone https://pi.duncano.de/git/dotfiles.git
Log | Files | Refs | README

commit 49784a2a2b98d67c5b2c2e607a4f9e2d07ad6270
parent 37e9e2d08d87d7a8e98b42fc430c1d15e822f11f
Author: Duncaen <mail@duncano.de>
Date:   Sat, 16 May 2015 16:28:40 +0200

bin/dmenu_playerctl: remeber last volume action for faster up/down

Diffstat:
bin/dmenu_playerctl | 22+++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)

diff --git 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