How to use the safeeyes.Utility.command_exist function in safeeyes

To help you get started, we’ve selected a few safeeyes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slgobinath / SafeEyes / safeeyes / plugins / screensaver / plugin.py View on Github external
return ['xflock4']
        elif desktop_session == 'cinnamon' and Utility.command_exist('cinnamon-screensaver-command'):
            return ['cinnamon-screensaver-command', '--lock']
        elif (desktop_session == 'pantheon' or desktop_session.startswith('lubuntu')) and Utility.command_exist('light-locker-command'):
            return ['light-locker-command', '--lock']
        elif desktop_session == 'mate' and Utility.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 Utility.command_exist('gnome-screensaver-command'):
                return ['gnome-screensaver-command', '--lock']
            # 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']
        elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
            if 'deprecated' not in os.environ.get('GNOME_DESKTOP_SESSION_ID') and Utility.command_exist('gnome-screensaver-command'):
                # Gnome 2
                return ['gnome-screensaver-command', '--lock']
    return None
github slgobinath / SafeEyes / safeeyes / plugins / screensaver / plugin.py View on Github external
"""
    Function tries to detect the screensaver command based on the current envinroment
    Possible results:
        Gnome, Unity, Budgie:		['gnome-screensaver-command', '--lock']
        Cinnamon:					['cinnamon-screensaver-command', '--lock']
        Pantheon, LXDE:				['light-locker-command', '--lock']
        Mate:						['mate-screensaver-command', '--lock']
        KDE:						['qdbus', 'org.freedesktop.ScreenSaver', '/ScreenSaver', 'Lock']
        XFCE:						['xflock4']
        Otherwise:					None
    """
    desktop_session = os.environ.get('DESKTOP_SESSION')
    current_desktop = os.environ.get('XDG_CURRENT_DESKTOP')
    if desktop_session is not None:
        desktop_session = desktop_session.lower()
        if ('xfce' in desktop_session or desktop_session.startswith('xubuntu') or (current_desktop is not None and 'xfce' in current_desktop)) and Utility.command_exist('xflock4'):
            return ['xflock4']
        elif desktop_session == 'cinnamon' and Utility.command_exist('cinnamon-screensaver-command'):
            return ['cinnamon-screensaver-command', '--lock']
        elif (desktop_session == 'pantheon' or desktop_session.startswith('lubuntu')) and Utility.command_exist('light-locker-command'):
            return ['light-locker-command', '--lock']
        elif desktop_session == 'mate' and Utility.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 Utility.command_exist('gnome-screensaver-command'):
                return ['gnome-screensaver-command', '--lock']
            # 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']
        elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
            if 'deprecated' not in os.environ.get('GNOME_DESKTOP_SESSION_ID') and Utility.command_exist('gnome-screensaver-command'):
