示例#1
0
    def set_wallpaper(self, filepath, style=None):
        bg_style = self.wp_styles.get(
            int(style if style is not None else WPStyle.NONE))
        cmd = 'feh %s %s' % (bg_style, filepath)
        sys_command(cmd)

        self.persist()
示例#2
0
    def set_wallpaper_style(self, style):
        wp_style = self.wp_styles.get(int(style))
        if wp_style is None:
            wp_style = self.wp_styles['none']

        cmd = 'gsettings set org.gnome.desktop.background picture-options %s' % wp_style
        sys_command(cmd)
示例#3
0
 def supports(gdmsession, xdg_current_desktop):
     if xdg_current_desktop is not None and xdg_current_desktop == 'i3':
         rc, _ = sys_command('which feh')
         if rc == 0:
             return True
         else:
             raise DesktopError(
                 'feh is not installed; sudo apt-get install feh?')
示例#4
0
    def get_wallpaper_style(self):
        cmd = 'gsettings get org.gnome.desktop.background picture-options'
        _, op = sys_command(cmd)

        style_name = op.strip()[1:-1]
        style = dict([(v, k) for (k, v) in self.wp_styles.items()
                      ]).get(style_name, None)

        return WPStyle(style)
示例#5
0
    def get_wallpaper(self):
        cmd = 'gsettings get org.gnome.desktop.background picture-uri'
        _, op = sys_command(cmd)
        filepath_prefix = 'file://'

        if not op[1:].startswith(filepath_prefix):
            raise DesktopError(
                'wallpaper path probably not a local file path: %s' % op)

        return op.strip()[len(filepath_prefix) + 1:-1]
示例#6
0
 def setup_cmd_by_exe(self, cmdname, _to_hyphen=False):
     if cmdname == const.internal_dummy_cmdname:
         cmdname = CommandCollection().prog
         self.setup_cmd(cmdname, _to_hyphen=_to_hyphen)
     else:
         cmd = cmdname + ' ' + const.internal_subcmd + ' autocomp setup ' + const.internal_dummy_cmdname
         rc, op = sys_command(cmd)
         print(op)
         if rc != 0:
             raise InstallError(op)
示例#7
0
def get_desktop_size():
    xinfo = rc = None
    width = height = None

    rc, xinfo = sys_command('xdpyinfo')
    if rc != 0:
        log.error('xdpyinfo failed')

    dim_regex = re.compile(".*dimensions:\s+(\d+)x(\d+).*", re.M | re.S)
    m = dim_regex.match(xinfo)

    if m:
        width = int(m.group(1))
        height = int(m.group(2))

    return width, height
示例#8
0
    def quit(self, condition, retry, fade):
        if condition is not None:
            r = Retry(retries=retry[0], delay=retry[1], exp_bkf=False)

            while r.left():
                rc, _ = sys_command(condition)
                if rc == 0:
                    r.cancel()
                else:
                    r.retry()

        if fade > 0:
            saved_volume = self.volume
            self.fade_volume(0, fade)
            self.stop()
            self.volume = saved_volume

        self._main.Quit()
示例#9
0
    def execute_js(self, js):
        plasma_app = dbus.SessionBus().get_object('org.kde.plasma-desktop',
                                                  '/App')
        plasma_app_iface = dbus.Interface(plasma_app, 'local.PlasmaApp')

        temp_file = NamedTemporaryFile()
        temp_file.file.write(js)
        temp_file.file.flush()

        plasma_app_iface.loadScriptInInteractiveConsole(temp_file.name)

        xdo_cmd = "xdotool search --name \"Desktop Shell Scripting Console\" " + \
          "windowsize 200 200 key \"ctrl+e\" key \"ctrl+w\" windowminimize"

        rc, _ = sys_command(xdo_cmd, suppress_output=True)
        if rc == 127:
            log.error(
                'xdotool not found, it is needed to automate the desktop shell scripting console'
            )
示例#10
0
 def set_wallpaper_style(self, style):
     bg_style = self.wp_styles.get(
         int(style if style is not None else WPStyle.NONE))
     _, filepath = self.load_fehbg()
     cmd = 'feh %s %s' % (bg_style, filepath)
     sys_command(cmd)
示例#11
0
 def _show_image(self, filepath):
         sys_command("cmd /c start %s"%filepath)
示例#12
0
    def set_wallpaper(self, filepath, style=None):
        cmd = 'gsettings set org.gnome.desktop.background picture-uri file://%s' % filepath
        sys_command(cmd)

        if style is not None:
            self.set_wallpaper_style(style)
示例#13
0
    def completion_setup(self, cmdname):
        return False, 'a'  # temp
        rc, op = sys_command("bash -c 'complete | grep %s'" % cmdname)
        func = op.split()[-2] if rc == 0 else None

        return rc == 0, func