Lock screen is working

This commit is contained in:
ruX 2017-04-08 14:54:07 +01:00
parent bf3d6848c8
commit 6816cc60c4
3 changed files with 9 additions and 2 deletions

View File

@ -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)

View File

@ -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())

View File

@ -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")