tChanged overall look and feel - scripts - various script and utils
 (HTM) git clone git://z3bra.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit b87ad9da6dbaa7b28e89667896cfc263faa39e41
 (DIR) parent d0fa7807f860102a6be23aa92065d55e9468508b
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Wed, 23 Apr 2014 18:03:11 +0200
       
       Changed overall look and feel
       
       Diffstat:
         M mkbar                               |     122 +++++++++++++++++++++++++------
         M popup                               |      14 ++++++++------
       
       2 files changed, 107 insertions(+), 29 deletions(-)
       ---
 (DIR) diff --git a/mkbar b/mkbar
       t@@ -5,12 +5,17 @@
        
        # configuration variables
        refresh_rate=0.75               # how often will the bar update
       -datefmt="%H:%M"                 # date time format
       +datefmt="%H:%M - %d %b"         # date time format
        maildir=~/var/mail/INBOX/new    # where do new mails arrive ?
        battery=1                       # battery index
        alsactl=Master                  # which alsa channel to display
       -no_group="%{F#ff1d1d1d}━━%{F-}" # Hidden groups
       -le_group="━━"                   # Current group
       +
       +barch=''
       +barfg='%{F#ffffffff}'
       +barbg='%{F#00333333}'
       +
       +grpfg='%{F#fffff000} '
       +grpbg='%{F#00ffffff} '
        
        # no need to modify anything else here
        
       t@@ -26,12 +31,16 @@ battery() {
            BATC=/sys/class/power_supply/BAT${battery}/capacity
            BATS=/sys/class/power_supply/BAT${battery}/status
        
       -    # prepend percentage with a '+' if charging, '-' otherwise
       -    test "`cat $BATS`" = "Charging" && echo -n '+' || echo -n '-'
       +    # prepend percentage with a '-' if discharging, '+' otherwise
       +    #test "`cat $BATS`" = "Discharging" && echo -n '-' || echo -n '+'
        
            cat $BATC
        }
        
       +muted() {
       +    amixer get $alsactl | grep -o '\[off\]' >/dev/null && false || true
       +}
       +
        volume() {
            amixer get $alsactl | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq
        }
       t@@ -47,7 +56,29 @@ memused() {
            bc <<< "100 * ($t - $f - $c - $b) / $t"
        }
        
       -network() {
       +netstate() {
       +    test -n "`ip route`" && echo "connected" || echo "disconnected"
       +}
       +
       +netip() {
       +    # local ip
       +    #ip addr show $(netint) | grep 'inet ' | awk '{print $2}'
       +    # extern ip
       +    curl http://canihazip.com/s
       +}
       +
       +nettrafic() {
       +    case $1 in
       +        up)     col=10;;
       +        down)   col=2;;
       +        *) 
       +    esac
       +
       +    trafic=$(awk "/$(netint)/ {print \$$col}" /proc/net/dev)
       +    echo $(( trafic / 1024 ))
       +}
       +
       +netint() {
            read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'`
            if iwconfig $int1 >/dev/null 2>&1; then
                wifi=$int1
       t@@ -56,19 +87,27 @@ network() {
                wifi=$int2
                eth0=$int1
            fi
       -    ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 || int=$wifi
        
       -    ping -c 1 8.8.8.8 >/dev/null 2>&1 && 
       -        echo "$int up" || echo "$int down"
       +    if ip link show $eth0 | grep 'state UP' >/dev/null; then
       +        int=$eth0
       +    elif ip link show $wifi | grep 'state UP' >/dev/null; then
       +        int=$wifi
       +    else
       +        int=lo
       +    fi
       +
       +    echo $int
        }
        
        groups() {
            cur=`xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}'`
            tot=`xprop -root _NET_NUMBER_OF_DESKTOPS | awk '{print $3}'`
        
       -    for w in `seq 0 $((cur - 1))`; do line="${line}${no_group}"; done
       -    line="${line}${le_group}"
       -    for w in `seq $((cur + 2)) $tot`; do line="${line}${no_group}"; done
       +    for w in `seq 0 $((cur - 1))`; do line="${line}${grpbg}"; done
       +    line="${line}${grpfg}"
       +    for w in `seq $((cur + 2)) $tot`; do line="${line}${grpbg}"; done
       +    line="${line}%{F-}"
       +
            echo $line
        }
        
       t@@ -79,15 +118,52 @@ nowplaying() {
            test -n "$cur" && $PARSER <<< $cur || echo "- stopped -"
        }
        
       +makebar() {
       +    max=10
       +    cur=$(($1 / 10))
       +
       +    bar="$barfg"
       +
       +    for v in $(seq 0 $((max - 1))); do
       +        if [ "$v" -lt "$cur" ]; then
       +            bar="${bar}${barfg}${barch}"
       +         else
       +            bar="${bar}${barbg}${barch}"
       +        fi
       +    done
       +
       +    echo "${bar}${barfg}"
       +}
       +
        # This loop will fill a buffer with our infos, and output it to stdout.
       -while :; do
       -    buf="%{r}$(groups)   $(clock)"
       -    #buf="${buf} %{F#4c4c4c} CLK: %{F#ffffff}$(clock) "
       -    #buf="${buf} %{F#4c4c4c} NET: %{F#ffffff}$(network) "
       -    #buf="${buf} %{F#4c4c4c} CPU: %{F#ffffff}$(cpuload)%% "
       -    #buf="${buf} %{F#4c4c4c} RAM: %{F#ffffff}$(memused)%% "
       -    #buf="${buf} %{F#4c4c4c} VOL: %{F#ffffff}$(volume)%%  "
       -
       -    echo $buf
       -    sleep ${refresh_rate}
       -done
       +buf="%{l} "
       +
       +# Set icon depending on the interface that is up
       +buf="${buf}%{F#ff49d4dd} "
       +if test "$(netint)" = "eth0"; then
       +    buf="${buf}%{F-}"
       +elif test "$(netint)" = "wlan0"; then
       +    buf="${buf}%{F-}"
       +else
       +    buf="${buf}%{F-}"
       +fi
       +buf="$buf $(netstate) "
       +
       +buf="${buf}%{F#ffcef318} %{F-} $(nettrafic down) "
       +buf="${buf}%{F#ffd43f10} %{F-} $(nettrafic up) "
       +buf="${buf}%{c} $(groups)"
       +buf="${buf}%{r}"
       +buf="${buf}%{F#ffede265} %{F-} $(mails) "
       +
       +# Change icon if volume is muted
       +if amixer get $alsactl | grep '\[off\]' >/dev/null; then
       +    buf="${buf}%{F#ffd43f10} %{F-} "
       +else
       +    buf="${buf}%{F#ff6ac0fd} %{F-} "
       +fi
       +buf="${buf}$(makebar $(volume)) "
       +
       +buf="${buf}%{F#ffef79ae} %{F-} $(makebar $(battery)) "
       +buf="${buf}%{F#ffb3b3b3} %{F-} $(clock)  "
       +echo $buf
       +sleep ${refresh_rate}
 (DIR) diff --git a/popup b/popup
       t@@ -7,7 +7,8 @@ TEXT='none'
        SLEEP=3
        
        # bar options
       -font="-*-gohufont-medium-*-*--11-*-*-*-*-*-iso10646-1"
       +font='-*-stlarch-medium-r-*-*-10-*-*-*-*-*-*-*'
       +font="$font,-*-gohufont-medium-*-*--11-*-*-*-*-*-iso10646-1"
        bg="#00000000"
        fg="#ffffffff"
        hl="#ff333333"
       t@@ -16,8 +17,8 @@ IFS=' x' read x y <<< `xrandr | grep '*' | sed 1q | awk '{print $1}'`
        
        width=120
        height=20
       -offx=$(( $x - $width - 200 ))
       -offy=$(( $y - $height - 0))
       +offx=$(( x/2 - $width - 74 ))
       +offy=10
        
        geom=${width}x${height}+${offx}+${offy}
        
       t@@ -26,7 +27,8 @@ usage() {
        }
        
        spawn() {
       -    (echo "%{c}$@";sleep $SLEEP) | bar -g $geom -f $font -B $bg -F $fg
       +    prefix='%{F#fffffe00} %{F-}'
       +    (echo "%{c}${prefix} $@";sleep $SLEEP) | bar -g $geom -f $font -B $bg -F $fg
        }
        
        loop() {
       t@@ -60,9 +62,9 @@ volumebar() {
        
            for v in $(seq 1 $((max - 1))); do
                if [ "$v" -lt "$cur" ]; then
       -             val="$val%{F${fg}}━━"
       +             val="$val%{F${fg}}──"
                 else
       -             val="$val%{F${hl}}━━"
       +             val="$val%{F${hl}}──"
                fi
            done