Last active
February 8, 2018 16:26
-
-
Save tasinet/f29ea941769692bd4cb133efcdce9447 to your computer and use it in GitHub Desktop.
switch i3 workspace only if current workspace is empty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
new_workspace=$1 | |
if [ "" == "$new_workspace" ]; then | |
echo expecting workspace name/number | |
exit 1 | |
fi | |
active_workspace=$( i3-msg -t get_workspaces | jq '.[] | select(.focused).num' ) | |
echo active $active_workspace | |
toplevel_containers=$( i3-msg -t get_tree | jq '(.nodes[].nodes[].nodes[] | select(.type=="workspace") | select(.num=='"$active_workspace"') | .nodes | length) // 0' ) | |
echo windows $toplevel_containers | |
if [ "$toplevel_containers" -eq "0" ]; then | |
i3-msg workspace $new_workspace | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment