move scripts from ~/.local/bin to rc.org
[~bandali/configs] / .local / bin / sway-ws-util
CommitLineData
a92a01fe
AB
1#!/bin/sh
2
3curr_ws=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused==true).name')
4[ "$curr_ws" -eq 1 ] && prev_ws=10 || prev_ws=$((curr_ws-1))
5[ "$curr_ws" -eq 10 ] && next_ws=1 || next_ws=$((curr_ws+1))
6dest_ws=-1
7op=-1
8
9if [ "$1" = "switch" ] || [ "$1" = "move" ]; then
10 op="$1"
11 if [ "$2" = "prev" ]; then
12 dest_ws="$prev_ws"
13 elif [ "$2" = "next" ]; then
14 dest_ws="$next_ws"
15 else
16 echo "Usage: $0 $1 {prev|next} [follow]"
17 exit 1
18 fi
19else
20 echo "Usage: $0 {switch|move} {prev|next} [follow]"
21 exit 1
22fi
23
24if [ "$op" = "switch" ]; then
25 sway workspace "$dest_ws"
26elif [ "$op" = "move" ]; then
27 sway move container to workspace "$dest_ws"
28 if [ "$3" = "follow" ]; then
29 sway workspace "$dest_ws"
30 fi
31fi