├── .sxhkdrc ├── README.md ├── clst ├── corner ├── fcs ├── fw ├── grps ├── max ├── middles ├── none ├── sgrd ├── xwait ├── xwait.c └── yawee /.sxhkdrc: -------------------------------------------------------------------------------- 1 | ## sxhkd keybinds 2 | ## dkeg 2015 3 | 4 | ## reload sxhkd 5 | mod4 + Escape 6 | pkill -USR1 -x sxhkd 7 | 8 | ## kill the session 9 | mod4 + ctrl + q 10 | pkill xinit 11 | 12 | ## kill active window 13 | alt + q 14 | killw $(pfw) 15 | #xdo close $(pfw) 16 | 17 | ## general 18 | alt + p 19 | popstat 20 | 21 | #mod4 + Return 22 | # xterm 23 | 24 | alt + Return 25 | urxvt 26 | 27 | mod4 + p 28 | demon 29 | 30 | alt + {_,shift +}b 31 | {vimb,firefox} 32 | 33 | alt + n 34 | leafpad 35 | 36 | alt + d 37 | popper ' ' $(date +'%R'), $(date +' %b %d') 38 | 39 | alt + shift + d 40 | wallblur 41 | 42 | ## manipulating 43 | # move windows 44 | mod4 + {h, j, k, l} 45 | wmv {-20 0, 0 20, 0 -20, 20 0} $(pfw) 46 | #wmv {-10 0, 0 10, 0 -10, 10 0} $(pfw) 47 | 48 | # fast move windows 49 | mod4 + ctrl + {h, j, k, l} 50 | wmv {-80 0, 0 80, 0 -80, 80 0} $(pfw) 51 | 52 | # split 2 windows 53 | mod4 + s 54 | split $(pfw) 55 | 56 | # switchgrid 57 | mod4 + shift + t 58 | sgrd $(pfw) 59 | 60 | # resize windows 61 | mod4 + shift + {h, j, k, l} 62 | wrs {-20 0, 0 20, 0 -20, 20 0} $(pfw) 63 | 64 | # fast resize windows 65 | mod4 + ctrl + shift + {h, j, k, l} 66 | wrs {-40 0, 0 40, 0 -40, 40 0} $(pfw) 67 | 68 | ## cycling 69 | alt + {h,j,k,l} 70 | clst {h,j,k,l} 71 | 72 | ## grouping 73 | # add 74 | mod4 + shift + {1,2,3,4} 75 | grps -s $(pfw) {1,2,3,4} 76 | 77 | # toggle 78 | mod4 + {1,2,3,4} 79 | grps -t {1,2,3,4} 80 | 81 | # remove 82 | mod4 + slash 83 | grps -c $(pfw) all 84 | 85 | ## move windos with mouse 86 | mod4 + !button{1,3} 87 | {wmv,wrs} -a %i %i $(pfw) 88 | 89 | ## window placement 90 | mod4 + {y,u,b,n,g} 91 | corner {tl,tr,bl,br,md} $(pfw) 92 | 93 | ## maximize and fullscreen (like cwm) 94 | alt + {_,shift + }f 95 | max -{m,f} $(pfw) 96 | 97 | mod4 {_,shift + }f 98 | max -p $(pfw) 99 | 100 | ## max horizontal and vertical like (cwm and 2bwm) 101 | alt + {_,shift +}m 102 | max -{v,h} $(pfw) 103 | 104 | ## compton toggle 105 | alt + {_,shift + }c 106 | ~/bin/comp {more,less} 107 | 108 | ## scratchpad 109 | alt + w 110 | mapw -t $(more ~/.scratch) 111 | 112 | ## volume 113 | alt + shift + {equal,minus,F8} 114 | ~/bin/volume {+,-,!}; \ 115 | popper $(~/bin/volume level) 116 | 117 | ## music 118 | mod4 + shift + equal 119 | ~/bin/music +; \ 120 | popper '' $(~/bin/music artist) 121 | 122 | mod4 + shift + minus 123 | ~/bin/music -; \ 124 | popper '' $(~/bin/music artist) 125 | 126 | mod4 + shift + Home 127 | ~/bin/music play; \ 128 | popper '' $(~/bin/music title) 129 | #popper %\{c\} '' $(~/bin/music title) 130 | 131 | mod4 + shift + ctrl + Home 132 | ~/bin/music pause; \ 133 | popper '' $(~/bin/music title) 134 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### Scripts currently using with wm-utils. 2 | ##### From wmutils/contrib, wmutils/opt, z3bra/scripts, Chef 3 | - Thank you to the authors 4 | - I have made some minor changes to suit my needs, 5 | - Source current xcolors for borders 6 | - Padding to corners 7 | - Includes my current sxhkdrc 8 | - middles is a cool little script by ChefIronBelly 9 | 10 | #### Changed a few things for an overall cleaner appeal 11 | - fcs = focus.sh 12 | - clst = closest.sh 13 | * like an alt-tab; allows moving focus b/t windows 14 | - grps = groups.sh 15 | - sgrd = switch_grid.sh 16 | - fw = focus_watcher.sh 17 | * focus newly spawned window, focus next when window in focus closed 18 | - corner 19 | * padding 20 | - maximize -> max 21 | * like cwm and 2bwm. Max vertically, horizontally, or fullscreen. Thannks z3bra! 22 | * added maximize (slight gap all around) like cwm 23 | 24 | #### I have also made a few modifications 25 | - fcs sources xcolors for active and inactive borders 26 | -------------------------------------------------------------------------------- /clst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # z3bra - 2014 (c) wtfpl 4 | # find and focus the closest window in a specific direction 5 | # depends on: focus.sh 6 | 7 | # get current window id 8 | CUR=$(pfw) 9 | file=fcs 10 | usage() { 11 | echo "usage: $(basename $0) " >&2 12 | exit 1 13 | } 14 | 15 | next_east() { 16 | lsw | xargs wattr xi | sort -nr | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" 17 | } 18 | 19 | next_west() { 20 | lsw | xargs wattr xi | sort -n | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" 21 | } 22 | 23 | next_north() { 24 | lsw | xargs wattr yi | sort -nr | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" 25 | } 26 | 27 | next_south() { 28 | lsw | xargs wattr yi | sort -n | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" 29 | } 30 | 31 | # Use the specification of your choice: WASD, HJKL, ←↑↓→, west/north/south/east 32 | case $1 in 33 | h|a|east|left) $file $(next_east) 2>/dev/null ;; 34 | j|s|south|down) $file $(next_south) 2>/dev/null ;; 35 | k|w|north|up) $file $(next_north) 2>/dev/null ;; 36 | l|d|west|right) $file $(next_west) 2>/dev/null ;; 37 | esac 38 | -------------------------------------------------------------------------------- /corner: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CUR=${2:-$(pfw)} 4 | ROOT=$(lsw -r) 5 | SW=$(wattr w $ROOT) 6 | SH=$(wattr h $ROOT) 7 | 8 | BW=$(wattr b $CUR) 9 | W=$(wattr w $CUR) 10 | H=$(wattr h $CUR) 11 | 12 | #X=0 13 | #Y=0 14 | coord="70" 15 | X=$coord 16 | Y=$coord 17 | num=$coord/$BW 18 | 19 | case $1 in 20 | #tr) X=$((SW - W - BW*2)) ;; 21 | tr) X=$((SW - W - BW*$num)) ;; 22 | bl) Y=$((SH - H - BW*$num)) ;; 23 | br) X=$((SW - W - BW*$num)) 24 | Y=$((SH - H - BW*$num)) ;; 25 | md) X=$((SW/2 - W/2 - BW)) 26 | Y=$((SH/2 - H/2 - BW));; 27 | esac 28 | 29 | wtp $X $Y $W $H $CUR 30 | -------------------------------------------------------------------------------- /fcs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # z3bra - 2014 (c) wtfpl 4 | # window focus wrapper that sets borders and can focus next/previous window 5 | # uncomment the active with bb to use bbdr 6 | # bbdr colors active border based on battery state/level 7 | # depends bbdr 8 | 9 | . $HOME/bin/colr 10 | . $HOME/inspin/bbdr 11 | 12 | # border width 13 | #BW=${BW:-5} 14 | BW=${BW:-5} 15 | 16 | # border color 17 | ACTIVE=${ACTIVE:-0x$bb} 18 | #ACTIVE=${ACTIVE:-0x$wht} 19 | INACTIVE=${INACTIVE:-0x$blk} 20 | 21 | # get current window id 22 | CUR=$(pfw) 23 | 24 | usage() { 25 | echo "usage: $(basename $0) " 26 | exit 1 27 | } 28 | 29 | setborder() { 30 | ROOT=$(lsw -r) 31 | 32 | # check if window exists 33 | wattr $2 || return 34 | 35 | # do not modify border of fullscreen windows 36 | test "$(wattr xywh $2)" = "$(wattr xywh $ROOT)" && return 37 | 38 | case $1 in 39 | active) chwb -s $BW -c $ACTIVE $2 ;; 40 | inactive) chwb -s $BW -c $INACTIVE $2 ;; 41 | #active) chwb2 -O $wht -o 1 -i 3 -I $blk -c $ACTIVE $2 ;; 42 | #inactive) chwb2 -O $blk -o 1 -i 3 -I $blk -c $INACTIVE $2 ;; 43 | esac 44 | } 45 | 46 | case $1 in 47 | next) wid=$(lsw|grep -v $CUR|sed '1 p;d') ;; 48 | prev) wid=$(lsw|grep -v $CUR|sed '$ p;d') ;; 49 | 0x*) wattr $1 && wid=$1 ;; 50 | *) usage ;; 51 | esac 52 | 53 | # exit if we can't find another window to focus 54 | test -z "$wid" && echo "$(basename $0): can't find a window to focus" >&2 && exit 1 55 | 56 | setborder inactive $CUR # set inactive border on current window 57 | setborder active $wid # activate the new window 58 | chwso -r $wid # put it on top of the stack 59 | wtf $wid # set focus on it 60 | 61 | # you might want to remove this for sloppy focus 62 | #wmp -a $(wattr xy $wid) # move the mouse cursor to 63 | #wmp -r $(wattr wh $wid) # .. its bottom right corner 64 | -------------------------------------------------------------------------------- /fw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # focus_watcher renamed to fw 3 | # and taking benefit functionality from yawee 4 | # modified with wallpaper effects 5 | 6 | . $HOME/.bg 7 | # get wall from .xinitrc & set attributes 8 | #wall=$(cat ~/.xinitrc|grep hsetroot|cut -d ' ' -f3|awk '{sub(/&/,"");print}') 9 | #wall=$(cat ~/.xinitrc|grep hsetroot|awk '{sub(/&/,"");print}') 10 | BLUR=20 11 | CON="0.7" 12 | BRT="-0.02" 13 | #dir=$HOME/tmp 14 | #back=$(convert $wall -blur $BLUR $tmp/$pic) 15 | #back=convert "$wall" -blur ${1:-$BLUR} "$dir"/tmpwall.jpg 16 | # bg effects on new window 17 | effect(){ 18 | #hsetroot -fill $back 19 | #$wallp -brightness ${1:-$BRT} 20 | #$wallp -brightness ${1:-$BRT} -blur ${1:-$BLUR} 21 | #$wallp -blur ${1:-$BLUR} -brightness ${1:-$BRT} 22 | $wallp -blur ${1:-$BLUR} 23 | #hsetroot -fill $back 24 | #$act $opt ${1:-$back} 25 | } 26 | 27 | file=fcs 28 | 29 | while IFS=: read ev wid; do 30 | case $ev in 31 | # window creation 32 | 16) wattr o $wid || corner md $wid 33 | test "$(lsw)" = "$wid" && effect ;; 34 | #test "$(lsw)" = "$wid" ;; 35 | 36 | # mapping requests 37 | 19) wattr o $wid \ 38 | || $file $wid ;; 39 | 40 | # focus next window when deleting focused window 41 | 18) wattr $(pfw) || $file prev 2>/dev/null 42 | test -z "$(lsw)" && effect 0 ;; 43 | #test -z "$(lsw)" ;; 44 | 45 | # entering window 46 | 7) wattr o $wid || $file $wid ;; 47 | esac 48 | done 49 | -------------------------------------------------------------------------------- /grps: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2015 Greduan , licensed under the WTFPL 4 | # Adds group-like capabilities, sorta like those you find in CWM and such WMs 5 | 6 | usage() { 7 | cat << EOF 8 | usage: $(basename $0) [-hCU] [-c wid] [-s wid group] [-tmMu group] 9 | -h shows this help 10 | -c cleans WID from group files (and makes it visible) 11 | -C runs cleanup routine 12 | -s sets WID's group 13 | -t toggle group visibility state 14 | -m maps (shows) group 15 | -M maps group and unmaps all other groups 16 | -u unmaps (hides) group 17 | -U unmaps all the groups 18 | EOF 19 | 20 | exit 1 21 | } 22 | 23 | # test for no arguments 24 | test $# -eq 0 && usage 25 | 26 | # I suggest it's under /tmp or somewhere that gets cleaned up at reboot or gets 27 | # cleaned up after X stops running 28 | FSDIR=${FSDIR:-$HOME/tmp/groups} 29 | 30 | # define our functions 31 | 32 | # clean WID ($1) from group files 33 | clean_wid() { 34 | # TODO: make POSIX compatible, -i is a GNU-ism 35 | sed -i "/$1/d" $FSDIR/group.* 36 | } 37 | 38 | # cleans group ($1) from (in)active files 39 | clean_status() { 40 | # TODO: make POSIX compatible, -i is a GNU-ism 41 | sed -i "/$1/d" $FSDIR/active 42 | sed -i "/$1/d" $FSDIR/inactive 43 | } 44 | 45 | # shows all the windows in group ($1) 46 | map_group() { 47 | # safety 48 | if ! grep -q $1 < $FSDIR/all; then 49 | echo "Group doesn't exist" 50 | exit 1 51 | fi 52 | 53 | # clean statuses 54 | clean_status $1 55 | # add to active 56 | echo $1 >> $FSDIR/active 57 | 58 | # loop through group and map windows 59 | while read line; do 60 | mapw -m $line 61 | done < $FSDIR/group.$1 62 | } 63 | 64 | # hides all the windows in group ($1) 65 | unmap_group() { 66 | # safety 67 | if ! grep -q $1 < $FSDIR/all; then 68 | echo "Group doesn't exist" 69 | exit 1 70 | fi 71 | 72 | # clean statuses 73 | clean_status $1 74 | # add to inactive 75 | echo $1 >> $FSDIR/inactive 76 | 77 | # loop through group and unmap windows 78 | while read line; do 79 | mapw -u $line 80 | done < $FSDIR/group.$1 81 | } 82 | 83 | # assigns WID ($1) to the group ($2) 84 | set_group() { 85 | # make sure we've no duplicates 86 | clean_wid $1 87 | clean_status $2 88 | 89 | # insert WID into new group if not already there 90 | grep -q $1 < $FSDIR/group.$2 || \ 91 | echo $1 >> $FSDIR/group.$2 92 | 93 | # if we can't find the group add it to groups and make it active 94 | grep -q $2 < $FSDIR/all || \ 95 | echo $2 >> $FSDIR/all && \ 96 | echo $2 >> $FSDIR/active 97 | 98 | # map WID if group is active 99 | grep -q $2 < $FSDIR/active && \ 100 | mapw -m $1 101 | 102 | # unmap WID if group is inactive 103 | grep -q $2 < $FSDIR/inactive && \ 104 | mapw -u $1 105 | } 106 | 107 | # toggles visibility state of all the windows in group ($1) 108 | toggle_group() { 109 | # safety 110 | if ! grep -q $1 < $FSDIR/all; then 111 | echo "Group doesn't exist" 112 | return 113 | fi 114 | 115 | # search through active groups first 116 | grep -q $1 < $FSDIR/active && \ 117 | unmap_group $1 && \ 118 | return 119 | 120 | # search through inactive groups next 121 | grep -q $1 < $FSDIR/inactive && \ 122 | map_group $1 && \ 123 | return 124 | } 125 | 126 | # removes all the unexistent WIDs from groups 127 | # removes all group files that don't exist 128 | # removes from 'all' file all groups that don't exist 129 | cleanup_everything() { 130 | # clean WIDs that don't exist 131 | # using `cat` instead of `<` because error suppression 132 | cat $FSDIR/group.* 2>/dev/null | while read wid; do 133 | wattr $wid || \ 134 | clean_wid $wid 135 | done 136 | 137 | # clean group files that are empty 138 | for file in $FSDIR/group.*; do 139 | # is the group empty? 140 | if [ ! -s $file ]; then 141 | rm -f $file 142 | fi 143 | done 144 | 145 | # remove groups that don't exist from 'all' 146 | while read line; do 147 | if [ ! -f $FSDIR/group.$line ]; then 148 | # TODO: make POSIX compatible, -i is a GNU-ism 149 | sed -i "/$line/d" $FSDIR/all 150 | clean_status $line 151 | fi 152 | done < $FSDIR/all 153 | } 154 | 155 | # actual run logic (including arguments and such) 156 | 157 | # check $FSDIR exists 158 | test -d $FSDIR || mkdir -p $FSDIR 159 | 160 | # touch all the files 161 | test -f $FSDIR/active || :> $FSDIR/active 162 | test -f $FSDIR/inactive || :> $FSDIR/inactive 163 | test -f $FSDIR/all || :> $FSDIR/all 164 | 165 | cleanup_everything 166 | 167 | # getopts yo 168 | while getopts "hc:Cs:t:m:M:u:U" opt; do 169 | case $opt in 170 | h) 171 | usage 172 | ;; 173 | c) 174 | clean_wid $OPTARG 175 | mapw -m $OPTARG 176 | break 177 | ;; 178 | C) 179 | cleanup_everything 180 | break 181 | ;; 182 | s) 183 | set_group $OPTARG $(eval echo "\$$OPTIND") 184 | break 185 | ;; 186 | t) 187 | toggle_group $OPTARG 188 | break 189 | ;; 190 | m) 191 | map_group $OPTARG 192 | break 193 | ;; 194 | M) 195 | for file in $FSDIR/group.*; do 196 | group=${file##*.} 197 | unmap_group $group 198 | done 199 | map_group $OPTARG 200 | break 201 | ;; 202 | u) 203 | unmap_group $OPTARG 204 | break 205 | ;; 206 | U) 207 | for file in $FSDIR/group.*; do 208 | group=${file##*.} 209 | unmap_group $group 210 | done 211 | break 212 | ;; 213 | esac 214 | done 215 | -------------------------------------------------------------------------------- /max: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # rockin' script by z3bra 3 | # includes fullscreen, max h, and max v 4 | # thank you! 5 | # modified by dkeg 6 | # now includes maximize (like cwm), slight gaps all around 7 | # also includes a fullscreen with panel gap 8 | 9 | #. $HOME/bin/barconf 10 | 11 | usage() { 12 | echo "usage: $(basename $0) [-hvmpf] wid" >&2 13 | exit 1 14 | } 15 | 16 | while getopts hvmpf OPT; do 17 | case $OPT in 18 | h) MAX=horz ;; 19 | v) MAX=vert ;; 20 | m) MAX=gmax ;; 21 | p) MAX=fullp ;; 22 | f) MAX=full ;; 23 | *) usage ;; 24 | esac 25 | done 26 | shift $((OPTIND -1)) 27 | 28 | test -n "$1" && WID=$1 || usage 29 | 30 | MAX=${MAX:-full} 31 | EXPANDIR=/tmp/.expan.d 32 | #PAD=$bar3h 33 | PAD=105 34 | #PAD=85 35 | PAD2=18 36 | tg=12 37 | BW=$(wattr b $WID) 38 | SW=$(( $(wattr w `lsw -r`) - 2*$BW)) 39 | SH=$(( $(wattr h `lsw -r`) - 2*$BW)) 40 | SHP=$(( $(wattr h `lsw -r`) - 2*$BW - $PAD2)) 41 | #SWM=$(( $(wattr w `lsw -r`) - 8*$BW - 8*$PAD)) 42 | #SHM=$(( $(wattr h `lsw -r`) - 8*$BW - 8*$PAD)) 43 | SWM=$(( $(wattr w `lsw -r`) - 2*$BW - 2*$PAD)) 44 | SHM=$(( $(wattr h `lsw -r`) - 2*$BW - 2*$PAD)) 45 | 46 | test -d $EXPANDIR || mkdir -p $EXPANDIR 47 | 48 | is_maxed() { 49 | case $MAX in 50 | vert) test $(wattr h $WID) -eq $SHM && return 0 ;; 51 | horz) test $(wattr w $WID) -eq $SWM && return 0 ;; 52 | #vert) test $(wattr h $WID) -eq $SH && return 0 ;; 53 | #horz) test $(wattr w $WID) -eq $SW && return 0 ;; 54 | gmax) test "$(wattr wh $WID)" = "$SWM $SHM" && return 0 ;; 55 | fullp) test "$(wattr wh $WID)" = "$SW $SHP" && return 0 ;; 56 | full) test "$(wattr wh $WID)" = "$SW $SH" && return 0 ;; 57 | esac 58 | 59 | return 1 60 | } 61 | 62 | expand_win() { 63 | wattr xywhi $WID > $EXPANDIR/$WID 64 | case $MAX in 65 | vert) GEOMETRY=$(printf '%d '$PAD' %d %d' $(wattr xw $WID) "$SHM") ;; 66 | #vert) GEOMETRY=$(printf '%d 0 %d %d' $(wattr xw $WID) "$SH") ;; 67 | #horz) GEOMETRY=$(printf '0 %d %d %d' $(wattr y $WID) "$SW" $(wattr h $WID)) ;; 68 | horz) GEOMETRY=$(printf ''$PAD' %d %d %d' $(wattr y $WID) "$SWM" $(wattr h $WID)) ;; 69 | gmax) GEOMETRY=$(printf ''$PAD' '$PAD' %d %d' "$SWM" "$SHM") ;; 70 | fullp) GEOMETRY=$(printf '0 '$PAD2' %d %d' "$SW" "$SHP") ;; 71 | full) GEOMETRY=$(printf '0 0 %d %d' "$SW" "$SH") ;; 72 | esac 73 | wtp ${GEOMETRY} ${WID} 74 | } 75 | 76 | collapse_win() { 77 | test -f $EXPANDIR/$WID || return 78 | wtp $(grep $WID $EXPANDIR/$WID) 79 | rm $EXPANDIR/$WID 80 | } 81 | 82 | is_maxed && collapse_win || expand_win ; 83 | -------------------------------------------------------------------------------- /middles: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ChefIronBelly 2015 3 | # left, center and right middle placement 4 | 5 | CUR=${2:-$(pfw)} 6 | ROOT=$(lsw -r) 7 | SW=$(wattr w $ROOT) 8 | SH=$(wattr h $ROOT) 9 | 10 | BW=$(wattr b $CUR) 11 | W=$(wattr w $CUR) 12 | H=$(wattr h $CUR) 13 | 14 | X=0 15 | Y=0 16 | 17 | case $1 in 18 | uy) X=$((SW/4 - W/2 - BW)) 19 | Y=$((SH/4 - H/2 - BW));; 20 | y) X=$((SW/4 - W/2 - BW)) 21 | Y=$((SH/2 - H/2 - BW));; 22 | g) X=$((SW/2 - W/2 - BW)) 23 | Y=$((SH/2 - H/2 - BW)) ;; 24 | u) X=$((SW/2 + W/4 - BW*2)) 25 | Y=$((SH/2 - H/2 - BW));; 26 | esac 27 | 28 | wtp $X $Y $W $H $CUR 29 | 30 | #mdls=("uy","y","g","u") 31 | #for i in "${mdls[@]}" 32 | # do 33 | # echo $i 34 | # done 35 | 36 | # rndm=$i 37 | -------------------------------------------------------------------------------- /none: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dkeg/wmtls/5db8788cc24b7957e27270b3dd9be9fd96b8d58b/none -------------------------------------------------------------------------------- /sgrd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright (c) 2015 Greduan , licensed under the WTFPL license 4 | # Credit where credit is due, the grid algorithm was written by z3bra 5 | # 6 | # When used puts all the windows in a grid and when you focus one of the windows 7 | # it puts all the windows back to their original location and focuses the window 8 | # you switched to. 9 | # depends on: wew focus.sh 10 | file=fcs 11 | TEMP=$(mktemp) && wattr xywhi $(lsw) > $TEMP 12 | NB=$(wc -l < $TEMP) # NB as in NumBer of windows 13 | 14 | # just safety 15 | if [ $NB -eq 1 ]; then 16 | exit 17 | fi 18 | 19 | # user defined 20 | BW=${BW:-4} # width of your borders 21 | GAP=${GAP:-20} # gap between windows 22 | 23 | # get monitor dimensions 24 | ROOT=$(lsw -r) 25 | SW=$(wattr w $ROOT) 26 | SH=$(wattr h $ROOT) 27 | # reduce screen useable screen area to improve later expressions 28 | SW=$(( SW - GAP - 2*BW )) 29 | SH=$(( SH - GAP - 2*BW )) 30 | 31 | # calculate the size of the grid using the square root of the number of windows 32 | ROWS=$(echo "sqrt($NB)" | bc) 33 | COLS=$ROWS 34 | 35 | # FOLLOWING WAS WRITTEN BY Z3BRA, don't give me credit for this awesome logic 36 | # for each row... 37 | for r in `seq 1 $ROWS`; do 38 | 39 | # .. if we're on the last row, display all the remaining windows 40 | # eg: if we have 12 windows, the square root would be 3 (truncated). 41 | # so the script would draw a 3x3 grid. This would leave 3 windows apart. To 42 | # avoid this, we set the number of columns of the last row as 43 | # 44 | # 12 - 3 * (3-1) 45 | # => 12 - 3 * 2 46 | # => 12 - 6 47 | # == 6 48 | # so we will have 6 windows on the last row, instead of 3. 49 | # This do not lead to the best looking grid, I know (the best one would be 50 | # 3x4), but it's the simplest algo I've found. Don't forget we're playing 51 | # with shell scripts here, not matlab.. 52 | test $r -eq $ROWS && COLS=$(( NB - ROWS * (ROWS-1) )) 53 | 54 | # for each column of each row.. 55 | for c in `seq 1 $COLS`; do 56 | 57 | # exit if we don't have other windows to display 58 | test $(( (r-1)*r + c )) -gt $NB && break 59 | 60 | # heigh of windows (total heigh minus gaps and borders) 61 | H=$(( SH/ROWS - GAP - BW )) 62 | # same for width 63 | W=$(( SW/COLS - GAP - BW )) 64 | 65 | # and the tricky part.. 66 | # The X offset is the width * the actual column (starting from 0) + the 67 | # gaps/borders multiplied by the column number (draw it on a sheet of 68 | # paper like me, it will make much more sense! 69 | X=$(( W * (c-1) + c*(GAP + BW) )) 70 | # same for the Y offset 71 | Y=$(( H * (r-1) + r*(GAP + BW) )) 72 | 73 | # finally, teleport the window to the place we just calculated. 74 | # the sed trick is used to get the corresponding line number in the file 75 | # holding the window infos. 76 | wtp $X $Y $W $H $(sed "$(( (r-1)*r + c ))p;d" $TEMP | cut -d\ -f5) 77 | done 78 | done 79 | # END Z3BRA 80 | 81 | # listen to wew for our desired event 82 | wew -m 4 | while IFS=: read ev wid; do 83 | if [ $ev -eq 4 ]; then 84 | while read line; do 85 | wtp $line 86 | done < $TEMP 87 | fcs $wid 88 | killall wew 89 | fi 90 | done 91 | 92 | # cleanup 93 | rm $TEMP 94 | -------------------------------------------------------------------------------- /xwait: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dkeg/wmtls/5db8788cc24b7957e27270b3dd9be9fd96b8d58b/xwait -------------------------------------------------------------------------------- /xwait.c: -------------------------------------------------------------------------------- 1 | //#!/usr/bin/tcc -run 2 | 3 | /* 4 | * use it to hold your X session. 5 | * You can either compile it, or run it through tcc using it's special shebang, 6 | * that's up to you, really. 7 | * 8 | * echo "exec xwait" >> ~/.xinitrc 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | int 16 | main ( c, v, e ) 17 | int c; 18 | char **v; 19 | char **e; 20 | { 21 | for( ;; ) 22 | { 23 | wait( NULL ); 24 | sleep( 1 ); 25 | } 26 | 27 | return 0; 28 | } 29 | 30 | /* vim: set ft=c: */ 31 | -------------------------------------------------------------------------------- /yawee: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | file=focus.sh 3 | #file=vroum 4 | 5 | while IFS=: read ev wid; do 6 | case $ev in 7 | # window creation 8 | 16) wattr o $wid || corner md $wid ;; 9 | 10 | # mapping requests 11 | 19) wattr o $wid \ 12 | || $file $wid ;; 13 | #&& chwb2 -s 1 -c 0x323232 $wid \ 14 | #$file $wid ;; 15 | 16 | # focus next window when deleting focused window 17 | 18) wattr $(pfw) || $file prev 2>/dev/null;; 18 | #18) wattr $(pfw) || $file prev 2>/dev/null;; 19 | 20 | # entering window 21 | 7) wattr o $wid || $file $wid ;; 22 | # 7) wattr o $wid || $file $wid ;; 23 | esac 24 | done 25 | --------------------------------------------------------------------------------