diff options
author | Jochen Keil <jochen.keil@gmail.com> | 2012-08-12 11:33:54 +0200 |
---|---|---|
committer | Jochen Keil <jochen.keil@gmail.com> | 2012-08-12 11:33:54 +0200 |
commit | abb0b488741fc2f20a1486a6f122f7f6fa38e92d (patch) | |
tree | 4de873210308c7c84e168c4eec2e4ca01b99e52c /samples/status.sh | |
parent | 2570b0d756121fb6314de514412b52f648d0fc25 (diff) | |
download | xmobar-abb0b488741fc2f20a1486a6f122f7f6fa38e92d.tar.gz xmobar-abb0b488741fc2f20a1486a6f122f7f6fa38e92d.tar.bz2 |
Fancier status script sample
This sample script uses colors and unicode signs for drawing a status
bar for e.g. volume. The unicode character can be simply changed to an
ascii one in case of problems.
Diffstat (limited to 'samples/status.sh')
-rwxr-xr-x | samples/status.sh | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/samples/status.sh b/samples/status.sh index fc8af11..c84d7f2 100755 --- a/samples/status.sh +++ b/samples/status.sh @@ -1,10 +1,6 @@ #!/bin/sh - STATUSPIPE="/tmp/xmobar_status_jrk" -NORMAL='#eee8d5' -MUTED='#cb4b16' -FGCOLOR="#657b83" function isMuted () { # retrieve mute status @@ -17,23 +13,35 @@ function getPercent () { echo "66" } - function percentBar () { - local res= i=1 - local percent=$( getPercent ) - - if [ -n "$( isMuted )" ]; then - res="<fc=$MUTED>" + local i=1 res= + normal=47 high=80 + fgColor='#657b83' mutedColor='#cb4b16' + lowColor='#859900' midColor='#b58900' + highColor='#cb4b16' + + bar="$(echo -ne "\u2588")" + percent="$( getPercent )" + muted="$( isMuted )" + + if [ -n "$muted" ]; then + res="<fc=$mutedColor>" else - res="<fc=$NORMAL>" + res="<fc=$lowColor>" fi while [ $i -lt $percent ]; do - res+='#' + if [ $i -eq $normal -a -z "$muted" ]; then + res+="</fc><fc=$midColor>" + elif [ $i -eq $high -a -z "$muted" ]; then + res+="</fc><fc=$highColor>" + fi + + res+=$bar i=$((i+1)) done - res+="</fc><fc=$FGCOLOR>" + res+="</fc><fc=$fgColor>" while [ $i -lt 100 ]; do res+='-' @@ -43,5 +51,4 @@ function percentBar () { echo "$res</fc>" } - echo "$( percentBar )" > "$STATUSPIPE" |