about summary refs log tree commit diff
path: root/nixos/scripts/get-volume
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/scripts/get-volume')
-rwxr-xr-xnixos/scripts/get-volume22
1 files changed, 22 insertions, 0 deletions
diff --git a/nixos/scripts/get-volume b/nixos/scripts/get-volume
new file mode 100755
index 0000000..4a9d510
--- /dev/null
+++ b/nixos/scripts/get-volume
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Dependencies: pactl, awk
+
+volume=$(pactl list sinks | awk '/^\s+Volume:/ {print $5}' | head -n 1 | tr -d '%')
+muted=$(pactl list sinks | awk '/^\s+Mute:/ {print $2}' | head -n 1)
+
+if [ "$muted" = "yes" ]; then
+    icon="󰝟"
+else
+    if [ "$volume" -le 20 ]; then
+        icon="󰕿"
+    elif [ "$volume" -le 50 ]; then
+        icon="󰖀"
+    elif [ "$volume" -le 100 ]; then
+        icon="󰕾"
+    else
+        icon="󰝝"
+    fi
+fi
+
+echo "$icon $volume%"
+