summaryrefslogtreecommitdiffstats
path: root/volchange
blob: 88dc0e25e735cc7035f3b93491cfe67f7e45f957 (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
#!/bin/zsh
if =grep -q oss_hdaudio /proc/modules;then
    type="vmix0-outvol"

    max="25.0"
    if [[ $1 = 'cur' ]];then 
        cur=$(ossmix $type | awk '{ print $10 }'); 
        cur=$(( ${cur#*:}/$max * 100.0 ))
        printf "♪ %.2f ♪" $cur
        exit
    fi
    if  [[ $1 = '1' ]];then curvol="+3" ;fi
    if  [[ $1 = '2' ]];then curvol="-3";fi
    if [[ $1 = 'mute' ]];then ossmix jack.int-speaker.mute TOGGLE; exit;fi
    ossmix $type -- "$curvol"
else
    if [[ $1 = 'cur' ]];then
        vol=$(amixer get Master | /bin/grep Mono:)
        if =grep -q "\[on\]" <<<$vol;then
            amixer get Master | /bin/grep Mono: | perl -lne 'print ($_ =~ m{([0-9]+)%})'
        else
            echo -n "Mute"
        fi
        exit
    fi
    if  [[ $1 = '1' ]];then curvol="10%+" ;fi
    if  [[ $1 = '2' ]];then curvol="10%-";fi
    if [[ $1 = 'mute' ]];then
        amixer sset Master playback toggle
        exit
    fi
    amixer sset Master playback $curvol
fi