From 2f455a6a5e363788041eb0d7b9f40d56b2b263d0 Mon Sep 17 00:00:00 2001 From: generaldenmark Date: Fri, 13 Nov 2020 15:50:12 +0100 Subject: [PATCH] Last release introduced a bug, where if you had a monitor in your config that was not active, it would error out the script and prevent screenchanges --- pi3/smart_workspace.py | 12 +++++++----- setup.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pi3/smart_workspace.py b/pi3/smart_workspace.py index 9dfdf30..a4ae318 100644 --- a/pi3/smart_workspace.py +++ b/pi3/smart_workspace.py @@ -31,7 +31,7 @@ class WorkSpacer: self.current_output_name = None def _connect(self): - self.print_if_debug('all available outputs on device') + self.print_if_debug('All available outputs on device') self.print_if_debug(names_for_outputs) try: self.i3 = Connection() @@ -55,6 +55,8 @@ class WorkSpacer: for matchNum, match in enumerate( re.finditer(r'workspace (\$.*) output (\$.*)', self.config, re.MULTILINE) ): + if not config_outputs.keys().__contains__(match.group(2)): + continue # Not an active display, skip it if not self.workspaces_on_outputs.keys().__contains__(config_outputs[match.group(2)]): self.workspaces_on_outputs[config_outputs[match.group(2)]] = [] self.workspaces_on_outputs[config_outputs[match.group(2)]].append( @@ -90,19 +92,19 @@ class WorkSpacer: y_offset = output.__dict__["rect"].__dict__["y"] if x_offset == 0 and y_offset == 0: - if x_offset <= self.mouse_position[0] <= x_offset + width and y_offset <=\ + if x_offset <= self.mouse_position[0] <= x_offset + width and y_offset <= \ self.mouse_position[1] <= y_offset + height: return output.__dict__["name"] elif x_offset == 0: - if x_offset <= self.mouse_position[0] <= x_offset + width and y_offset <\ + if x_offset <= self.mouse_position[0] <= x_offset + width and y_offset < \ self.mouse_position[1] <= y_offset + height: return output.__dict__["name"] elif y_offset == 0: - if x_offset < self.mouse_position[0] <= x_offset + width and y_offset <=\ + if x_offset < self.mouse_position[0] <= x_offset + width and y_offset <= \ self.mouse_position[1] <= y_offset + height: return output.__dict__["name"] else: - if x_offset < self.mouse_position[0] <= x_offset + width and y_offset <\ + if x_offset < self.mouse_position[0] <= x_offset + width and y_offset < \ self.mouse_position[1] <= y_offset + height: return output.__dict__["name"] diff --git a/setup.py b/setup.py index e8da543..ef8b0df 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ with open('README.rst', 'r') as fh: setup( name='pi3-smart-workspace', - version='0.1.7', + version='0.1.8', packages=['pi3'], url='https://github.com/GeneralDenmark/PyOutputHandler', license='Apache-2.0 License ',