Super hacky shell wrapper around lemonbar that aims to poll as little as possible, minimising bar updates to the screen and reduce resource usage.
git clone https://mcol.xyz/code/lemontools
Log | Files | Refs | README | LICENSE

commit 11af88bb528ab31e591b809dab837b7a619e7959
parent 6e276353f39c64577392dc24136a1fffe7213bbf
Author: mcol <mcol@posteo.net>
Date:   Sat, 16 Feb 2019 16:54:07 +0000

incorporated mute into alsa vol module with fontawesome5 icons

Diffstat:
Mmodules/alsa | 46+++++++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 9 deletions(-)

diff --git a/modules/alsa b/modules/alsa @@ -6,23 +6,45 @@ # Settings: # $alsa_mixer : mixer to use (default: PCM) -# $alsa_bg : background colour for module -# $alsa_fg : foreground colour for module +# $alsa_format : format string (default: '${pad}${icon} ${volume}%${pad}') + + +update_alsa_mute() { + if [[ $(amixer sget Master | awk -F '[][]' 'NR==5{print $6}') == 'on' ]] + then + muted=false + else + muted=true + fi + update_alsa +} update_alsa() { local output + local volume + local icon + if [[ $# > 0 ]] then - output=$($dir/src/alsa -m $alsa_mixer -c $1) + volume=$($dir/src/alsa -m $alsa_mixer -c $1) else - output=$($dir/src/alsa -m $alsa_mixer) + volume=$($dir/src/alsa -m $alsa_mixer) fi - output=${alsa_prefix}${output}${alsa_suffix} - output=${pad}${output}${pad} - output=%{F$alsa_fg}%{B$alsa_bg}${output}%{B-}%{F-} + if $muted + then + icon=%{O2} + elif [[ $volume -gt 50 ]] + then + icon= + else + icon=%{O5} + fi + + output=$(eval echo $alsa_format) output=${alsa_pre}${output}${alsa_post} + echo "alsa='$output'" > $fifo 2>> $log } @@ -30,9 +52,15 @@ update_alsa() { _alsa() { get_clicks alsa - [[ -z "$alsa_bg" ]] && alsa_bg=$background - [[ -z "$alsa_fg" ]] && alsa_fg=$foreground [[ -z "$alsa_mixer" ]] && alsa_mixer=PCM + [[ -z "$alsa_format" ]] && alsa_format='${pad}${icon} ${volume}%${pad}' + + if [[ $(amixer sget Master | awk -F '[][]' 'NR==5{print $6}') == 'on' ]] + then + muted=false + else + muted=true + fi update_alsa & }