Check current desktop environment type

This commit is contained in:
ruX 2017-04-08 14:30:44 +01:00
parent 76c26048e6
commit bf3d6848c8
2 changed files with 18 additions and 1 deletions

View File

@ -72,7 +72,8 @@ class SettingsDialog:
self.spin_postpone_duration.set_value(config['postpone_duration'])
self.switch_strict_break.set_active(config['strict_break'])
self.switch_audible_alert.set_active(config['audible_alert'])
self.switch_screen_lock.set_active(self.config.get('enable_screen_lock', True))
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.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

@ -240,3 +240,19 @@ def read_lang_files():
languages[lang_file_name.lower().replace('.json', '')] = lang['meta_info']['language_name']
return languages
def desktop_envinroment():
"""
Function tries to detect current envinroment
Possible results: unity, gnome or None if nothing detected
"""
if 'unity' == os.environ.get('XDG_CURRENT_DESKTOP', '').lower():
return 'unity'
elif 'gnome' == os.environ.get('DESKTOP_SESSION', '').lower():
return 'gnome'
return None
def is_desktop_lock_supported():
return desktop_envinroment() in ['unity', 'gnome']