local/bin/i3-watch

   1 #!/bin/bash
   2 
   3 gaps=$(i3-msg -t get_config | awk '/^gaps\s+inner/ { print $3 }')
   4 gaps=${gaps:-0}
   5 
   6 i3-msg -t subscribe -m '[ "window", "binding" ]' | while read; do
   7     ws=$(i3-msg -t get_workspaces | jq '.[] | select(.focused == true).num')
   8     gp=$(i3-msg -t get_tree | jq ".nodes[].nodes[].nodes[] | select(.num == $ws).gaps.inner")
   9     gp=$(( $gaps + $gp ))
  10 
  11     i3-msg [tiling workspace=__focused__] border normal $(( $gp == 0 ? 1 : 0 ))
  12 done