Last active
April 8, 2018 12:40
Revisions
-
mfaerevaag revised this gist
Apr 8, 2018 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,13 +7,13 @@ signal() { # change after your setup CARD='0' CHANNELS="Master Front Surround Center LFE" # get "muted" or "unmuted" get_state() { res="unmuted" for m in $CHANNELS; do if amixer -c $CARD get $m | grep '\[off\]' > /dev/null; then res="muted" break; @@ -23,10 +23,10 @@ get_state() { echo $res } # run for all playable channels for_all_channels() { for channel in $CHANNELS; do amixer -c $CARD set $channel $1 > /dev/null done } @@ -47,14 +47,14 @@ then elif [[ $1 == "unmute" ]] then for_all_channels "unmute" signal elif [[ $1 == "toggle" ]] then state=`get_state` if [ "$state" == "muted" ]; then for_all_channels "unmute" else amixer -c $CARD set Master mute > /dev/null fi -
mfaerevaag created this gist
Apr 8, 2018 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ #!/bin/sh # signal window manager to update volume bar signal() { pkill -RTMIN+1 i3blocks } # change after your setup CARD='0' MIXERS="Master Front Surround Center LFE" # get "muted" or "unmuted" get_state() { res="unmuted" for m in $MIXERS; do if amixer -c $CARD get $m | grep '\[off\]' > /dev/null; then res="muted" break; fi done echo $res } # run for all playable mixers for_all_mixers() { for m in $MIXERS; do amixer -c $CARD set $m $1 > /dev/null done } # parse arg and run if [[ $1 == "+" ]] then amixer -c $CARD -q sset Master $2+ signal elif [[ $1 == "-" ]] then amixer -c $CARD -q sset Master $2- signal elif [[ $1 == "mute" ]] then amixer -c $CARD set Master mute > /dev/null signal elif [[ $1 == "unmute" ]] then for_all_mixers "unmute" signal elif [[ $1 == "toggle" ]] then state=`get_state` if [ "$state" == "muted" ]; then for_all_mixers "unmute" else amixer -c $CARD set Master mute > /dev/null fi signal elif [[ $1 == "show" ]] then amixer -c $CARD get Master signal else echo "usage: $0 <show | toggle | mute | unmute | +/- [0-9]+>" fi