commit c786eca

hovercats  ·  2023-11-29 14:36:09 +0000 UTC
parent e491516
focus: nits
1 files changed,  +12, -12
+12, -12
 1@@ -3,9 +3,9 @@
 2 # z3bra - 2014 (c) wtfpl
 3 # window focus wrapper that sets borders and can focus next/previous window
 4 
 5-BW=${BW:-2}                    # border width
 6-ACTIVE=${ACTIVE:-0xffffff}     # active border color
 7-INACTIVE=${INACTIVE:-0x333333} # inactive border color
 8+BW="${BW:-2}"                    # border width
 9+ACTIVE="${ACTIVE:-0xffffff}"     # active border color
10+INACTIVE="${INACTIVE:-0x333333}" # inactive border color
11 
12 # get current window id
13 CUR=$(pfw)
14@@ -16,7 +16,7 @@ usage() {
15 }
16 
17 setborder() {
18-    ROOT=$(lsw -r)
19+    ROOT="$(lsw -r)"
20 
21     # check if window exists
22     wattr "$2" || return
23@@ -24,26 +24,26 @@ setborder() {
24     # do not modify border of fullscreen windows
25     [ "$(wattr xywh "$2")" = "$(wattr xywh "$ROOT")" ] && return
26 
27-    case $1 in
28+    case "$1" in
29         active)   chwb -s "$BW" -c "$ACTIVE" "$2" ;;
30         inactive) chwb -s "$BW" -c "$INACTIVE" "$2" ;;
31     esac
32 }
33 
34 case $1 in
35-    next) wid=$(lsw|grep -v "$CUR"|sed '1 p;d') ;;
36-    prev) wid=$(lsw|grep -v "$CUR"|sed '$ p;d') ;;
37-    0x*) wattr "$1" && wid=$1 ;;
38+    next) wid="$(lsw | grep -v "$CUR" | sed '1 p;d')" ;;
39+    prev) wid="$(lsw | grep -v "$CUR" | sed '$ p;d')" ;;
40+    0x*) wattr "$1" && wid="$1" ;;
41     *) usage ;;
42 esac
43 
44 # exit if we can't find another window to focus
45 [ -z "$wid" ] && printf "$(basename "$0"): can't find a window to focus\n" "%s" >&2 && exit 1
46 
47-setborder inactive "$CUR" # set inactive border on current window
48-setborder active "$wid"   # activate the new window
49-chwso -r "$wid"           # put it on top of the stack
50-wtf "$wid"                # set focus on it
51+setborder inactive "${CUR}" # set inactive border on current window
52+setborder active "${wid}"   # activate the new window
53+chwso -r "${wid}"           # put it on top of the stack
54+wtf "${wid}"                # set focus on it
55 
56 # you might want to remove this for sloppy focus
57 wmp -a "$(wattr xy "$wid")" # move the mouse cursor to