From b2348fe0ef6dc5af4f7815bf852ae722f12f044d Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 9 Feb 2016 15:42:12 +0100 Subject: Improved volume in status bar (recognises mute) --- bin/volume | 19 ++++++++++++------- system/xmobarrc.symlink | 5 ++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bin/volume b/bin/volume index 3e22a2b..1250a80 100755 --- a/bin/volume +++ b/bin/volume @@ -1,8 +1,13 @@ #!/bin/bash -volumes=$(amixer get Master |grep % |awk '{print $5}'|sed 's/[^0-9]//g') -#avg=$(awk '{ print ($1+$2)/2 }' <(echo $volumes)) -if [[ $1 == 'L' ]]; then - echo "$(echo $volumes | cut -d' ' -f1)%" -else - echo "$(echo $volumes | cut -d' ' -f2)%" -fi +outputs=(Left Right) +i=1 +for o in ${outputs[@]}; do + vol=$(amixer get Master |grep "$o" |grep %) + if [[ "$vol" == *"off"* ]]; then + volumes[$i]="M" + else + volumes[$i]=$(echo $vol |awk '{print $5}'|sed 's/[^0-9%]//g') + fi + let i=i+1 +done +echo ${volumes[*]} diff --git a/system/xmobarrc.symlink b/system/xmobarrc.symlink index 3aeec5d..778a890 100644 --- a/system/xmobarrc.symlink +++ b/system/xmobarrc.symlink @@ -10,8 +10,7 @@ Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*" , Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 10 , Run Com "wireless-status" ["wlan0"] "wlan0stat" 10 , Run Battery ["--normal","red","--high","green","-t","% ()"] 150 - , Run Com "volume" ["L"] "vol-l" 10 - , Run Com "volume" ["R"] "vol-r" 10 + , Run Com "volume" [] "volume" 10 , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10 , Run Memory ["-t","Mem: %"] 10 , Run Swap [] 10 @@ -24,6 +23,6 @@ Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*" ] , sepChar = "%" , alignSep = "}{" - , template = "%StdinReader% | %battery% | %vol-l% %vol-r% | %cpu% | %memory% * %swap% | %eth0% - %wlan0% %wlan0stat% }{%date% | %uname% | %kbd% | %EHSB% " + , template = "%StdinReader% | %battery% | %volume% | %cpu% | %memory% * %swap% | %eth0% - %wlan0% %wlan0stat% }{%date% | %uname% | %kbd% | %EHSB% " } -- vim:ft=haskell:tw=9999: -- cgit v1.2.3