Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit e8a58eb

Browse files
committed
Put check_unity() inside a try-except. Fixed #107.
screen.get_active_window() return None if the i3 window manager is used.
1 parent 98bc002 commit e8a58eb

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

ibus_engine/ibus_engine.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@ def string_to_text(string):
6262

6363

6464
def check_unity():
65-
screen = Wnck.Screen.get_default()
66-
screen.force_update()
67-
window = screen.get_active_window()
68-
window_name = window.get_name()
69-
window_type = window.get_window_type()
70-
logging.info("Current active window: %s" % window_name)
71-
if window_type == Wnck.WindowType.DOCK and (window_name == 'launcher'
72-
or window_name == 'unity-dash'):
73-
return True
74-
else:
65+
try:
66+
screen = Wnck.Screen.get_default()
67+
screen.force_update()
68+
window = screen.get_active_window()
69+
window_name = window.get_name()
70+
window_type = window.get_window_type()
71+
logging.info("Current active window: %s" % window_name)
72+
if window_type == Wnck.WindowType.DOCK and (window_name == 'launcher'
73+
or window_name == 'unity-dash'):
74+
return True
75+
else:
76+
return False
77+
except:
7578
return False
7679

7780

0 commit comments

Comments
 (0)