Example #1
0
def trash_get_params():
    home = Constants.USERHOMEDIR
    path_trash_files = home + "/.local/share/Trash/files/"
    gio_file = Gio.File.new_for_path(path_trash_files)

    if gio_file.query_exists():
        return path_trash_files
    else:
        try:
            GLib.spawn_command_line_sync("mkdir -p " + path_trash_files)
            return path_trash_files
        except Exception as err:
            print("ORG.GCLEANER.PLUGINS.TRASH: [COMMAND-ERROR: " + str(err) + "]")
            return "error"
Example #2
0
def intelb(_):
    result, output, error, status = glib.spawn_command_line_sync(
        '/usr/share/manjaroptimus-appindicator/scripts/pkexec_intel')
    if (error):
        notify.Notification.new(error_head, error.decode("utf-8"),
                                'dialog-warning').show()
    elif (result):
        notify.Notification.new(
            intel_notif, reboot_notifb,
            '/usr/share/icons/hicolor/symbolic/apps/manjaroptimus-intel-symbolic.svg'
        ).show()
        glib.spawn_command_line_sync(
            '/usr/share/manjaroptimus-appindicator/scripts/reboot.sh')
    else:
        notify.Notification.new(error_head, output.decode("utf-8"),
                                'dialog-warning').show()
Example #3
0
def intel(_):
    result, output, error, status = glib.spawn_command_line_sync('/usr/share/optimus-switch-indicator/scripts/pkexec_intel')
    if (error):
        notify.Notification.new(error_head, error.decode("utf-8"), 'dialog-warning').show()
    elif (result):
        notify.Notification.new(intel_notif, reboot_notif, 'prime-indicator-intel-symbolic').show()
    else:
        notify.Notification.new(error_head, output.decode("utf-8"), 'dialog-warning').show()
Example #4
0
def nvidia(_):
    result, output, error, status = glib.spawn_command_line_sync('/usr/share/suseprime-appindicator/scripts/pkexec_nvidia')
    if (error):
        notify.Notification.new(error_head, error.decode("utf-8"), 'dialog-warning').show()
    elif (result):
        notify.Notification.new(nvidia_notif, reboot_notif, 'suseprime-nvidia-symbolic').show()
    else:
        notify.Notification.new(error_head, output.decode("utf-8"), 'dialog-warning').show()
Example #5
0
def _get_serial_number():
    serial_no = _read_device_tree('serial-number')
    if serial_no is not None:
        return serial_no

    cmd = 'pkexec sugar-serial-number-helper'
    result, output, error, status = GLib.spawn_command_line_sync(cmd)
    if status != 0:
        return _not_available

    return output.rstrip('\n')
Example #6
0
def should_notify():
    """
    Return true if notification should be displayed.

    This runs the `inhibit-command` defined in the config and checks its exit
    status.

    """
    command = config['global'].get('inhibit-command')
    if not command:
        return True

    logger.debug('Checking if notification should be displayed command=%r',
                 command)
    result = GLib.spawn_command_line_sync(command)
    logger.debug('result=%s', result)

    return result.exit_status != 0
Example #7
0
def trash_clean(parent_window):
    home = Constants.USERHOMEDIR
    path_trash = home + "/.local/share/Trash/"
    cmd = "rm -Rf " + path_trash + "*"
    error = ""
    status = 0
    try:
        result, output, error, status = GLib.spawn_command_line_sync(cmd)
        if status != 0:
            # Show MsgBox with Error
            msg_cmd_failed(parent_window)
            return 1
        else:
            return 0
    except Exception as err:
        print("ORG.GCLEANER.PLUGIN-TRASH: [COMMAND-ERROR: " + str(err) + "]")
        print("ORG.GCLEANER.PLUGIN-TRASH: [ERROR: " + str(error) + "]")
        print("ORG.GCLEANER.PLUGIN-TRASH: [STATUS: " + str(status) + "%s]")
        return 1
Example #8
0
 def _helper_write(option, value):
     cmd = 'pkexec sugar-backlight-helper --%s %d' % (option, value)
     GLib.spawn_command_line_sync(cmd)
Example #9
0
 def _helper_read(option):
     cmd = 'sugar-backlight-helper --%s' % option
     result, output, error, status = GLib.spawn_command_line_sync(cmd)
     if status != 0:
         return None
     return output.rstrip(b'\0\n')
Example #10
0
 def _helper_read(self, option):
     cmd = '%s --%s' % (self._get_helper(), option)
     result, output, error, status = GLib.spawn_command_line_sync(cmd)
     if status != 0:
         return None
     return output.rstrip('\0\n')
Example #11
0
 def _helper_read(self, option):
     cmd = "sugar-backlight-helper --%s" % option
     result, output, error, status = GLib.spawn_command_line_sync(cmd)
     if status != 0:
         return None
     return output.rstrip("\0\n")
Example #12
0
 def _helper_write(self, option, value):
     cmd = 'pkexec %s --%s %d' % (self._get_helper(), option, value)
     GLib.spawn_command_line_sync(cmd)
Example #13
0
 def _helper_read(self, option):
     cmd = '%s --%s' % (self._get_helper(), option)
     result, output, error, status = GLib.spawn_command_line_sync(cmd)
     if status != 0:
         return None
     return output.rstrip('\0\n')
Example #14
0
 def _setup(self):
     cmd = 'pkexec %s' % self._find_binary('sugar-backlight-setup')
     GLib.spawn_command_line_sync(cmd)
Example #15
0
 def _helper_write(self, option, value):
     cmd = 'pkexec %s --%s %d' % (self._get_helper(), option, value)
     GLib.spawn_command_line_sync(cmd)
Example #16
0
 def _setup(self):
     cmd = "pkexec sugar-backlight-setup"
     GLib.spawn_command_line_sync(cmd)
Example #17
0
 def _setup():
     cmd = 'pkexec sugar-backlight-setup'
     GLib.spawn_command_line_sync(cmd)
Example #18
0
 def _helper_write(self, option, value):
     cmd = "pkexec sugar-backlight-helper --%s %d" % (option, value)
     GLib.spawn_command_line_sync(cmd)
Example #19
0
 def _setup(self):
     cmd = 'pkexec %s' % self._find_binary('sugar-backlight-setup')
     GLib.spawn_command_line_sync(cmd)