diff options
author | Piotr Miller <nwg.piotr@gmail.com> | 2021-01-08 17:01:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 17:01:54 +0100 |
commit | 368b7092f52826f7184653108dce7c6af0c2ea1c (patch) | |
tree | d5572772f37a31a660ca0e9d975ae910b663a9f5 | |
parent | db73fed0aeecb24874387db9ebc9d95c87edd0ca (diff) | |
parent | 1e4e52a8cd7d700927339b2797b9bfc1dca8241b (diff) | |
download | autotiling-368b7092f52826f7184653108dce7c6af0c2ea1c.tar.gz |
Merge pull request #23 from nwg-piotr/polish
minor polishment
-rw-r--r-- | autotiling/main.py | 61 | ||||
-rw-r--r-- | setup.cfg | 2 |
2 files changed, 26 insertions, 37 deletions
diff --git a/autotiling/main.py b/autotiling/main.py index 5c20215..5a8547e 100644 --- a/autotiling/main.py +++ b/autotiling/main.py @@ -5,7 +5,7 @@ It works on both sway and i3 window managers. Inspired by https://github.com/olemartinorg/i3-alternating-layout -Copyright: 2019-2020 Piotr Miller & Contributors +Copyright: 2019-2021 Piotr Miller & Contributors e-mail: nwg.piotr@gmail.com Project: https://github.com/nwg-piotr/autotiling License: GPL3 @@ -18,14 +18,12 @@ from functools import partial from i3ipc import Connection, Event - try: from .__about__ import __version__ except ImportError: __version__ = "unknown" - def switch_splitting(i3, e, debug, workspaces): try: con = i3.get_tree().find_focused() @@ -45,27 +43,21 @@ def switch_splitting(i3, e, debug, workspaces): # Let's exclude floating containers, stacked layouts, tabbed layouts and # full screen mode - if ( - not is_floating - and not is_stacked - and not is_tabbed - and not is_full_screen - ): + if (not is_floating + and not is_stacked + and not is_tabbed + and not is_full_screen): new_layout = "splitv" if con.rect.height > con.rect.width else "splith" + if new_layout != con.parent.layout: result = i3.command(new_layout) if result[0].success and debug: - print( - "Debug: Switched to {}".format(new_layout), file=sys.stderr - ) + print("Debug: Switched to {}".format(new_layout), file=sys.stderr) elif debug: - print( - "Error: Switch failed with err {}".format(result[0].error), - file=sys.stderr, - ) + print("Error: Switch failed with err {}".format(result[0].error), file=sys.stderr, ) elif debug: - print("Debug: No focused container found or autotiling on workspace turned off", file=sys.stderr) + print("Debug: No focused container found or autotiling on the workspace turned off", file=sys.stderr) except Exception as e: print("Error: {}".format(e), file=sys.stderr) @@ -73,29 +65,26 @@ def switch_splitting(i3, e, debug, workspaces): def main(): parser = argparse.ArgumentParser() - parser.add_argument( - "--debug", action="store_true", help="Print debug messages to stderr" - ) - parser.add_argument( - "--version", - "-v", - action="version", - version="%(prog)s {}, Python {}".format(__version__, sys.version), - help="display version information", - ) - parser.add_argument( - "--workspaces", - "-w", - help="Restricts autotiling to certain workspaces. Example: autotiling --workspaces 8 9", - nargs="*", - type=str, - default=[], - ) + parser.add_argument("-d", + "--debug", + action="store_true", + help="Print debug messages to stderr") + parser.add_argument("-v", + "--version", + action="version", + version="%(prog)s {}, Python {}".format(__version__, sys.version), + help="display version information", ) + parser.add_argument("-w", + "--workspaces", + help="Restricts autotiling to certain workspaces. Example: autotiling --workspaces 8 9", + nargs="*", + type=str, + default=[],) args = parser.parse_args() if args.debug and args.workspaces: - print("autotiling is only active on workspaces:", ','.join(args.workspaces)) + print("autotiling is only active on workspaces:", ','.join(args.workspaces)) handler = partial(switch_splitting, debug=args.debug, workspaces=args.workspaces) i3 = Connection() @@ -1,6 +1,6 @@ [metadata] name = autotiling -version = 1.2 +version = 1.3 author = Piotr Miller author_email = nwg.piotr@gmail.com description = Automatically switch the horizontal/vertical window split orientation in i3 and sway |