From 17b104fc0be0cd65ee74d3970f0c1a15739e8fd7 Mon Sep 17 00:00:00 2001 From: joestandring Date: Fri, 24 May 2019 17:46:31 +0000 Subject: [PATCH] Added dwm_pulse.sh --- README.md | 6 +++++- dwm_bar.sh | 1 + functions/dwm_pulse.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 functions/dwm_pulse.sh diff --git a/README.md b/README.md index 2a010dc..8487540 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ Displays the current master volume of ALSA ``` [🔉 55] ``` +### dwm_pulse +Displays the current master volume of PulseAudio +``` +[🔉 55] +``` Dependencies: ```alsa-utils``` ### dwm_countdown Displays the status of [countdown](https://github.com/joestandring/countdown) @@ -117,7 +122,6 @@ Code for some functions was modified from: * [Parket Johnson](https://github.com/ronno/scripts/blob/master/xsetcmus) * [suckless.org](https://dwm.suckless.org/status_monitor/) ## More to come! -* dwm_pulse function to control pulseaudio sound * dwm_bat function to display battery percentage and status * dwm_notifs function to show the last recieved notification in the bar * dwm_bluez function to show currently connected Bluetooth device using bluez diff --git a/dwm_bar.sh b/dwm_bar.sh index ee46e88..e8eeea8 100755 --- a/dwm_bar.sh +++ b/dwm_bar.sh @@ -23,6 +23,7 @@ DIR=$(dirname "$LOC") . "$DIR/functions/dwm_resources.sh" . "$DIR/functions/dwm_mail.sh" . "$DIR/functions/dwm_alsa.sh" +# . "$DIR/functions/dwm_pulse.sh" . "$DIR/functions/dwm_weather.sh" . "$DIR/functions/dwm_keyboard.sh" . "$DIR/functions/dwm_date.sh" diff --git a/functions/dwm_pulse.sh b/functions/dwm_pulse.sh new file mode 100755 index 0000000..02db615 --- /dev/null +++ b/functions/dwm_pulse.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# A dwm_bar function to show the master volume of PulseAudio +# Joe Standring +# GNU GPLv3 + +# Dependencies: pamixer + +dwm_pulse () { + VOL=$(pamixer --get-volume) + if [ "$IDENTIFIER" = "unicode" ]; then + if [ "$VOL" -eq 0 ]; then + printf "[🔇 %s]\n" "$VOL]\n" + elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then + printf "[🔈 %s]\n" "$VOL" + elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then + printf "[🔉 %s]\n" "$VOL" + else + printf "[🔊 %s]\n" "$VOL" + fi + else + if [ "$VOL" -eq 0 ]; then + printf "[VOL %s]\n" "$VOL]\n" + elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then + printf "[VOL %s]\n" "$VOL" + elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then + printf "[VOL %s]\n" "$VOL" + else + printf "[VOL %s]\n" "$VOL" + fi + fi +} + +dwm_pulse