tMerge branch 'master' of z3bra.org:scripts - scripts - various script and utils
 (HTM) git clone git://z3bra.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit dc17d9d38aaae57d482a15d510be86c77dd8cd78
 (DIR) parent 938c6caae2c64acb7ed6a5552f1b0a9542365fae
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Fri, 23 May 2014 12:31:46 +0200
       
       Merge branch 'master' of z3bra.org:scripts
       
       Diffstat:
         M mkbar                               |      40 +++++++++++++++++++++++++++++--
       
       1 file changed, 38 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/mkbar b/mkbar
       t@@ -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
       t@@ -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
       t@@ -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
       t@@ -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
       t@@ -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) "