about summary refs log tree commit diff
path: root/nixos/scripts/get-volume
blob: 4a9d51093bf35c33d625622e88a5558620ba8e82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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%"