aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiotr <nwg.piotr@gmail.com>2021-01-08 16:56:47 +0100
committerpiotr <nwg.piotr@gmail.com>2021-01-08 16:56:47 +0100
commit435c5d828f44f1185cf2f61b79c2fba63e3b9b6b (patch)
treec8e175aed70b86e4fe014ebe2a4f0b76f4abafc2
parentdb73fed0aeecb24874387db9ebc9d95c87edd0ca (diff)
downloadautotiling-435c5d828f44f1185cf2f61b79c2fba63e3b9b6b.tar.gz
formatting, some argument cleanup
-rw-r--r--autotiling/main.py61
1 files changed, 25 insertions, 36 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()