diff options
author | Jackson Taylor <jackson@jacksontaylor.xyz> | 2021-02-01 19:04:54 -0500 |
---|---|---|
committer | Jackson Taylor <jackson@jacksontaylor.xyz> | 2021-02-01 19:04:54 -0500 |
commit | aa3f11586147f2a9528e59688a6607d386d2b818 (patch) | |
tree | e2b26ad9c82fcd1163df4c6acf6a4cce89527cbe /.local/bin/statusbar/volume | |
parent | 445f6eaeb94d97aa271970b0fdbbb6841dd349a4 (diff) |
Add local bin folder
Diffstat (limited to '.local/bin/statusbar/volume')
-rwxr-xr-x | .local/bin/statusbar/volume | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/.local/bin/statusbar/volume b/.local/bin/statusbar/volume new file mode 100755 index 0000000..2766ed2 --- /dev/null +++ b/.local/bin/statusbar/volume @@ -0,0 +1,38 @@ +#!/bin/sh + +# Prints the current volume or 🔇 if muted. Uses PulseAudio by default, +# uncomment the ALSA lines if you remove PulseAudio. + +case $BLOCK_BUTTON in + # 1) setsid -f "$TERMINAL" -e alsamixer ;; + # 2) amixer sset Master toggle ;; + # 4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;; + # 5) amixer sset Master 5%- >/dev/null 2>/dev/null ;; + 1) setsid -f "$TERMINAL" -e pulsemixer ;; + 2) pamixer -t ;; + 4) pamixer --allow-boost -i 1 ;; + 5) pamixer --allow-boost -d 1 ;; + 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +volstat="$(pactl list sinks)" +# volstat="$(amixer get Master)" # ALSA only equivalent. + +echo "$volstat" | grep -q "Mute: yes" && printf "🔇\\n" && exit +# echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit # ALSA + +vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")" +# vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") # ALSA + +if [ "$vol" -gt "70" ]; then + icon="🔊" +elif [ "$vol" -lt "30" ]; then + icon="🔈" +else + icon="🔉" +fi + +printf "%s%s%%\\n" "$icon" "$vol" |