github slgobinath / SafeEyes / safeeyes / plugins / screensaver / plugin.py View on Github external
Cinnamon:					['cinnamon-screensaver-command', '--lock']
        Pantheon, LXDE:				['light-locker-command', '--lock']
        Mate:						['mate-screensaver-command', '--lock']
        KDE:						['qdbus', 'org.freedesktop.ScreenSaver', '/ScreenSaver', 'Lock']
        XFCE:						['xflock4']
        Otherwise:					None
    """
    desktop_session = os.environ.get('DESKTOP_SESSION')
    current_desktop = os.environ.get('XDG_CURRENT_DESKTOP')
    if desktop_session is not None:
        desktop_session = desktop_session.lower()
        if ('xfce' in desktop_session or desktop_session.startswith('xubuntu') or (current_desktop is not None and 'xfce' in current_desktop)) and Utility.command_exist('xflock4'):
            return ['xflock4']
        elif desktop_session == 'cinnamon' and Utility.command_exist('cinnamon-screensaver-command'):
            return ['cinnamon-screensaver-command', '--lock']
        elif (desktop_session == 'pantheon' or desktop_session.startswith('lubuntu')) and Utility.command_exist('light-locker-command'):
            return ['light-locker-command', '--lock']
        elif desktop_session == 'mate' and Utility.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 Utility.command_exist('gnome-screensaver-command'):
                return ['gnome-screensaver-command', '--lock']
            # 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']
        elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
            if 'deprecated' not in os.environ.get('GNOME_DESKTOP_SESSION_ID') and Utility.command_exist('gnome-screensaver-command'):
                # Gnome 2
                return ['gnome-screensaver-command', '--lock']
    return None
github slgobinath / SafeEyes / safeeyes / SettingsDialog.py View on Github external
# Set the current values of input fields
		self.spin_short_break_duration.set_value(config['short_break_duration'])
		self.spin_long_break_duration.set_value(config['long_break_duration'])
		self.spin_interval_between_two_breaks.set_value(config['break_interval'])
		self.spin_short_between_long.set_value(config['no_of_short_breaks_per_long_break'])
		self.spin_time_to_prepare.set_value(config['pre_break_warning_time'])
		self.spin_idle_time_to_pause.set_value(config['idle_time'])
		self.spin_postpone_duration.set_value(config['postpone_duration'])
		self.switch_show_time_in_tray.set_active(config['show_time_in_tray'])
		self.switch_strict_break.set_active(config['strict_break'])
		self.switch_audible_alert.set_active(config['audible_alert'])
		self.spin_time_to_screen_lock.set_value(config['time_to_screen_lock'])

		# Enable idle_time_to_pause only if xprintidle is available
		self.spin_idle_time_to_pause.set_sensitive(Utility.command_exist('xprintidle'))

		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_postpone.set_active(config['allow_postpone'] and not config['strict_break'])

		# Update relative states
		# GtkSwitch state-set signal is available only from 3.14
		if Gtk.get_minor_version() >= 14:
			self.switch_strict_break.connect('state-set', self.on_switch_strict_break_activate)
			self.switch_screen_lock.connect('state-set', self.on_switch_screen_lock_activate)
			self.switch_postpone.connect('state-set', self.on_switch_postpone_activate)
			self.on_switch_strict_break_activate(self.switch_strict_break, self.switch_strict_break.get_active())
			self.on_switch_screen_lock_activate(self.switch_screen_lock, self.switch_screen_lock.get_active())
			self.on_switch_postpone_activate(self.switch_postpone, self.switch_postpone.get_active())

		# Initialize the language combobox
github slgobinath / SafeEyes / safeeyes / plugins / screensaver / plugin.py View on Github external
desktop_session = os.environ.get('DESKTOP_SESSION')
    current_desktop = os.environ.get('XDG_CURRENT_DESKTOP')
    if desktop_session is not None:
        desktop_session = desktop_session.lower()
        if ('xfce' in desktop_session or desktop_session.startswith('xubuntu') or (current_desktop is not None and 'xfce' in current_desktop)) and Utility.command_exist('xflock4'):
            return ['xflock4']
        elif desktop_session == 'cinnamon' and Utility.command_exist('cinnamon-screensaver-command'):
            return ['cinnamon-screensaver-command', '--lock']
        elif (desktop_session == 'pantheon' or desktop_session.startswith('lubuntu')) and Utility.command_exist('light-locker-command'):
            return ['light-locker-command', '--lock']
        elif desktop_session == 'mate' and Utility.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 Utility.command_exist('gnome-screensaver-command'):
                return ['gnome-screensaver-command', '--lock']
            # 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']
        elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
            if 'deprecated' not in os.environ.get('GNOME_DESKTOP_SESSION_ID') and Utility.command_exist('gnome-screensaver-command'):
                # Gnome 2
                return ['gnome-screensaver-command', '--lock']
    return None
github slgobinath / SafeEyes / safeeyes / plugins / screensaver / plugin.py View on Github external
Possible results:
        Gnome, Unity, Budgie:		['gnome-screensaver-command', '--lock']
        Cinnamon:					['cinnamon-screensaver-command', '--lock']
        Pantheon, LXDE:				['light-locker-command', '--lock']
        Mate:						['mate-screensaver-command', '--lock']
        KDE:						['qdbus', 'org.freedesktop.ScreenSaver', '/ScreenSaver', 'Lock']
        XFCE:						['xflock4']
        Otherwise:					None
    """
    desktop_session = os.environ.get('DESKTOP_SESSION')
    current_desktop = os.environ.get('XDG_CURRENT_DESKTOP')
    if desktop_session is not None:
        desktop_session = desktop_session.lower()
        if ('xfce' in desktop_session or desktop_session.startswith('xubuntu') or (current_desktop is not None and 'xfce' in current_desktop)) and Utility.command_exist('xflock4'):
            return ['xflock4']
        elif desktop_session == 'cinnamon' and Utility.command_exist('cinnamon-screensaver-command'):
            return ['cinnamon-screensaver-command', '--lock']
        elif (desktop_session == 'pantheon' or desktop_session.startswith('lubuntu')) and Utility.command_exist('light-locker-command'):
            return ['light-locker-command', '--lock']
        elif desktop_session == 'mate' and Utility.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 Utility.command_exist('gnome-screensaver-command'):
                return ['gnome-screensaver-command', '--lock']
            # 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']
        elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
            if 'deprecated' not in os.environ.get('GNOME_DESKTOP_SESSION_ID') and Utility.command_exist('gnome-screensaver-command'):
                # Gnome 2
                return ['gnome-screensaver-command', '--lock']
