From 4fc70aa2c10d8542425be924e9e99cdd6063050b Mon Sep 17 00:00:00 2001 From: Markus Schmidt Date: Wed, 26 Oct 2022 16:22:30 +0200 Subject: [PATCH] detect if no window is active and set the current focussed window to [Desktop] --- libinput-gestures | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libinput-gestures b/libinput-gestures index 444cdbc..9914ec5 100755 --- a/libinput-gestures +++ b/libinput-gestures @@ -113,8 +113,13 @@ def get_active_window_title(): m = re.search(b'^_NET_ACTIVE_WINDOW.* ([\w]+)$', stdout) if m != None: window_id = m.group(1) - window = subprocess.Popen(['xprop', '-id', window_id, 'WM_NAME'], stdout=subprocess.PIPE) - stdout, stderr = window.communicate() + if window_id != '0x0': + if args.verbose: + print(f'window id: {window_id} from: {stdout}'); + window = subprocess.Popen(['xprop', '-id', window_id, 'WM_NAME'], stdout=subprocess.PIPE) + stdout, stderr = window.communicate() + else: + window = 'Desktop' else: return None @@ -459,7 +464,7 @@ class GESTURE: appname = appname_cache[appl]; if args.debug: - print('current active window ',appname) + print(f'current active window [{appname}]') 'Action a motion command for this gesture' command = self.motions.get((appname, motion, self.fingers)) or \