summaryrefslogtreecommitdiff
path: root/scripts/.local/bin/sb-volume
blob: bfa789934aaf8e62d7de1dd337c82c50e9ffc75c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

# Prints the current volume or MUT if muted.

if [ "$(pamixer --get-mute)" = true ]; then
    vol="MUT"
else
    vol="$(pamixer --get-volume)"
fi

if ! command -v pamixer ;then
    vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
    case "$vol" in
        *MUTED*) vol="MUT" ;;
        *) vol=$(echo "100*$(echo "$vol" | cut -d' ' -f2)/1" | bc) ;;
    esac
fi

# for slstatus
printf "%s" "$vol" > "$XDG_RUNTIME_DIR/volume"

# for dwmblocks
printf "%3d" "$vol"