scripts

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

commit d23dca893b7e45a49a8836ec3827065daff5933a
parent 77253c4d41cb7f64154c8ab2bfbc6f9cfcfb00aa
Author: z3bra <willy@mailoo.org>
Date:   Wed Apr  8 21:12:39 +0200

made popup simpler

Diffstat:
popup | 53+++++++++++++++++------------------------------------
1 file changed, 17 insertions(+), 36 deletions(-)
diff --git a/popup b/popup @@ -2,64 +2,45 @@ # # z3bra - (c) wtfpl 2014 # Create a small popup with the given text +# +# depends: lemonbar, wattr and common sense -TEXT='none' -SLEEP=3 - -ftn="profont" # XFT name of the font, for txtw -fts="12" # size of the said font # bar options #font='-*-stlarch-medium-r-*-*-10-*-*-*-*-*-*-*' -#font="-*-profont-medium-*-*--12-*-*-*-*-*-*-1" font="-*-creep-*-*-*--16-*-*-*-*-*-*-1" bg="#ff040201" fg="#ffdfd5d2" hl="#ff443232" -x=$(wattr w `lsw -r`) -y=$(wattr h `lsw -r`) - -width=180 -height=20 -#offx=10 -offy=10 -offx=$(( x - 14 - $width )) -#offy=$(( y - $height - 10 )) +default_geometry() { + # get screen size + x=$(wattr w `lsw -r`) + y=$(wattr h `lsw -r`) -geom=${width}x${height}+${offx}+${offy} + width=256 + height=28 -usage() { - echo "`basename $0` [-hb] [-d delay] [-t title] [-g WxH+X+Y] [TEXT]" -} - -spawn() { - (echo "%{c}$@";sleep $SLEEP) | lemonbar -d -g $geom -f $font -B $bg -F $fg -} + offy=10 + offx=$(( x - x/2 - $width/2 )) -loop() { - (while :; do - echo "%{c}`$1`" - sleep $SLEEP - done) | bar -g $geom -f $font -B $bg -F $fg + echo "${width}x${height}+${offx}+${offy}" } -test "$#" -lt 1 && +test "$#" -lt 1 && exit 1 -while getopts ":bd:g:hlt:" opt; do +while getopts "d:g:h" opt; do case $opt in - b) BEEP=1 ;; d) SLEEP=$OPTARG ;; - g) geom=$OPTARG ;; + g) GEOM=$OPTARG ;; h) usage; exit 0 ;; *) usage; exit 1 ;; esac done -shift $(( OPTIND - 1 )); +GEOM=${GEOM:-$(default_geometry)} +SLEEP=${SLEEP:-3} -TEXT="$@" -FUNC="echo $TEXT" +(echo "%{c}$@"; sleep $SLEEP) | lemonbar -d -g $GEOM -f $font -B $bg -F $fg -spawn "$TEXT"