Last active
March 5, 2020 22:06
-
-
Save ffwff/190d0758005812589c9e1770134425fd to your computer and use it in GitHub Desktop.
Changes layout of current i3 workspace
This file contains hidden or 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 | |
if [[ "$1" = "fourbox" ]]; then | |
(i3-save-tree |sed -e's/^\s*\/\/\s[^\"].*//g' -e's/^\s*\/\///g' | \ | |
jq '..|objects|select(.type=="con")|select(has("nodes")|not)'| \ | |
jq -s '{layout:"splith","type":"con",nodes:[{"layout":"splitv",nodes:[.[0],.[1]]},{"layout":"splitv",nodes:[.[2],.[3]]}]}') > /tmp/layout | |
else | |
(i3-save-tree |sed -e's/^\s*\/\/\s[^\"].*//g' -e's/^\s*\/\///g' | \ | |
jq '..|objects|select(.type=="con")|select(has("nodes")|not)'| \ | |
jq -s '{layout:"'$1'","type":"con",nodes:.}') > /tmp/layout | |
fi | |
windows="$(wmctrl -l|awk '{ if ($2 == "'$(wmctrl -d | awk '{ if ($2 == "'*'") print $1 }')'") print $1}')" | |
i3-msg append_layout /tmp/layout | |
for window in $windows; do | |
xdotool windowunmap $window | |
xdotool windowmap $window | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment