summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2022-10-02 15:25:29 -0400
committerLuke Smith <luke@lukesmith.xyz>2022-10-02 15:25:29 -0400
commit28a57eb59ec33308ab0e835429e9a0dcb054d07e (patch)
treed1e21517abdbad006ce088755b631d4e5295d788
parent2e7fc9cfb7f755a9c0341f9f9ae7263ba93911aa (diff)
downloadeibhear-28a57eb59ec33308ab0e835429e9a0dcb054d07e.tar.gz
eibhear-28a57eb59ec33308ab0e835429e9a0dcb054d07e.tar.zst
eibhear-28a57eb59ec33308ab0e835429e9a0dcb054d07e.zip
volume bar more efficient
-rwxr-xr-x.local/bin/statusbar/sb-volume30
1 files changed, 19 insertions, 11 deletions
diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume
index 3cfdc45..d17ce66 100755
--- a/.local/bin/statusbar/sb-volume
+++ b/.local/bin/statusbar/sb-volume
@@ -13,18 +13,26 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-[ $(pamixer --get-mute) = true ] && echo 🔇 && exit
+vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
-vol="$(pamixer --get-volume)"
+# If muted, print 🔇 and exit.
+[ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit
-if [ "$vol" -gt "70" ]; then
- icon="🔊"
-elif [ "$vol" -gt "30" ]; then
- icon="🔉"
-elif [ "$vol" -gt "0" ]; then
- icon="🔈"
-else
- echo 🔇 && exit
-fi
+vol="${vol#Volume: }"
+split() {
+ # For ommiting the . without calling and external program.
+ IFS=$2
+ set -- $1
+ printf '%s' "$@"
+}
+vol="$(split "$vol" ".")"
+vol="${vol##0}"
+
+case 1 in
+ $((vol >= 70)) ) icon="🔊" ;;
+ $((vol >= 30)) ) icon="🔉" ;;
+ $((vol >= 1)) ) icon="🔈" ;;
+ * ) echo 🔇 && exit ;;
+esac
echo "$icon$vol%"