-
Notifications
You must be signed in to change notification settings - Fork 0
/
i3_workspace_swap.sh
executable file
·49 lines (41 loc) · 1.06 KB
/
i3_workspace_swap.sh
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
#!/bin/sh
# path: /home/klassiker/.local/share/repos/i3/i3_workspace_swap.sh
# author: klassiker [mrdotx]
# github: https://github.com/mrdotx/i3
# date: 2022-04-24T08:06:21+0200
# speed up script by using standard c
LC_ALL=C
LANG=C
script=$(basename "$0")
help="$script [-h/--help] -- swap workspaces and focus
Usage:
$script [left/right/up/down]
Settings:
[left/right/up/down] = direction to focus after the workspaces swaped
Examples:
$script left
$script right
$script up
$script down"
swap_workspaces() {
current_workspaces=$( \
i3-msg -t get_outputs \
| grep -oE '"current_workspace":"[0-9]{1,2}"' \
| cut -d "\"" -f4
)
for line in $current_workspaces; do
[ -n "$line" ] \
&& i3-msg -q "workspace --no-auto-back-and-forth $line" \
&& i3-msg -q "move workspace to output $1"
done
i3-msg -q "focus $1"
}
case "$1" in
left | right | up | down)
swap_workspaces "$1"
;;
*)
printf "%s\n" "$help"
exit 1
;;
esac