3 set -e; .
/usr
/local
/lib
/bash-bear
; set +e
5 # We use this along with
6 # /a/opt/i3-alternating-layout/alternating_layouts.py to anticipate when
7 # we want to split/tab windows. There are 2 options of when to do it:
8 # just after a window is created, or just before a window is
9 # created. Doing it after a window is created allows you to move a
10 # window into the split that only has 1 window, whereas the other way
11 # doesn't. For my use cases, I think I don't really want to move it into
12 # the split if it is a tabbed split.
14 # I have a keybind which disables both, it runs /b/ds/i3-auto-layout-toggle
16 if [[ -e /tmp
/iank-i3-no-auto
]]; then
23 i3-msg
-t get_workspaces | jq
".[]| select(.focused==true) | .rect | .width" >$tmp
25 { read -r screen_width
; read -r screen_height
; } <$tmp
27 i3-msg
-t get_tree | jq
-r ".. | select(.focused? == true).rect | .width, .height" >$tmp
29 half_w
=$
(( screen_width
/ 2 + 100 ))
30 half_h
=$
(( screen_height
/ 2 + 100 ))
33 { read -r w
; read -r h
; } <$tmp
36 if (( screen_width
< 1920 )); then
37 # haven't considered this case yet
41 if (( w
< half_w
&& h
< half_h
)); then
42 i3-msg
"split vertical, layout tabbed"