Skip to content

Instantly share code, notes, and snippets.

@synaptiko
Created August 30, 2016 17:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save synaptiko/46a63f46abed674cc696545b619f0413 to your computer and use it in GitHub Desktop.
Save synaptiko/46a63f46abed674cc696545b619f0413 to your computer and use it in GitHub Desktop.
Example how to use i3msg command
#!/usr/bin/env bash
isWorkspaceFocused=$(i3-msg -t get_workspaces | jq 'map(select(.focused==true))|map(.num)|map(select(. == 10))|length' 2> /dev/null)
isKicktermRunning=$(i3-msg -t get_tree | jq "recurse(.nodes[]) | .window_properties | objects | .class" | grep '"Kickterm"' | wc -l 2> /dev/null)
if [ $isKicktermRunning -eq 0 ]; then
/home/jprokop/Projects/kickterm/new-i3.py >& /dev/null
fi
if [ $isWorkspaceFocused -eq 0 ]; then
if [ $isKicktermRunning -eq 0 ]; then
i3-msg "workspace 10" >& /dev/null
else
i3-msg "[class=\"Kickterm\"] focus" >& /dev/null
fi
else
if [ $isKicktermRunning -ne 0 ]; then
i3-msg "workspace 10" >& /dev/null
fi
fi
@synaptiko
Copy link
Author

Requires jq command as dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment