diff --git a/safeeyes/SafeEyesCore.py b/safeeyes/SafeEyesCore.py index 0e2a189..6edf832 100644 --- a/safeeyes/SafeEyesCore.py +++ b/safeeyes/SafeEyesCore.py @@ -65,7 +65,8 @@ class SafeEyesCore: self.skip_break_window_classes = [x.lower() for x in config['active_window_class']['skip_break']] self.take_break_window_classes = [x.lower() for x in config['active_window_class']['take_break']] self.custom_exercises = config['custom_exercises'] - self.time_to_screen_lock = config.get('time_to_screen_lock', -1) + self.time_to_screen_lock = config.get('time_to_screen_lock', -1) + self.enable_screen_lock = config.get('enable_screen_lock', False) exercises = language['exercises'] for short_break_config in config['short_breaks']: @@ -292,6 +293,10 @@ class SafeEyesCore: audible_alert = self.short_break_exercises[self.short_break_message_index][2] image = self.short_break_exercises[self.short_break_message_index][3] + + if (Utility.is_desktop_lock_supported() and self.enable_screen_lock and self.time_to_screen_lock < seconds): + Utility.lock_desktop() + # Show the break screen self.start_break(message, image) diff --git a/safeeyes/SettingsDialog.py b/safeeyes/SettingsDialog.py index 7b1fd1f..2cd26b2 100644 --- a/safeeyes/SettingsDialog.py +++ b/safeeyes/SettingsDialog.py @@ -73,7 +73,7 @@ class SettingsDialog: self.switch_strict_break.set_active(config['strict_break']) self.switch_audible_alert.set_active(config['audible_alert']) self.switch_screen_lock.set_sensitive(Utility.is_desktop_lock_supported()) - self.switch_screen_lock.set_active(Utility.is_desktop_lock_supported() and self.config.get('enable_screen_lock', True)) + self.switch_screen_lock.set_active(Utility.is_desktop_lock_supported() and self.config.get('enable_screen_lock', False)) self.spin_time_to_screen_lock.set_value(self.config.get('time_to_screen_lock', 20)) self.on_switch_screen_lock_activate(self.switch_screen_lock, self.switch_screen_lock.get_active()) diff --git a/safeeyes/Utility.py b/safeeyes/Utility.py index 4ad658c..6b88766 100644 --- a/safeeyes/Utility.py +++ b/safeeyes/Utility.py @@ -256,3 +256,5 @@ def desktop_envinroment(): def is_desktop_lock_supported(): return desktop_envinroment() in ['unity', 'gnome'] +def lock_desktop(): + os.system("gnome-screensaver-command --lock")