#! /bin/bash

current_ws() {
	echo $(i3-msg -t get_workspaces | jq '.[] | select(.focused) | .num')
}

other_ws() {
	echo $(i3-msg -t get_workspaces | jq '.[] | select((.focused | not) and .visible) | .num')
}

set_ws() {
	let WS=$1
	if [ "$(current_ws)" -gt 9 ]; then
		let WS=$WS+9
	fi
	if [ -z $2 ]; then
		i3-msg workspace $WS
	else
		i3-msg move container to workspace $WS
	fi
}

toggle_ws() {
	i3msg workspace $(other_ws)
}

$@