-
Notifications
You must be signed in to change notification settings - Fork 1
/
fcs
executable file
·63 lines (50 loc) · 1.6 KB
/
fcs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#
# z3bra - 2014 (c) wtfpl
# window focus wrapper that sets borders and can focus next/previous window
# uncomment the active with bb to use bbdr
# bbdr colors active border based on battery state/level
# depends bbdr
. $HOME/bin/colr
. $HOME/inspin/bbdr
# border width
#BW=${BW:-5}
BW=${BW:-5}
# border color
ACTIVE=${ACTIVE:-0x$bb}
#ACTIVE=${ACTIVE:-0x$wht}
INACTIVE=${INACTIVE:-0x$blk}
# get current window id
CUR=$(pfw)
usage() {
echo "usage: $(basename $0) <next|prev|wid>"
exit 1
}
setborder() {
ROOT=$(lsw -r)
# check if window exists
wattr $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 ;;
#active) chwb2 -O $wht -o 1 -i 3 -I $blk -c $ACTIVE $2 ;;
#inactive) chwb2 -O $blk -o 1 -i 3 -I $blk -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): can't find a 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
# you might want to remove this for sloppy focus
#wmp -a $(wattr xy $wid) # move the mouse cursor to
#wmp -r $(wattr wh $wid) # .. its bottom right corner