Improve the screen lock command
This commit is contained in:
parent
8761d6cbbf
commit
0ee6f2f2bb
|
@ -1,4 +1,4 @@
|
||||||
safeeyes (1.2.0a8-1) xenial; urgency=low
|
safeeyes (1.2.0a9-1) xenial; urgency=low
|
||||||
|
|
||||||
* Move to Python 3
|
* Move to Python 3
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class SettingsDialog:
|
||||||
"""
|
"""
|
||||||
Create and initialize SettingsDialog instance.
|
Create and initialize SettingsDialog instance.
|
||||||
"""
|
"""
|
||||||
def __init__(self, config, language, languages, on_save_settings, glade_file):
|
def __init__(self, config, language, languages, able_to_lock_screen, on_save_settings, glade_file):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.on_save_settings = on_save_settings
|
self.on_save_settings = on_save_settings
|
||||||
self.languages = []
|
self.languages = []
|
||||||
|
@ -79,11 +79,6 @@ class SettingsDialog:
|
||||||
|
|
||||||
# Enable idle_time_to_pause only if xprintidle is available
|
# Enable idle_time_to_pause only if xprintidle is available
|
||||||
self.spin_idle_time_to_pause.set_sensitive(Utility.command_exist('xprintidle'))
|
self.spin_idle_time_to_pause.set_sensitive(Utility.command_exist('xprintidle'))
|
||||||
|
|
||||||
# Check lock screen command
|
|
||||||
able_to_lock_screen = False
|
|
||||||
if config['lock_screen_command'] or Utility.lock_screen_command():
|
|
||||||
able_to_lock_screen = True
|
|
||||||
|
|
||||||
self.switch_screen_lock.set_sensitive(able_to_lock_screen)
|
self.switch_screen_lock.set_sensitive(able_to_lock_screen)
|
||||||
self.switch_screen_lock.set_active(able_to_lock_screen and config['enable_screen_lock'])
|
self.switch_screen_lock.set_active(able_to_lock_screen and config['enable_screen_lock'])
|
||||||
|
|
|
@ -256,39 +256,37 @@ def lock_screen_command():
|
||||||
Otherwise: None
|
Otherwise: None
|
||||||
"""
|
"""
|
||||||
desktop_session = os.environ.get('DESKTOP_SESSION')
|
desktop_session = os.environ.get('DESKTOP_SESSION')
|
||||||
|
current_desktop = os.environ.get('XDG_CURRENT_DESKTOP')
|
||||||
if desktop_session is not None:
|
if desktop_session is not None:
|
||||||
desktop_session = desktop_session.lower()
|
desktop_session = desktop_session.lower()
|
||||||
if desktop_session in ['gnome','unity', 'budgie-desktop'] or desktop_session.startswith('ubuntu'):
|
if ('xfce' in desktop_session or desktop_session.startswith('xubuntu') or (current_desktop is not None and 'xfce' in current_desktop)) and command_exist('xflock4'):
|
||||||
|
return ['xflock4']
|
||||||
|
elif desktop_session == 'cinnamon' and command_exist('cinnamon-screensaver-command'):
|
||||||
|
return ['cinnamon-screensaver-command', '--lock']
|
||||||
|
elif (desktop_session == 'pantheon' or desktop_session.startswith('lubuntu')) and command_exist('light-locker-command'):
|
||||||
|
return ['light-locker-command', '--lock']
|
||||||
|
elif desktop_session == 'mate' and command_exist('mate-screensaver-command'):
|
||||||
|
return ['mate-screensaver-command', '--lock']
|
||||||
|
elif desktop_session == 'kde' or 'plasma' in desktop_session or desktop_session.startswith('kubuntu') or os.environ.get('KDE_FULL_SESSION') == 'true':
|
||||||
|
return ['qdbus', 'org.freedesktop.ScreenSaver', '/ScreenSaver', 'Lock']
|
||||||
|
elif desktop_session in ['gnome','unity', 'budgie-desktop'] or desktop_session.startswith('ubuntu'):
|
||||||
if command_exist('gnome-screensaver-command'):
|
if command_exist('gnome-screensaver-command'):
|
||||||
return ['gnome-screensaver-command', '--lock']
|
return ['gnome-screensaver-command', '--lock']
|
||||||
else:
|
else:
|
||||||
# From Gnome 3.8 no gnome-screensaver-command
|
# From Gnome 3.8 no gnome-screensaver-command
|
||||||
return ['dbus-send', '--type=method_call', '--dest=org.gnome.ScreenSaver', '/org/gnome/ScreenSaver', 'org.gnome.ScreenSaver.Lock']
|
return ['dbus-send', '--type=method_call', '--dest=org.gnome.ScreenSaver', '/org/gnome/ScreenSaver', 'org.gnome.ScreenSaver.Lock']
|
||||||
elif desktop_session == 'cinnamon':
|
|
||||||
return ['cinnamon-screensaver-command', '--lock']
|
|
||||||
elif desktop_session == 'pantheon' or desktop_session.startswith('lubuntu'):
|
|
||||||
return ['light-locker-command', '--lock']
|
|
||||||
elif desktop_session == 'mate':
|
|
||||||
return ['mate-screensaver-command', '--lock']
|
|
||||||
elif desktop_session == 'kde' or 'plasma' in desktop_session or desktop_session.startswith('kubuntu') or os.environ.get('KDE_FULL_SESSION') == 'true':
|
|
||||||
return ['qdbus', 'org.freedesktop.ScreenSaver', '/ScreenSaver', 'Lock']
|
|
||||||
elif 'xfce' in desktop_session or desktop_session.startswith('xubuntu'):
|
|
||||||
return ['xflock4']
|
|
||||||
elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
|
elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
|
||||||
if not 'deprecated' in os.environ.get('GNOME_DESKTOP_SESSION_ID'):
|
if not 'deprecated' in os.environ.get('GNOME_DESKTOP_SESSION_ID') and command_exist('gnome-screensaver-command'):
|
||||||
|
# Gnome 2
|
||||||
return ['gnome-screensaver-command', '--lock']
|
return ['gnome-screensaver-command', '--lock']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def lock_desktop(user_defined_command):
|
def lock_desktop(command):
|
||||||
"""
|
"""
|
||||||
Lock the screen using the predefined commands
|
Lock the screen using the predefined commands
|
||||||
"""
|
"""
|
||||||
if user_defined_command:
|
if command:
|
||||||
command = user_defined_command
|
|
||||||
else:
|
|
||||||
command = lock_screen_command()
|
|
||||||
if command is not None:
|
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(command)
|
subprocess.Popen(command)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -328,4 +326,4 @@ class __HTMLTextExtractor(HTMLParser):
|
||||||
self.fed.append(d)
|
self.fed.append(d)
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
return ''.join(self.fed)
|
return ''.join(self.fed)
|
||||||
|
|
|
@ -44,14 +44,17 @@ system_style_sheet_path = os.path.join(Utility.bin_directory, "config/style/safe
|
||||||
|
|
||||||
is_active = True
|
is_active = True
|
||||||
CONFIGURATION_VERSION = 4
|
CONFIGURATION_VERSION = 4
|
||||||
SAFE_EYES_VERSION = "1.2.0a8"
|
SAFE_EYES_VERSION = "1.2.0a9"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Listen to tray icon Settings action and send the signal to Settings dialog.
|
Listen to tray icon Settings action and send the signal to Settings dialog.
|
||||||
"""
|
"""
|
||||||
def show_settings():
|
def show_settings():
|
||||||
logging.info("Show Settings dialog")
|
logging.info("Show Settings dialog")
|
||||||
settings_dialog = SettingsDialog(config, language, Utility.read_lang_files(), save_settings, settings_dialog_glade)
|
able_to_lock_screen = False
|
||||||
|
if system_lock_command:
|
||||||
|
able_to_lock_screen = True
|
||||||
|
settings_dialog = SettingsDialog(config, language, Utility.read_lang_files(), able_to_lock_screen, save_settings, settings_dialog_glade)
|
||||||
settings_dialog.show()
|
settings_dialog.show()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -89,7 +92,7 @@ def close_alert(audible_alert_on):
|
||||||
logging.info("Close the break screen")
|
logging.info("Close the break screen")
|
||||||
if config['enable_screen_lock'] and context['break_type'] == 'long':
|
if config['enable_screen_lock'] and context['break_type'] == 'long':
|
||||||
# Lock the screen before closing the break screen
|
# Lock the screen before closing the break screen
|
||||||
Utility.lock_desktop(config['lock_screen_command'])
|
Utility.lock_desktop(system_lock_command)
|
||||||
break_screen.close()
|
break_screen.close()
|
||||||
if audible_alert_on:
|
if audible_alert_on:
|
||||||
Utility.play_notification()
|
Utility.play_notification()
|
||||||
|
@ -137,7 +140,7 @@ def on_skipped():
|
||||||
logging.info("User skipped the break")
|
logging.info("User skipped the break")
|
||||||
if config['enable_screen_lock'] and context['break_type'] == 'long' and context.get('count_down', 0) >= config['time_to_screen_lock']:
|
if config['enable_screen_lock'] and context['break_type'] == 'long' and context.get('count_down', 0) >= config['time_to_screen_lock']:
|
||||||
# Lock the screen before closing the break screen
|
# Lock the screen before closing the break screen
|
||||||
Utility.lock_desktop(config['lock_screen_command'])
|
Utility.lock_desktop(system_lock_command)
|
||||||
core.skip_break()
|
core.skip_break()
|
||||||
plugins.post_break(context)
|
plugins.post_break(context)
|
||||||
|
|
||||||
|
@ -148,7 +151,7 @@ def on_postponed():
|
||||||
logging.info("User postponed the break")
|
logging.info("User postponed the break")
|
||||||
if config['enable_screen_lock'] and context['break_type'] == 'long' and context.get('count_down', 0) >= config['time_to_screen_lock']:
|
if config['enable_screen_lock'] and context['break_type'] == 'long' and context.get('count_down', 0) >= config['time_to_screen_lock']:
|
||||||
# Lock the screen before closing the break screen
|
# Lock the screen before closing the break screen
|
||||||
Utility.lock_desktop(config['lock_screen_command'])
|
Utility.lock_desktop(system_lock_command)
|
||||||
core.postpone_break()
|
core.postpone_break()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -304,9 +307,16 @@ def main():
|
||||||
global language
|
global language
|
||||||
global context
|
global context
|
||||||
global plugins
|
global plugins
|
||||||
|
global system_lock_command
|
||||||
|
|
||||||
context = {}
|
context = {}
|
||||||
language = Utility.load_language(config['language'])
|
language = Utility.load_language(config['language'])
|
||||||
|
# Get the lock command only one time
|
||||||
|
if config['lock_screen_command']:
|
||||||
|
system_lock_command = config['lock_screen_command']
|
||||||
|
else:
|
||||||
|
system_lock_command = Utility.lock_screen_command()
|
||||||
|
|
||||||
|
|
||||||
# Initialize the Safe Eyes Context
|
# Initialize the Safe Eyes Context
|
||||||
context['version'] = SAFE_EYES_VERSION
|
context['version'] = SAFE_EYES_VERSION
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -23,13 +23,13 @@ def _data_files(path):
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="safeeyes",
|
name="safeeyes",
|
||||||
version="1.2.0a8",
|
version="1.2.0a9",
|
||||||
description="Protect your eyes from eye strain using this continuous breaks reminder.",
|
description="Protect your eyes from eye strain using this continuous breaks reminder.",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
author="Gobinath Loganathan",
|
author="Gobinath Loganathan",
|
||||||
author_email="slgobinath@gmail.com",
|
author_email="slgobinath@gmail.com",
|
||||||
url="https://github.com/slgobinath/SafeEyes",
|
url="https://github.com/slgobinath/SafeEyes",
|
||||||
download_url="https://github.com/slgobinath/SafeEyes/archive/v1.2.0a8.tar.gz",
|
download_url="https://github.com/slgobinath/SafeEyes/archive/v1.2.0a9.tar.gz",
|
||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
package_data={'safeeyes': ['config/*.json',
|
package_data={'safeeyes': ['config/*.json',
|
||||||
'config/style/*.css',
|
'config/style/*.css',
|
||||||
|
|
Loading…
Reference in New Issue