tAdded a bunch of new scripts - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 0fde3c1375342d76ee5db0225c0a4d0e22a25c12
(DIR) parent 4deba4b0bcd92c61ba8b3ff88f172a14a5d5f3ff
(HTM) Author: z3bra <willy@mailoo.org>
Date: Fri, 9 Jan 2015 18:40:37 +0100
Added a bunch of new scripts
Diffstat:
A corner | 24 ++++++++++++++++++++++++
A fullscreen | 42 +++++++++++++++++++++++++++++++
A groaw | 79 +++++++++++++++++++++++++++++++
A link-open | 10 ++++++++++
A radio | 3 +++
A record | 7 +++++++
A tile | 48 +++++++++++++++++++++++++++++++
A timebar | 17 +++++++++++++++++
A vroum | 49 +++++++++++++++++++++++++++++++
A yawee | 14 ++++++++++++++
10 files changed, 293 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/corner b/corner
t@@ -0,0 +1,24 @@
+#!/bin/sh
+
+CUR=${2:-$(pfw)}
+ROOT=$(lsw -r)
+SW=$(wattr w $ROOT)
+SH=$(wattr h $ROOT)
+
+BW=$(wattr b $CUR)
+W=$(wattr w $CUR)
+H=$(wattr h $CUR)
+
+X=0
+Y=0
+
+case $1 in
+ tr) X=$((SW - W - BW*2)) ;;
+ bl) Y=$((SH - H - BW*2)) ;;
+ br) X=$((SW - W - BW*2))
+ Y=$((SH - H - BW*2)) ;;
+ md) X=$((SW/2 - W/2 - BW))
+ Y=$((SH/2 - H/2 - BW));;
+esac
+
+wtp $X $Y $W $H $CUR
(DIR) diff --git a/fullscreen b/fullscreen
t@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# z3bra - 2014 (c) wtfpl
+# toggle the fullscreen state of a window
+
+# this file is used to store the previous geometry of a window
+FSFILE=${FSFILE:-~/.fwin}
+
+# it's pretty simple, but anyway...
+usage() {
+ echo "usage: $(basename $0) <wid>"
+ exit 1
+}
+
+# exit if no argument given
+test -z "$1" && usage
+
+# this will unset the fullscreen state of any fullscreen window if there is one.
+# this way, there will only be one window in fullscreen at a time, and no window
+# will loose their previous geometry info
+test -f $FSFILE && wtp $(cat $FSFILE)
+
+# if file exist and contain our window id, it means that out window is in
+# fullscreen mode
+if test -f $FSFILE && grep -q $1 $FSFILE; then
+ # if the window we removed was our window, delete the file, so we can
+ # fullscreen it again later
+ rm -f $FSFILE
+
+else
+ # if not, then put the current window in fullscreen mode, after saving its
+ # geometry and id to $FSFILE we also remove any border from this window.
+ wattr xywhi $1 > $FSFILE
+ wtp $(wattr xywh `lsw -r`) $1
+ chwb -s 0 $1
+fi
+
+# now focus the window, and put it in front, no matter which state we're in, and
+# put the cursor on its bottom-right corner (for consistency)
+vroum $1
+wmp -a $(wattr xy $1)
+wmp -r $(wattr wh $1)
(DIR) diff --git a/groaw b/groaw
t@@ -0,0 +1,79 @@
+#!/bin/sh
+#
+# z3bra - 2014 (c) wtfpl
+# groaw - group, organize and arrange windows (or just a bear behind you)
+
+GROOT=$HOME/.groaw.d
+GNUMBER=3
+
+usage() {
+ echo "$(basename $0) [-h] [-admtu <gid>]"
+}
+
+add_to_group() {
+ :> $GROOT/$2/$1
+ show_group $2
+}
+
+remove_from_group() {
+ test "$2" = "all" \
+ && rm -f $GROOT/*/$1 \
+ || rm -f $GROOT/$2/$1
+}
+
+find_group() {
+ file=$(find $GROOT -name "$1")
+ test -n "$file" && basename $(dirname $file)
+}
+
+show_group() {
+ for file in $GROOT/$1/*; do
+ wid=$(basename $file)
+ mapw -m $wid
+ done
+}
+
+hide_group() {
+ for file in $GROOT/$1/*; do
+ wid=$(basename $file)
+ mapw -u $wid
+ done
+}
+
+togg_group() {
+ wid=$(ls -1 $GROOT/$1 | sed 1q)
+
+ test -z "$wid" && return
+ mapw $wid \
+ && hide_group $1 \
+ || show_group $1
+}
+
+check_groups_sanity() {
+ for gid in $(seq 1 $GNUMBER ); do
+ test -d $GROOT/$gid || mkdir -p $GROOT/$gid
+ done
+
+ for file in $(find $GROOT -type f); do
+ wid=$(basename $file)
+ wattr $wid || rm -f $file
+ done
+}
+
+check_groups_sanity
+
+while getopts ":a:wd:ghm:t:u:" opt; do
+ case $opt in
+ a) add_to_group `pfw` $OPTARG ;;
+ d) remove_from_group `pfw` $OPTARG ;;
+ g) find_group `pfw` ;;
+ m) show_group $OPTARG ;;
+ t) togg_group $OPTARG ;;
+ u) hide_group $OPTARG ;;
+ *) usage && exit 0;;
+ esac
+done
+
+# in case no argument is given, display the whole tree
+test $# -eq 0 && tree --noreport $GROOT
+
(DIR) diff --git a/link-open b/link-open
t@@ -0,0 +1,10 @@
+#!/bin/sh
+
+URI="$*"
+
+thingmenu -g 120x120 \
+ "picture" "img '$URI'" \
+ "video" "mplayer '$URI'" \
+ "donlad" "urxvt -cd $HOME/tmp -e curl -sO '$URI'" \
+ "kinda vid" "uplay '$URI'" \
+ "web shit" "dwb '$URI'" 2>/dev/null
(DIR) diff --git a/radio b/radio
t@@ -0,0 +1,3 @@
+#!/bin/sh
+
+mplayer -nocache http://radio.2f30.org:8000/live.ogg
(DIR) diff --git a/record b/record
t@@ -0,0 +1,7 @@
+#!/bin/sh
+ffmpeg -y -f x11grab -s 1440x900 -i $DISPLAY -an $1.mkv
+tput setaf 1
+echo ABOUT TO MAKE WEBM FROM RECORDING, ^C TO ABORT
+sleep 5
+tput setaf default
+ffmpeg -y -i $1.mkv -c:v libvpx -an -b:v 2000k -s 1440x900 $1.webm
(DIR) diff --git a/tile b/tile
t@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# z3bra - 2014 (c) wtfpl
+# arrange windows in a tiled pattern
+
+# default values for gaps and master area
+GAP=${GAP:-20}
+MASTER=${MASTER:-900}
+
+# get current window id and its borderwidth
+PFW=$(pfw)
+
+# retrieve first window
+wattr $PFW || PFW=$(lsw|sed 1q)
+
+test -z "$PFW" && exit 1
+
+
+# get root window's size (beware, multi-head setups...)
+ROOT=$(lsw -r)
+SW=$(wattr w $ROOT)
+SH=$(wattr h $ROOT)
+
+# get window's borderwidth
+BW=$(wattr b $PFW)
+
+# get the number of windows to put in the stacking area
+MAX=$(lsw|grep -v $PFW|wc -l)
+
+# calculate usable screen size (without borders and gaps)
+SW=$((SW - GAP - 2*BW))
+SH=$((SH - GAP - 2*BW))
+
+test "$MAX" -eq 0 && wtp $GAP $GAP $((SW - GAP)) $((SH - GAP)) $PFW && exit
+
+# put current window in master area
+wtp $GAP $GAP $((MASTER - GAP - 2*BW)) $((SH - GAP)) $PFW
+
+# and now, stack up all remaining windows on the right
+Y=$((0 + GAP))
+X=$((MASTER + GAP))
+W=$((SW - MASTER - GAP))
+H=$((SH / MAX - GAP - 2*BW))
+
+for wid in $(lsw|grep -v $PFW); do
+ wtp $X $Y $W $H $wid
+ Y=$((Y + H + GAP + 2*BW))
+done
(DIR) diff --git a/timebar b/timebar
t@@ -0,0 +1,17 @@
+#!/bin/sh
+
+ROOT=$(lsw -r)
+SW=$(wattr w $ROOT)
+SH=$(wattr h $ROOT)
+
+W=64
+H=32
+X=$((SW - W))
+Y=$((SH - H))
+
+font='-*-profont-medium-*-*--12-*-*-*-*-*-*-1'
+
+while :; do
+ date "+%{c}%T"
+ sleep 1
+done | bar -d -g ${W}x${H}+$X+$Y -f "$font" -B\#ff261616 -F\#ff888888
(DIR) diff --git a/vroum b/vroum
t@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# z3bra - 2014 (c) wtfpl
+# window focus wrapper that sets borders and can focus next/previous window
+
+BW=${BW:-2} # border width
+ACTIVE=${ACTIVE:-0xcc6464} # active border color
+INACTIVE=${INACTIVE:-0xffffff} # inactive border color
+
+# get current window id
+CUR=$(pfw)
+
+usage() {
+ echo "usage: $(basename $0) <next|prev|wid>"
+ exit 1
+}
+
+setborder() {
+ ROOT=$(lsw -r)
+
+ # check that window exists and shouldn't be ignored
+ wattr $2 || return
+ wattr o $2 && return
+
+ # do not modify border of fullscreen windows
+ test "$(wattr xywh $2)" = "$(wattr xywh $ROOT)" && return
+
+ case $1 in
+ active) chwb -s $BW -c $ACTIVE $2 ;;
+ inactive) chwb -s $BW -c $INACTIVE $2 ;;
+ esac
+}
+
+case $1 in
+ next) wid=$(lsw|grep -v $CUR|sed '1 p;d') ;;
+ prev) wid=$(lsw|grep -v $CUR|sed '$ p;d') ;;
+ 0x*) wattr $1 && wid=$1 ;;
+ *) usage ;;
+esac
+
+# exit if we can't find another window to focus
+test -z "$wid" && { echo "$(basename $0): no window to focus" >&2; exit 1; }
+
+setborder inactive $CUR # set inactive border on current window
+setborder active $wid # activate the new window
+chwso -r $wid # put it on top of the stack
+wtf $wid # set focus on it
+#wmp -a $(wattr xyi $wid) # move the mouse cursor to
+#wmp -r $(wattr whi $wid) # .. its bottom right corner
(DIR) diff --git a/yawee b/yawee
t@@ -0,0 +1,14 @@
+#!/bin/sh
+
+while IFS=: read ev wid; do
+ case $ev in
+ # window creation
+ 16) wattr o $wid \
+ && chwb -s 2 -c 0x564444 $wid \
+ || { corner md $wid; vroum $wid; } ;;
+ 18) vroum next 2>/dev/null;;
+
+ # entering window
+ 7) wattr o $wid || vroum $wid ;;
+ esac
+done