From c40b32d729be979bd119c5eaae8d736528dc719c Mon Sep 17 00:00:00 2001 From: joestandring Date: Wed, 5 Jun 2019 19:10:45 +0000 Subject: [PATCH] Made dwm_alsa and dwm_pulse more robust and pretty --- bar-functions/dwm_alsa.sh | 16 ++++++++-------- bar-functions/dwm_pulse.sh | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bar-functions/dwm_alsa.sh b/bar-functions/dwm_alsa.sh index 5fc8bcb..dca6204 100755 --- a/bar-functions/dwm_alsa.sh +++ b/bar-functions/dwm_alsa.sh @@ -10,23 +10,23 @@ dwm_alsa () { VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/") if [ "$IDENTIFIER" = "unicode" ]; then if [ "$VOL" -eq 0 ]; then - printf "[🔇 %s]\n" "$VOL]\n" + printf "[🔇]\n" elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then - printf "[🔈 %s]\n" "$VOL" + printf "[🔈 %s%%]\n" "$VOL" elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then - printf "[🔉 %s]\n" "$VOL" + printf "[🔉 %s%%]\n" "$VOL" else - printf "[🔊 %s]\n" "$VOL" + printf "[🔊 %s%%]\n" "$VOL" fi else if [ "$VOL" -eq 0 ]; then - printf "[VOL %s]\n" "$VOL]\n" + printf "[MUTE]\n" elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then - printf "[VOL %s]\n" "$VOL" + printf "[VOL %s%%]\n" "$VOL" elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then - printf "[VOL %s]\n" "$VOL" + printf "[VOL %s%%]\n" "$VOL" else - printf "[VOL %s]\n" "$VOL" + printf "[VOL %s%%]\n" "$VOL" fi fi } diff --git a/bar-functions/dwm_pulse.sh b/bar-functions/dwm_pulse.sh index 02db615..84f40fc 100755 --- a/bar-functions/dwm_pulse.sh +++ b/bar-functions/dwm_pulse.sh @@ -7,26 +7,26 @@ # Dependencies: pamixer dwm_pulse () { - VOL=$(pamixer --get-volume) + VOL=$(pamixer --get-volume-human | tr -d '%') if [ "$IDENTIFIER" = "unicode" ]; then - if [ "$VOL" -eq 0 ]; then - printf "[🔇 %s]\n" "$VOL]\n" + if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then + printf "[🔇]\n" elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then - printf "[🔈 %s]\n" "$VOL" + printf "[🔈 %s%%]\n" "$VOL" elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then - printf "[🔉 %s]\n" "$VOL" + printf "[🔉 %s%%]\n" "$VOL" else - printf "[🔊 %s]\n" "$VOL" + printf "[🔊 %s%%]\n" "$VOL" fi else - if [ "$VOL" -eq 0 ]; then - printf "[VOL %s]\n" "$VOL]\n" + if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then + printf "[MUTE]\n" elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then - printf "[VOL %s]\n" "$VOL" + printf "[VOL %s%%]\n" "$VOL" elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then - printf "[VOL %s]\n" "$VOL" + printf "[VOL %s%%]\n" "$VOL" else - printf "[VOL %s]\n" "$VOL" + printf "[VOL %s%%]\n" "$VOL" fi fi }