From 846ca7311b7b1fbb24b1018b1e09e89e5658e040 Mon Sep 17 00:00:00 2001 From: "i.ortega" Date: Sat, 9 May 2020 19:30:30 +0200 Subject: [PATCH] Fancy notification when volume changes --- .config/dunst/volume-notification-hook.sh | 1 + .config/sxhkd/sxhkdrc | 4 +-- scripts/progress-bar.sh | 32 +++++++++++++++++++++++ scripts/volume-notification.sh | 11 ++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 .config/dunst/volume-notification-hook.sh create mode 100644 scripts/progress-bar.sh create mode 100644 scripts/volume-notification.sh diff --git a/.config/dunst/volume-notification-hook.sh b/.config/dunst/volume-notification-hook.sh new file mode 100755 index 0000000..0617957 --- /dev/null +++ b/.config/dunst/volume-notification-hook.sh @@ -0,0 +1 @@ +#!/usr/bin/env sh diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index a428647..c6027b4 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -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 diff --git a/scripts/progress-bar.sh b/scripts/progress-bar.sh new file mode 100644 index 0000000..0b57b78 --- /dev/null +++ b/scripts/progress-bar.sh @@ -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 diff --git a/scripts/volume-notification.sh b/scripts/volume-notification.sh new file mode 100644 index 0000000..36342df --- /dev/null +++ b/scripts/volume-notification.sh @@ -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"