2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
9 # Copyright 2024 Ian Kelling
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
15 # http://www.apache.org/licenses/LICENSE-2.0
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
24 set -e; .
/usr
/local
/lib
/bash-bear
; set +e
26 # We use this along with
27 # /a/opt/i3-alternating-layout/alternating_layouts.py to anticipate when
28 # we want to split/tab windows. There are 2 options of when to do it:
29 # just after a window is created, or just before a window is
30 # created. Doing it after a window is created allows you to move a
31 # window into the split that only has 1 window, whereas the other way
32 # doesn't. For my use cases, I think I don't really want to move it into
33 # the split if it is a tabbed split.
35 # I have a keybind which disables both, it runs /b/ds/i3-auto-layout-toggle
37 if [[ -e /tmp
/iank-i3-no-auto
]]; then
44 i3-msg
-t get_workspaces | jq
".[]| select(.focused==true) | .rect | .width" >$tmp
46 { read -r screen_width
; read -r screen_height
; } <$tmp
48 i3-msg
-t get_tree | jq
-r ".. | select(.focused? == true).rect | .width, .height" >$tmp
50 half_w
=$
(( screen_width
/ 2 + 100 ))
51 half_h
=$
(( screen_height
/ 2 + 100 ))
54 { read -r w
; read -r h
; } <$tmp
57 if (( screen_width
< 1920 )); then
58 # haven't considered this case yet
62 if (( w
< half_w
&& h
< half_h
)); then
63 i3-msg
"split vertical, layout tabbed"