Skip to content

Commit

Permalink
bump to 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
nwg-piotr committed Feb 9, 2024
1 parent 82f0264 commit c63140c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ but not on even ones:
Another option you can try, is setting `--limit` and only use stacking or
tabbing on the lowest level. A good place to start would be `--limit 2`. Open
four windows with the third and fourth window in the same container as two. This
might mimic a master-stack layout and you should now be able to switch to
might mimic a master-stack layout, and you should now be able to switch to
stacking or tabbed. Beware that the decision on how to split is still based on
the height / width ratio.

Expand All @@ -55,29 +55,42 @@ Installing manually:

```text
$ autotiling -h
usage: autotiling [-h] [-d] [-v] [-w [WORKSPACES ...]] [-e [EVENTS ...]]
usage: main.py [-h] [-d] [-v] [-o [OUTPUTS ...]] [-w [WORKSPACES ...]]
[-l LIMIT] [-sw SPLITWIDTH] [-sh SPLITHEIGHT] [-sr SPLITRATIO]
[-e [EVENTS ...]]
optional arguments:
options:
-h, --help show this help message and exit
-d, --debug print debug messages to stderr
-v, --version display version information
-o [OUTPUTS ...], --outputs [OUTPUTS ...]
restricts autotiling to certain output; example: autotiling --output DP-1
HDMI-0
restricts autotiling to certain output; example:
autotiling --output DP-1 HDMI-0
-w [WORKSPACES ...], --workspaces [WORKSPACES ...]
restricts autotiling to certain workspaces; example: autotiling --workspaces 8
9
restricts autotiling to certain workspaces; example:
autotiling --workspaces 8 9
-l LIMIT, --limit LIMIT
limit how often autotiling will split a container; try "2", if you like
master-stack layouts; default: 0 (no limit)
limit how often autotiling will split a container; try
"2" if you like master-stack layouts; default: 0 (no
limit)
-sw SPLITWIDTH, --splitwidth SPLITWIDTH
set the width of the vertical split (as factor);
default: 1.0;
-sh SPLITHEIGHT, --splitheight SPLITHEIGHT
set the height of the horizontal split (as factor);
default: 1.0;
-sr SPLITRATIO, --splitratio SPLITRATIO
Split direction ratio - based on window height/width;
default: 1;try "1.61", for golden ratio - window has
to be 61% wider for left/right split; default: 1.0;
-e [EVENTS ...], --events [EVENTS ...]
list of events to trigger switching split orientation; default: WINDOW MODE
list of events to trigger switching split orientation;
default: WINDOW MODE
```

### Events

Changing event subscription has already been the objective of several pull request. To avoid doing this again and again,
starting from v1.6 you may specify them in the `-e` | `--events` argument. If no value given, the script will subscribe
to `Event.WINDOW` and `Event.MODE`, as if it was executed with `autotiling -e WINDOW MODE`. See
[altdesktop/i3ipc-python`](https://github.com/altdesktop/i3ipc-python/blob/a670f24e7e04f509de8161cf760afe929c22ae93/i3ipc/events.py#L12)
for event enumeration.
[altdesktop/i3ipc-python`](https://github.com/altdesktop/i3ipc-python/blob/a670f24e7e04f509de8161cf760afe929c22ae93/i3ipc/events.py#L12) for event enumeration.
17 changes: 9 additions & 8 deletions autotiling/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def switch_splitting(i3, e, debug, outputs, workspaces, depth_limit, splitwidth,
and not is_stacked
and not is_tabbed
and not is_full_screen):
new_layout = "splitv" if con.rect.height > con.rect.width/splitratio else "splith"
new_layout = "splitv" if con.rect.height > con.rect.width / splitratio else "splith"

if new_layout != con.parent.layout:
result = i3.command(new_layout)
Expand All @@ -112,13 +112,13 @@ def switch_splitting(i3, e, debug, outputs, workspaces, depth_limit, splitwidth,
elif debug:
print(f"Error: Switch failed with err {result[0].error}", file=sys.stderr)

if e.change in ["new","move"] and con.percent:
if con.parent.layout == "splitv" and splitheight != 1.0: # top / bottom
if e.change in ["new", "move"] and con.percent:
if con.parent.layout == "splitv" and splitheight != 1.0: # top / bottom
# print(f"split top fac {splitheight*100}")
i3.command(f"resize set height {int(con.percent*splitheight*100)} ppt")
elif con.parent.layout == "splith" and splitwidth != 1.0: # top / bottom: # left / right
i3.command(f"resize set height {int(con.percent * splitheight * 100)} ppt")
elif con.parent.layout == "splith" and splitwidth != 1.0: # top / bottom: # left / right
# print(f"split right fac {splitwidth*100} ")
i3.command(f"resize set width {int(con.percent*splitwidth*100)} ppt")
i3.command(f"resize set width {int(con.percent * splitwidth * 100)} ppt")

elif debug:
print("Debug: No focused container found or autotiling on the workspace turned off", file=sys.stderr)
Expand All @@ -140,7 +140,8 @@ def main():
parser.add_argument("-w", "--workspaces", nargs="*", type=str, default=[],
help="restricts autotiling to certain workspaces; example: autotiling --workspaces 8 9")
parser.add_argument("-l", "--limit", type=int, default=0,
help='limit how often autotiling will split a container; try "2" if you like master-stack layouts; default: 0 (no limit)')
help='limit how often autotiling will split a container; '
'try "2" if you like master-stack layouts; default: 0 (no limit)')
parser.add_argument("-sw",
"--splitwidth",
help='set the width of the vertical split (as factor); default: 1.0;',
Expand All @@ -154,7 +155,7 @@ def main():
parser.add_argument("-sr",
"--splitratio",
help='Split direction ratio - based on window height/width; default: 1;'
'try "1.61", for golden ratio - window has to be 61%% wider for left/right split; default: 1.0;',
'try "1.61", for golden ratio - window has to be 61%% wider for left/right split; default: 1.0;',
type=float,
default=1.0, )

Expand Down

0 comments on commit c63140c

Please sign in to comment.