#!/bin/bash # dzen2 volume control by twily # # useage: scroll to change volume # # command to increase the volume CI="amixer -c0 sset Master 3dB+ >/dev/null" # command to decrease the volume CD="amixer -c0 sset Master 3dB- >/dev/null" while true; do VOL=$((amixer -c0 get Master | awk '/^ Mono/ { print $4 }') | awk -F'[([|%)]' '{ print $2}') TXT="$VOL %" if [ $VOL -eq 100 ]; then TXT="MAX"; elif [ $VOL -eq 0 ]; then TXT="MIN"; fi echo "^bg(#130F1C) " echo -ne "^cs()\n\n" if [ $VOL -gt 95 ]; then for i in {$(seq 1 20)}; do echo "█"; done elif [ $VOL -lt 5 ]; then for i in {$(seq 1 20)}; do echo "^fg(#4b464f)█"; done else for i in {$(seq 1 $(echo '20-('$VOL'/5)'|bc)); do echo "^fg(#4b464f)█"; done; for i in $(seq $(echo '20-(('$VOL'/5)-1)'|bc) 20); do echo "█"; done fi echo -e "\n^fg(#d6ccdc)$TXT\n" sleep .1; done | dzen2 -sa c -w 48 -h 8 -y 9 -x 1812 -fg '#aaa5ad' -e "onstart=uncollapse,hide;button3=exit;button4=exec:$CI;button5=exec:$CD" -l 24 -tw 6