github slgobinath / SafeEyes / safeeyes / SettingsDialog.py View on Github external
self.spin_long_break_duration.set_value(config['long_break_duration'])
        self.spin_interval_between_two_breaks.set_value(
            config['break_interval'])
        self.spin_short_between_long.set_value(
            config['no_of_short_breaks_per_long_break'])
        self.spin_time_to_prepare.set_value(config['pre_break_warning_time'])
        self.spin_idle_time_to_pause.set_value(config['idle_time'])
        self.spin_postpone_duration.set_value(config['postpone_duration'])
        self.switch_show_time_in_tray.set_active(config['show_time_in_tray'])
        self.switch_strict_break.set_active(config['strict_break'])
        self.switch_audible_alert.set_active(config['audible_alert'])
        self.spin_time_to_screen_lock.set_value(config['time_to_screen_lock'])

        # Enable idle_time_to_pause only if xprintidle is available
        self.spin_idle_time_to_pause.set_sensitive(
            Utility.command_exist('xprintidle'))

        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_postpone.set_active(
            config['allow_postpone'] and not config['strict_break'])

        # Update relative states
        # GtkSwitch state-set signal is available only from 3.14
        if Gtk.get_minor_version() >= 14:
            self.switch_strict_break.connect(
                'state-set', self.on_switch_strict_break_activate)
            self.switch_screen_lock.connect(
                'state-set', self.on_switch_screen_lock_activate)
            self.switch_postpone.connect(
                'state-set', self.on_switch_postpone_activate)
github slgobinath / SafeEyes / safeeyes / plugins / screensaver / plugin.py View on Github external
Mate:						['mate-screensaver-command', '--lock']
        KDE:						['qdbus', 'org.freedesktop.ScreenSaver', '/ScreenSaver', 'Lock']
        XFCE:						['xflock4']
        Otherwise:					None
    """
    desktop_session = os.environ.get('DESKTOP_SESSION')
    current_desktop = os.environ.get('XDG_CURRENT_DESKTOP')
    if desktop_session is not None:
        desktop_session = desktop_session.lower()
        if ('xfce' in desktop_session or desktop_session.startswith('xubuntu') or (current_desktop is not None and 'xfce' in current_desktop)) and Utility.command_exist('xflock4'):
            return ['xflock4']
        elif desktop_session == 'cinnamon' and Utility.command_exist('cinnamon-screensaver-command'):
            return ['cinnamon-screensaver-command', '--lock']
        elif (desktop_session == 'pantheon' or desktop_session.startswith('lubuntu')) and Utility.command_exist('light-locker-command'):
            return ['light-locker-command', '--lock']
        elif desktop_session == 'mate' and Utility.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 Utility.command_exist('gnome-screensaver-command'):
                return ['gnome-screensaver-command', '--lock']
            # 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']
        elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
            if 'deprecated' not in os.environ.get('GNOME_DESKTOP_SESSION_ID') and Utility.command_exist('gnome-screensaver-command'):
                # Gnome 2
                return ['gnome-screensaver-command', '--lock']
    return None