summaryrefslogtreecommitdiff
path: root/volume-sndiod
blob: b5af2f38a8ca746ed69a30a313172be048cf4cd0 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
# Displays the default device, volume, and mute status for i3blocks

AUDIO_HIGH_SYMBOL='  '

AUDIO_MED_THRESH=50
AUDIO_MED_SYMBOL='  '

AUDIO_LOW_THRESH=0
AUDIO_LOW_SYMBOL='  '

AUDIO_MUTED_SYMBOL='  '

AUDIO_INTERVAL=6

DEFAULT_COLOR="#ffffff"
MUTED_COLOR="#a0a0a0"

USE_PERCENT=1

SUBSCRIBE=0

while getopts pH:M:L:X:T:t:C:c:i:h opt; do
    case "$opt" in
        p) USE_PERCENT=0 ;;
        H) AUDIO_HIGH_SYMBOL="$OPTARG" ;;
        M) AUDIO_MED_SYMBOL="$OPTARG" ;;
        L) AUDIO_LOW_SYMBOL="$OPTARG" ;;
        X) AUDIO_MUTED_SYMBOL="$OPTARG" ;;
        T) AUDIO_MED_THRESH="$OPTARG" ;;
        t) AUDIO_LOW_THRESH="$OPTARG" ;;
        C) DEFAULT_COLOR="$OPTARG" ;;
        c) MUTED_COLOR="$OPTARG" ;;
        i) AUDIO_INTERVAL="$OPTARG" ;;
        h) printf \
"Usage: volume-sndiod [-p] [-H symb] [-M symb]
        [-L symb] [-X symb] [-T thresh] [-t thresh] [-C color] [-c color] [-i inter] [-h]
Options:
-p\tOmit the percent sign (%%) in volume
-H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL'
-M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL'
-L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL'
-X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL'
-T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH
-t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH
-C\tColor for non-muted audio. Default: $DEFAULT_COLOR
-i\tInterval size of volume increase/decrease. Default: $AUDIO_INTERVAL
-h\tShow this help text
" && exit 0;;
    esac
done

case "$BLOCK_BUTTON" in
    2) aucactl master=$(
    4) aucactl master=$( expr $RAWVOL + $AUDIO_INTERVAL) ;;
    5) aucactl master=$( expr $RAWVOL - $AUDIO_INTERVAL) ;;
esac

function print_format {
    PERCENT="%"
    [[ $USE_PERCENT == 0 ]] && PERCENT=""
    echo "$SYMBOL$VOL$PERCENT"
}

function print_block {
    RAWVOL=$(aucatctl master | cut -d = -f 2)
    VOL=$( expr $RAWVOL \* 100 / 127)


    SYMBOL=$AUDIO_HIGH_SYMBOL
    [[ $VOL -le $AUDIO_MED_THRESH ]] && SYMBOL=$AUDIO_MED_SYMBOL
    [[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMBOL=$AUDIO_LOW_SYMBOL
    COLOR=$DEFAULT_COLOR

    print_format
    echo "$COLOR"
}

print_block