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 469e823f8df185c364faab39fea3e646c12b9756
 (DIR) parent d8354e5e9c4bcdadbb17ce8f29bcaaea99f84c9a
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Wed, 22 Oct 2014 16:54:31 +0200
       
       Merge branch 'master' of z3bra.org:scripts
       
       Conflicts:
               menu
       
       Diffstat:
         M cdump                               |       4 ++--
         M dm                                  |       3 ++-
         M imgurup                             |       2 +-
         M mkbar                               |      38 ++++++++++++++++----------------
         M popup                               |       7 +++----
         A todo                                |      32 +++++++++++++++++++++++++++++++
         A wrapbar                             |      20 ++++++++++++++++++++
       
       7 files changed, 79 insertions(+), 27 deletions(-)
       ---
 (DIR) diff --git a/cdump b/cdump
       t@@ -1,7 +1,7 @@
        #!/bin/sh
        
        FILE=$HOME/etc/Xresources
       -FILE=$HOME/etc/theme/bow
       +FILE=$HOME/etc/theme/flashy
        
        for NUM in $(seq 0 7); do
              CN=$(grep "^\*color${NUM}:" $FILE | cut -d':' -f2 | tr -d ' ')
       t@@ -17,7 +17,7 @@ for NUM in $(seq 0 7); do
        done
        echo
        for NUM in $(seq 0 7); do
       -      CN=$(grep "^\*color${NUM}:" $FILE | cut -d':' -f2 | tr -d ' ')
       +    CN=$(grep "^\*color$((${NUM} + 8)):" $FILE | cut -d':' -f2 | tr -d ' ')
              printf    "\e[1;3${NUM}m%s " $CN
        done
        printf "\e[0m\n"
 (DIR) diff --git a/dm b/dm
       t@@ -4,6 +4,7 @@
        # Create/list/attach/detach applications using dtach
        
        sockdir=~/var/run
       +keyseq=
        
        list() {
            # change colors, for fun!
       t@@ -35,4 +36,4 @@ shift
        
        socket="${sockdir}/${name}"
        
       -dtach -${method} ${socket} -r winch $@
       +dtach -${method} ${socket} -e ${keyseq} -r winch $@
 (DIR) diff --git a/imgurup b/imgurup
       t@@ -25,7 +25,7 @@ for IMG in "$@"; do
            URL=$(echo $RESP | sed 's|.*<original_image>\(.*\)</original_image>.*|\1|')
            DELETEURL=$(echo $RESP | sed 's|.*<delete_page>\(.*\)</delete_page>.*|\1|')
        
       -    echo  $URL" | tee $LOG | $CLIP
       +    echo  "$URL" | tee $LOG | $CLIP
            echo "$DELETEURL" >> $LOG
            echo "$URL"
        done
 (DIR) diff --git a/mkbar b/mkbar
       t@@ -16,20 +16,20 @@
        # configuration variables
        refresh_rate=0.75               # how often will the bar update
        datefmt="%d %b %H:%M"         # date time format
       -maildir=~/var/mail/INBOX/new    # where do new mails arrive ?
       +maildir=~/var/mail/inbox/new    # where do new mails arrive ?
        alsactl=Master                  # which alsa channel to display
        #battery=BAT0                    # battery index
        # find battery name in a smart way
        battery=$(ls /sys/class/power_supply | grep BAT)
        
        barch=''
       -barfg='%{F#ff666666}'
       -barmg='%{F#ff2288cc}'
       +barfg='%{F#ff888888}'
       +barmg='%{F#ffffffff}'
        barbg='%{F#00888888}'
        
       -grpfg='%{F#ff111111} '
       +grpfg='%{F#ffffff00} '
        grpmg='%{F#ff2288cc} '
       -grpbg='%{F#ffbbbbbb} '
       +grpbg='%{F#ffffffff} '
        
        # no need to modify anything else here
        
       t@@ -75,10 +75,16 @@ netstate() {
        }
        
        netip() {
       -    # local ip
       -    #ip addr show $(netint) | grep 'inet ' | awk '{print $2}'
       -    # extern ip
       -    curl http://canihazip.com/s
       +    case $1 in
       +        local)
       +            # local ip
       +            ip addr show $(netint) | grep 'inet ' | awk '{print $2}'
       +            ;;
       +        *)
       +            # extern ip
       +            curl http://canihazip.com/s
       +            ;;
       +    esac
        }
        
        nettrafic() {
       t@@ -165,9 +171,9 @@ makebar() {
        
            for v in $(seq 0 $((max - 1))); do
                if [ "$v" -lt "$cur" ]; then
       -            bar="${bar}${barfg}${barch}"
       +            bar="${bar}${barmg}${barch}"
                else
       -            bar="${bar}${barbg}${barch}"
       +            bar="${bar}${barfg}${barch}"
                fi
            done
        
       t@@ -179,14 +185,8 @@ buf="%{l} "
        
        # Set icon depending on the interface that is up
        buf="${buf}${barmg} "
       -if test "$(netint)" = "eth0"; then
       -    buf="${buf}${barfg}"
       -elif test "$(netint)" = "wlan0"; then
       -    buf="${buf}${barfg}"
       -else
       -    buf="${buf}${barfg}"
       -fi
       -buf="$buf $(netstate) "
       +buf="${buf}${barfg}"
       +buf="$buf $(netip local) "
        
        buf="${buf}${barmg} ${barfg} $(nettrafic down) "
        buf="${buf}${barmg} ${barfg} $(nettrafic up) "
 (DIR) diff --git a/popup b/popup
       t@@ -9,7 +9,7 @@ SLEEP=3
        # bar options
        font='-*-stlarch-medium-r-*-*-10-*-*-*-*-*-*-*'
        font="$font,-*-gohufont-medium-*-*--11-*-*-*-*-*-iso10646-1"
       -bg="#ff333333"
       +bg="#ff1d1d1d"
        fg="#ffffffff"
        hl="#ff2288cc"
        
       t@@ -17,9 +17,8 @@ IFS=' x' read x y <<< `xrandr | grep '*' | sed 1q | awk '{print $1}'`
        
        width=300
        height=30
       -offx=$(( x/2 - $width - 74 ))
       -offx=1610
       -offy=1040
       +offx=$(( x - $width  - 10 ))
       +offy=$(( y - $height - 10 ))
        
        title=""
        geom=${width}x${height}+${offx}+${offy}
 (DIR) diff --git a/todo b/todo
       t@@ -0,0 +1,32 @@
       +#!/bin/bash
       +#
       +# z3bra - (c) wtfpl 2014
       +# Manage a todo list.
       +# The file is just plain text, with one line per task.
       +# This script just provide "shorter" commands to append to the file and display
       +# its content. For more complex tasks, use other tools like `sed`.
       +
       +#Where's the file ?
       +TODO=${TODO:-$HOME/.todo}
       +
       +# List the content of the file with some fancy headers
       +list() {
       +    test -f $TODO || { echo "nothing to do, enjoy."; exit 0; }
       +    echo
       +    echo "TODO:"
       +    echo "====="
       +    echo
       +    # WOAH, MUCH CLEVER !
       +    cat -n $TODO
       +    echo
       +}
       +
       +append() {
       +    # append all arguments "as-is" to the file
       +    echo "$*" >> $TODO
       +}
       +
       +# append arguments to the file, or print it otherwise
       +test -n "$*" && append $* || list
       +
       +exit 0
 (DIR) diff --git a/wrapbar b/wrapbar
       t@@ -0,0 +1,20 @@
       +#!/bin/sh
       +#
       +# spawn a status bar
       +
       +set -e
       +
       +# get screen size
       +IFS='x' read w h <<< "$(xrandr | awk '/\*/ {print $1}')"
       +
       +icon="-*-stlarch-medium-*-*--10-*-*-*-*-*-*-*"
       +font="*-gohufont-medium-*-*--11-*-*-*-*-*-iso10646-1"
       +
       +# two "useless" bars, for multi borders
       +echo | bar -p -B\#ff1d1d1d -g $((w - 20))x32+10+10 & sleep 0.1
       +echo | bar -p -B\#ff4c4c4c -g $((w - 26))x26+13+13 & sleep 0.1
       +
       +# and the actual bar
       +while :; do
       +    ~/bin/mkbar
       +done | bar -f "$icon,$font" -B\#ff1d1d1d -g $((w - 30))x22+15+15 &