scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit 83914aaa81e4e1484fec7aeff13fb3b581c444f9
parent dd6615f0fd58247658098d0c66917f0d40a579f2
Author: z3bra <willy@mailoo.org>
Date:   Mon May 26 12:01:27 +0200

Merge branch 'master' of z3bra.org:scripts

Diffstat:
mkbar | 42+++++++++++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/mkbar b/mkbar @@ -2,6 +2,16 @@ # # z3bra - (c) wtfpl 2014 # Fetch infos on your computer, and print them to stdout every second. +# +# require : +# amixer - volume() +# bc - cpuload() memused() +# curl - netip() +# fcount - mails() +# iwconfig - netint() (to spot wifi interface) +# mpc - nowplaying() +# xprop - groups() gstate() +# xwininfo - gstate() # configuration variables refresh_rate=0.75 # how often will the bar update @@ -17,6 +27,7 @@ barfg='%{F#ffffffff}' barbg='%{F#00333333}' grpfg='%{F#fffff000} ' +grpmg='%{F#ff666666} ' grpbg='%{F#00ffffff} ' # no need to modify anything else here @@ -113,6 +124,31 @@ groups() { echo $line } +# print current group and shown groups +gstate() { + cur=`xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}'` + tot=`xprop -root _NET_NUMBER_OF_DESKTOPS | awk '{print $3}'` + + for wid in `xprop -root | sed '/_LIST(WINDOW)/!d;s/.*# //;s/,//g'`; do + if grep -q 'IsViewable' <<< $(xwininfo -id $wid); then + grp=`xprop -id $wid _NET_WM_DESKTOP | awk '{print $3}'` + shown="$shown $grp" + fi + done + + for g in `seq 0 $((tot - 1))`; do + if test $g -eq $cur; then + line="${line}${grpfg}" + elif grep -q $g <<< "$shown"; then + line="${line}${grpmg}" + else + line="${line}${grpbg}" + fi + done + + echo $line +} + nowplaying() { cur=`mpc current` # this line allow to choose whether the output will scroll or not @@ -129,7 +165,7 @@ makebar() { for v in $(seq 0 $((max - 1))); do if [ "$v" -lt "$cur" ]; then bar="${bar}${barfg}${barch}" - else + else bar="${bar}${barbg}${barch}" fi done @@ -153,7 +189,7 @@ buf="$buf $(netstate) " buf="${buf}%{F#ffcef318} %{F-} $(nettrafic down) " buf="${buf}%{F#ffd43f10} %{F-} $(nettrafic up) " -buf="${buf}%{c} $(groups)" +buf="${buf}%{c} $(gstate)" buf="${buf}%{r}" buf="${buf}%{F#ffede265} %{F-} $(mails) " @@ -166,7 +202,7 @@ fi buf="${buf}$(makebar $(volume)) " # Show battery status if there is a battery (U DONT SAY) -test -n "$(battery)" && +test -n "${battery}" && buf="${buf}%{F#ffef79ae} %{F-} $(makebar $(battery)) " buf="${buf}%{F#ffb3b3b3} %{F-} $(clock)  "