commit c3b440d

hovercats  ·  2023-03-25 07:51:13 +0000 UTC
parent 8bf004e
nits
2 files changed,  +25, -23
+2, -0
 1@@ -19,6 +19,7 @@ usage() {
 2 # this will unset the fullscreen state of any fullscreen window if there is one.
 3 # this way, there will only be one window in fullscreen at a time, and no window
 4 # will loose their previous geometry info
 5+# shellcheck disable=2046
 6 [ -f "${FSFILE}" ] && wtp $(cat "${FSFILE}")
 7 
 8 # if file exist and contain our window id, it means that out window is in
 9@@ -33,6 +34,7 @@ else
10     # geometry and id to $FSFILE we also remove any border from this window.
11     wattr xywhi "$1" > "${FSFILE}"
12     chwb -s 0 "$1"
13+    # shellcheck disable=2046
14     wtp $(wattr xywh $(lsw -r)) "$1"
15 fi
16 
+23, -23
  1@@ -22,74 +22,74 @@ EOF
  2 ws_init() {
  3 	mkdir -p /tmp/workspaces/
  4 	i=0
  5-	while [ $i -le $NUM_WS ]; do
  6+	while [ "$i" -le "${NUM_WS}" ]; do
  7 		:> /tmp/workspaces/ws"$i"
  8-		i=$(echo $i + 1 | bc)
  9+		i="$(echo "$i" + 1 | bc)"
 10 	done
 11 	echo 0 > /tmp/workspaces/curr
 12 }
 13 # Saves all mapped windows to the current workspace.
 14 save_ws() {
 15 	curr=$(cat /tmp/workspaces/curr)
 16-	lsw > /tmp/workspaces/ws"$curr"
 17+	lsw > /tmp/workspaces/ws"${curr}"
 18 }
 19 move_to_ws() {
 20 	ws_num=$1
 21-	if [ "$ws_num" -gt $NUM_WS ] || [ "$ws_num" -lt 0 ]; then
 22+	if [ "${ws_num}" -gt "${NUM_WS}" ] || [ "${ws_num}" -lt 0 ]; then
 23 		echo "Workspace not found"
 24 		return
 25 	fi
 26 	curr_ws=$(cat /tmp/workspaces/curr);
 27-	if [ "$ws_num" = "$curr_ws" ]; then
 28+	if [ "${ws_num}" = "${curr_ws}" ]; then
 29 		# same workspace. ignore flicker
 30 		return
 31 	fi
 32 	save_ws
 33 	curr_windows=$(lsw)
 34-	if [ "$curr_windows" ]; then
 35+	if [ "${curr_windows}" ]; then
 36 		mapw -u "$(lsw)"
 37 	fi
 38-	new_windows="$(cat /tmp/workspaces/ws"$ws_num")"
 39+	new_windows="$(cat /tmp/workspaces/ws"${ws_num}")"
 40 	if [ "$new_windows" ]; then
 41 		mapw -m "$new_windows"
 42 	fi
 43-	echo "$ws_num" > /tmp/workspaces/curr
 44+	echo "${ws_num}" > /tmp/workspaces/curr
 45 }
 46 next_ws() {
 47 	# Get what ws we're currently in.
 48 	curr=$(cat /tmp/workspaces/curr)
 49-	curr=$(echo "$curr" + 1 | bc)
 50+	curr=$(echo "${curr}" + 1 | bc)
 51 
 52 	# Take care of loopback.
 53-	if [ "$curr" -gt $NUM_WS ]; then
 54+	if [ "${curr}" -gt "${NUM_WS}" ]; then
 55 		curr=0
 56 	fi
 57 
 58-	move_to_ws $curr
 59+	move_to_ws "${curr}"
 60 }
 61 prev_ws() {
 62 	# Get what ws we're currently in.
 63 	curr=$(cat /tmp/workspaces/curr)
 64-	curr=$(echo "$curr" - 1 | bc)
 65+	curr=$(echo "${curr}" - 1 | bc)
 66 
 67 	# Take care of loopback.
 68-	if [ "$curr" -lt 0 ]; then
 69-		curr=$NUM_WS
 70+	if [ "${curr}" -lt 0 ]; then
 71+		curr="${NUM_WS}"
 72 	fi
 73 
 74-	move_to_ws "$curr"
 75+	move_to_ws "${curr}"
 76 }
 77 move_focused_window() {
 78-	ws_num=$1
 79-	if [ "$ws_num" -gt "$NUM_WS" ] || [ "$ws_num" -lt 0 ]; then
 80+	ws_num="$1"
 81+	if [ "${ws_num}" -gt "${NUM_WS}" ] || [ "${ws_num}" -lt 0 ]; then
 82 		echo "Workspace not found"
 83 		return
 84 	fi
 85-	wid=$(pfw)
 86-	curr_ws=$(cat /tmp/workspaces/curr);
 87-	if [ "$ws_num" != "$curr_ws" ]; then
 88+	wid="$(pfw)"
 89+	curr_ws="$(cat /tmp/workspaces/curr)";
 90+	if [ "${ws_num}" != "${curr_ws}" ]; then
 91 		pfw >> /tmp/workspaces/ws"$1"
 92-		mapw -u "$wid"
 93+		mapw -u "${wid}"
 94 	fi
 95 }
 96 while getopts ":m:g:npi" opt; do
 97@@ -99,9 +99,9 @@ while getopts ":m:g:npi" opt; do
 98 		p)
 99 			prev_ws;;
100 		g)
101-			move_to_ws "$OPTARG";;
102+			move_to_ws "${OPTARG}";;
103 		m)
104-			move_focused_window "$OPTARG";;
105+			move_focused_window "${OPTARG}";;
106 		i)
107 			ws_init;;
108 		\?)