aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Miller <nwg.piotr@gmail.com>2020-02-19 00:56:00 +0100
committerGitHub <noreply@github.com>2020-02-19 00:56:00 +0100
commite4a4e47b1822c78e8ad820198489106ce18f9259 (patch)
tree292b45ac1e1ed58b112436b085ca4fa1dc07d596
parenta4b07d72721ce641219aea412148a8faf20dc84b (diff)
parent93d86f4c289ac5f6fbd4d2ddecbd8615bb456daa (diff)
downloadautotiling-e4a4e47b1822c78e8ad820198489106ce18f9259.tar.gz
Merge pull request #2 from ammgws/patch-1
Check if con exists before querying submembers
-rwxr-xr-xautotiling.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/autotiling.py b/autotiling.py
index cca9c79..9cd6aa5 100755
--- a/autotiling.py
+++ b/autotiling.py
@@ -24,21 +24,22 @@ i3 = Connection()
def switch_splitting(i3, e):
try:
con = i3.get_tree().find_focused()
- if con.floating: # We're on i3: on sway it would be None
- is_floating = '_on' in con.floating # May be 'auto_on' or 'user_on'
- is_full_screen = con.fullscreen_mode == 1
- else: # We are on sway
- is_floating = con.type == 'floating_con'
- # On sway on 1st focus the parent container returns 1, then forever the focused container itself
- is_full_screen = con.fullscreen_mode == 1 or con.parent.fullscreen_mode == 1
-
- is_stacked = con.parent.layout == 'stacked'
- is_tabbed = con.parent.layout == 'tabbed'
-
- # 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:
- new_layout = 'splitv' if con.rect.height > con.rect.width else 'splith'
- i3.command(new_layout)
+ if con:
+ if con.floating: # We're on i3: on sway it would be None
+ is_floating = '_on' in con.floating # May be 'auto_on' or 'user_on'
+ is_full_screen = con.fullscreen_mode == 1
+ else: # We are on sway
+ is_floating = con.type == 'floating_con'
+ # On sway on 1st focus the parent container returns 1, then forever the focused container itself
+ is_full_screen = con.fullscreen_mode == 1 or con.parent.fullscreen_mode == 1
+
+ is_stacked = con.parent.layout == 'stacked'
+ is_tabbed = con.parent.layout == 'tabbed'
+
+ # 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:
+ new_layout = 'splitv' if con.rect.height > con.rect.width else 'splith'
+ i3.command(new_layout)
except Exception as e:
print('Error: {}'.format(e))