summaryrefslogtreecommitdiff
path: root/scripts/volume-control
blob: bd47feab3ed496d1947455e526c1552e4499517e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash

# Taken from: https://github.com/salanpro/hyprland/tree/047f998e710b0ffe8d841a89fb7749b50c931b2c/.config/hypr/scripts

# Volume up and down
if [[ "$1" == "up" ]]; then
    wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ \
        && wpctl get-volume @DEFAULT_AUDIO_SINK@ | \
        awk '{print int($2*100)}' | xargs -I[] \
        notify-send -e -u low -h string:x-canonical-private-synchronous:volume_notif -h \
        int:value:[] "󰓃 Volume []"
elif [[ "$1" == "down" ]]; then
    wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%- \
        && wpctl get-volume @DEFAULT_AUDIO_SINK@ | \
        awk '{print int($2*100)}' | xargs -I[] \
        notify-send -e -u low -h string:x-canonical-private-synchronous:volume_notif -h \
        int:value:[] "󰓃 Volume []"
elif [[ "$1" == "mute" ]]; then
    wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle \
        && (wpctl get-volume @DEFAULT_AUDIO_SINK@ \
        | grep -q MUTED && \
        notify-send -e -u low -h \
        string:x-canonical-private-synchronous:volume_notif \
        "󰝟 Muted" || wpctl get-volume @DEFAULT_AUDIO_SINK@ | \
        awk '{print int($2*100)}' | xargs -I[] \
        notify-send -e -u low -h string:x-canonical-private-synchronous:volume_notif -h \
        int:value:[] "󰓃 Volume []")
fi