* .config/isync/mbsyncrc: Increase gnu account timeout to 240.
[~bandali/configs] / .local / bin / b-ws-util
CommitLineData
bfe53d9b
AB
1#!/bin/sh
2
3if [ "$1" = "i3" ]; then
4 msgcmd=i3-msg
5elif [ "$1" = "sway" ]; then
6 msgcmd=swaymsg
7else
8 echo "Usage: $0 {i3|sway} {switch|move} {prev|next} [follow]"
9 exit 1
10fi
11
12curr_ws=$("$msgcmd" -t get_workspaces | jq -r '.[] | select(.focused==true).name')
13[ "$curr_ws" -eq 1 ] && prev_ws=10 || prev_ws=$((curr_ws-1))
14[ "$curr_ws" -eq 10 ] && next_ws=1 || next_ws=$((curr_ws+1))
15dest_ws=-1
16op=-1
17
18if [ "$2" = "switch" ] || [ "$2" = "move" ]; then
19 op="$2"
20 if [ "$3" = "prev" ]; then
21 dest_ws="$prev_ws"
22 elif [ "$3" = "next" ]; then
23 dest_ws="$next_ws"
24 else
25 echo "Usage: $0 $1 $2 {prev|next} [follow]"
26 exit 1
27 fi
28else
29 echo "Usage: $0 $1 {switch|move} {prev|next} [follow]"
30 exit 1
31fi
32
33if [ "$op" = "switch" ]; then
34 i3 workspace "$dest_ws"
35elif [ "$op" = "move" ]; then
36 i3 move container to workspace "$dest_ws"
37 if [ "$4" = "follow" ]; then
38 i3 workspace "$dest_ws"
39 fi
40fi