Fancy notification when volume changes

This commit is contained in:
i.ortega 2020-05-09 19:30:30 +02:00
parent 0ecb2dc78d
commit 846ca7311b
4 changed files with 46 additions and 2 deletions

View File

@ -0,0 +1 @@
#!/usr/bin/env sh

View File

@ -8,10 +8,10 @@ alt + ctrl + r
dash $SCRIPTS/reboot.sh
XF86AudioLowerVolume
amixer -q sset Master 5%- && dash $SCRIPTS/reset-dwmbar.sh
amixer -q sset Master 5%- && dash $SCRIPTS/reset-dwmbar.sh && dash $SCRIPTS/volume-notification.sh
XF86AudioRaiseVolume
amixer -q sset Master 5%+ && dash $SCRIPTS/reset-dwmbar.sh
amixer -q sset Master 5%+ && dash $SCRIPTS/reset-dwmbar.sh && dash $SCRIPTS/volume-notification.sh
XF86AudioStop
player-command stop

32
scripts/progress-bar.sh Normal file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
mod=$(echo "$1 % 8" | bc)
blocks=$(echo "$1 / 8" | bc)
for _ in $(seq 1 "$blocks"); do
printf "█"
done
case "$mod" in
1)
printf "▏"
;;
2)
printf "▎"
;;
3)
printf "▍"
;;
4)
printf "▌"
;;
5)
[ "$1" -lt 96 ] && printf "▋"
;;
6)
[ "$1" -lt 96 ] && printf "▊"
;;
7)
[ "$1" -lt 96 ] && printf "▉"
;;
esac

View File

@ -0,0 +1,11 @@
#!/usr/bin/env sh
level=$(amixer get Master | grep -o "[0-9]*%\|\[on\]\|\[off\]" |
sed "s/\[on\]//;s/\[off\]//" | head -n 2)
bar=$(echo "$level" | head -n 1 | tr '%' ' ' |
xargs dash "$SCRIPTS/progress-bar.sh")
echo "$level" | xargs echo |
xargs -I{} notify-send -u low -t 3000 "Volume: {}" "$bar"