def run(self): iface = _create_dbus_connection_mpris(_OBJ_NAME_MPRIS_PLAYER, _OBJ_PATH_MPRIS, True) if iface: iface.Previous() else: utils.spawn_async(("rhythmbox-client", "--no-start", "--previous"))
def activate(self, app): argv = utils.argv_for_commandline(app.object.get_commandline()) for i, arg in enumerate(argv): if arg == "%u" or arg == "%U": argv.pop(i) argv.insert(0, 'optirun') utils.spawn_async(argv)
def activate(self, leaf, ctx): utils.spawn_async([ "gnome-terminal", "--profile=%s" % leaf.object, "--display=%s" % ctx.environment.get_display() ], in_dir=os.path.expanduser("~"))
def run(self, leaf): browser_type = __kupfer_settings__["browser_type"] searchhwdb = [ browser_type, 'https://nannyfe.prod.denic.de/host/%s' % leaf ] utils.spawn_async(searchhwdb)
def play_song(info): uri = _tostr(info["location"]) iface = _create_dbus_connection_mpris(_OBJ_NAME_MPRIS_PLAYER, _OBJ_PATH_MPRIS, True) if iface: iface.OpenUri(uri) else: utils.spawn_async(("rhythmbox-client", "--play-uri=%s" % uri))
def activate(self, leaf): skypeId = leaf.object utils.spawn_async([ "sh", "-c", 'skype "skype:' + skypeId + '"' + ' && xdotool search --sync --onlyvisible --name "' + leaf.name + '"' ' | xargs -n 1 -I {} xdotool windowactivate --sync {}' ])
def activate_multiple(self, objects, iobjects): recipients = (iobj.object for iobj in iobjects) cli = ['gpg', '--sign', '--encrypt', '--batch'] cli.extend(support.format_recipients_params(recipients)) for obj in objects: cli_ = cli[:] cli_.append(obj.object) utils.spawn_async(cli_)
def activate(self, leaf, iobj=None): key = iobj.object if iobj else __kupfer_settings__['default_key'] cli = ['gpg', '--detach-sign', '--batch'] if key: cli.append('--local-user') cli.append(key) cli.append(leaf.object) utils.spawn_async(cli)
def _make_archive(cls, basename, dirpath, filepaths): archive_type = __kupfer_settings__["archive_type"] archive_path = \ utils.get_destpath_in_directory(dirpath, basename, archive_type) cmd = ["file-roller", "--add-to=%s" % (archive_path, )] cmd.extend(filepaths) runtimehelper.register_async_file_result(archive_path) utils.spawn_async(cmd) return archive_path
def activate(self, leaf): if self.quoted: argv = [leaf.object] else: argv = utils.argv_for_commandline(leaf.object) if self.in_terminal: utils.spawn_in_terminal(argv) else: utils.spawn_async(argv)
def mount_volume_in_truecrypt(filepath): ''' Mount file in Truecrypt. Escape apostrophes - ie: "test'dk 'dlk' dsl''k '' sdkl.test" -> "'test'\''dk '\''dlk'\'' dsl'\'''\''k '\'''\'' sdkl.test'" ''' # escape ' characters filepath = filepath.replace("'", "'\\''") utils.spawn_async(["truecrypt", filepath])
def activate(self, leaf): email = email_from_leaf(leaf) if not utils.spawn_async(['thunderbird', 'mailto:%s' % email]): utils.spawn_async(['icedove', 'mailto:%s' % email]) if (not utils.spawn_async_notify_as( 'thunderbird.desktop', ['thunderbird', 'mailto:%s' % email])): utils.spawn_async_notify_as( 'icedove.desktop', ['icedove', 'mailto:%s' % email])
def activate(self, leaf, obj, ctx): size = self._make_size(obj.object) fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, size, ext) dpath = utils.get_destpath_in_directory(dirname, filename) argv = ["convert", "-scale", ('%s' % size), fpath, dpath] runtimehelper.register_async_file_result(ctx, dpath) utils.spawn_async(argv) return FileLeaf(dpath)
def activate(self, leaf, obj=None): fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, self.rotation, ext) dpath = utils.get_destpath_in_directory(dirname, filename) argv = ["jpegtran", "-copy", "all", "-rotate", self.rotation, "-outfile", dpath, fpath] runtimehelper.register_async_file_result(dpath) utils.spawn_async(argv) return FileLeaf(dpath)
def activate(self, leaf, obj): size = self._make_size(obj.object) fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, size, ext) dpath = utils.get_destpath_in_directory(dirname, filename) argv = ["convert", "-scale", ('%s' % size), fpath, dpath] runtimehelper.register_async_file_result(dpath) utils.spawn_async(argv) return FileLeaf(dpath)
def activate(self, leaf): if leaf.check_key(PUTTY_SESSION_KEY): session = leaf[PUTTY_SESSION_KEY] utils.spawn_async(["putty", "-load", session]) else: options = ['putty'] if leaf.check_key(HOST_SERVICE_USER_KEY): options.extend(['-l ', leaf[HOST_SERVICE_USER_KEY]]) if leaf.check_key(HOST_SERVICE_PORT_KEY): options.extend(['-P ', leaf[HOST_SERVICE_PORT_KEY]]) options.append(leaf[HOST_ADDRESS_KEY]) utils.spawn_async(options)
def activate(self, leaf): fpath = leaf.object if self.method == "vertical": argv = ["mogrify", "-flip", fpath] else: argv = ["mogrify", "-flop", fpath] # TODO Somethin like this? #runtimehelper.register_async_file_result(ctx, fpath) utils.spawn_async(argv) # TODO ...and then return something like this? #return FileLeaf(fpath) return
def activate(self, leaf, ctx): fpath = leaf.object dirname = os_path.dirname(fpath) head, ext = os_path.splitext(os_path.basename(fpath)) filename = "%s_%s%s" % (head, self.rotation, ext) dpath = utils.get_destpath_in_directory(dirname, filename) argv = [ "jpegtran", "-copy", "all", "-rotate", self.rotation, "-outfile", dpath, fpath ] runtimehelper.register_async_file_result(ctx, dpath) utils.spawn_async(argv) return FileLeaf(dpath)
def enqueue_songs(info, clear_queue=False): songs = list(info) if not songs: return qargv = ["rhythmbox-client"] if clear_queue: qargv.append("--clear-queue") for song in songs: uri = _tostr(song["location"]) gfile = gio.File(uri) path = gfile.get_path() qargv.append("--enqueue") qargv.append(path) utils.spawn_async(qargv)
def activate(self, leaf): if isinstance(leaf, UrlLeaf): utils.spawn_async(["vinagre", leaf.object]) else: service = leaf[HOST_SERVICE_NAME_KEY] host = leaf[HOST_ADDRESS_KEY] port = '' if leaf.check_key(HOST_SERVICE_PORT_KEY): port = ':' + leaf[HOST_SERVICE_PORT_KEY] user = '' if leaf.check_key(HOST_SERVICE_USER_KEY): user = leaf[HOST_SERVICE_USER_KEY] + '@' url = '%s://%s%s%s' % (service, user, host, port) utils.spawn_async(["vinagre", url])
def activate(self, leaf): text = leaf.object keys, orig_mods = gtk.accelerator_parse(text) m = { gtk.gdk.SHIFT_MASK: "Shift_L", gtk.gdk.CONTROL_MASK: "Control_L", gtk.gdk.SUPER_MASK: "Super_L", gtk.gdk.MOD1_MASK: "Alt_L", } mod_names = [] mods = orig_mods for mod in m: if mod & mods: mod_names.append(m[mod]) mods &= ~mod if mods != 0: raise OperationError(_("Keys not yet implemented: %s") % gtk.accelerator_get_label(keys, orig_mods)) key_arg = 'key %s' % (gtk.gdk.keyval_name(keys), ) mods_down = ['keydown ' + n for n in mod_names] mods_up = ['keyup ' + n for n in reversed(mod_names)] xte_paste_argv = ['xte', 'usleep 300000'] + \ mods_down + [key_arg] + mods_up if not utils.spawn_async(xte_paste_argv): raise CommandMissingError('xte')
def activate(self, leaf): clip = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD) interface.copy_to_clipboard(leaf, clip) xte_paste_argv = ['xte', 'usleep 300000', 'keydown Control_L', 'key v', 'keyup Control_L'] if not utils.spawn_async(xte_paste_argv): raise CommandMissingError('xte')
def launch_argv_with_fallbacks(commands, print_error=True): """Try the sequence of @commands with utils.spawn_async, and return with the first successful command. return False if no command is successful and log an error """ for argv in commands: ret = utils.spawn_async(argv) if ret: return ret pretty.print_error(__name__, "Unable to run command(s)", commands) return False
def activate(self, leaf): text = interface.get_text_representation(leaf) xte_paste_argv = ['xte', 'usleep 300000'] # replace all newlines with 'key Return' for line in text.splitlines(True): xte_paste_argv.append("str " + line.rstrip("\r\n")) if line.endswith("\n"): xte_paste_argv.append("key Return") if not utils.spawn_async(xte_paste_argv): raise CommandMissingError('xte')
def vm_action(action, vm_uuid): ''' change state of the virtual machine. Call VBoxManage. @param action - one of the const VM_* @param vm_uuid - virtual machine uuid ''' if action == vbox_const.VM_START_NORMAL: utils.spawn_async(['VBoxManage', 'startvm', vm_uuid, '--type', 'gui']) elif action == vbox_const.VM_START_HEADLESS: utils.spawn_async(['VBoxManage', 'startvm', vm_uuid, '--type', 'headless']) else: command = _ACTIONS[action] utils.spawn_async(['VBoxManage', 'controlvm', vm_uuid, command])
def activate(self, leaf): new_cmd = [ 'qdbus', 'org.kde.yakuake', '/yakuake/sessions', 'org.kde.yakuake.addSession' ] run_cmd = [ 'qdbus', 'org.kde.yakuake', '/yakuake/sessions', 'runCommand', 'ssh %s' % leaf.object ] open_cmd = [ 'qdbus', 'org.kde.yakuake', '/yakuake/window', 'org.kde.yakuake.toggleWindowState' ] utils.spawn_async(new_cmd) utils.spawn_async(open_cmd) utils.spawn_async(run_cmd)
def activate(self, leaf, iobj=None): if isinstance(leaf, (UrlLeaf, TextLeaf)): utils.spawn_async(['filezilla', leaf.object]) elif leaf.check_key(FILEZILLA_SITE_KEY): sessname = leaf.entry_type + '/' + leaf[hosts.HOST_NAME_KEY] utils.spawn_async(['filezilla', '-c', sessname]) else: url = ['ftp://'] if leaf.check_key(hosts.HOST_SERVICE_USER_KEY): url.append(leaf[hosts.HOST_SERVICE_USER_KEY]) if leaf.check_key(hosts.HOST_SERVICE_PASS_KEY): url.append(':') url.append(leaf[hosts.HOST_SERVICE_PASS_KEY]) url.append('@') url.append(leaf[hosts.HOST_ADDRESS_KEY]) if leaf.check_key(hosts.HOST_SERVICE_PORT_KEY): url.append(':') url.append(leaf[hosts.HOST_SERVICE_PORT_KEY]) if leaf.check_key(hosts.HOST_SERVICE_REMOTE_PATH_KEY): url.append(leaf[hosts.HOST_SERVICE_REMOTE_PATH_KEY]) utils.spawn_async(['filezilla', ''.join(url)])
def run(self): utils.spawn_async((AUDTOOL, "playlist-shuffle-toggle"))
def run(self): restart = ["/usr/local/bin/vpnconnect.sh", "restart"] utils.spawn_async(restart)
def activate(self, leaf): session = leaf[TSCLIENT_SESSION_KEY] utils.spawn_async(["tsclient", "-x", session])
def clear_queue(): utils.spawn_async((AUDTOOL, "playqueue-clear"))
def _start_zim(notebook, page): ''' Start zim and open given notebook and page. ''' utils.spawn_async(("zim", notebook, page.replace("'", "_")))
def run(self): vpnstop = ["/usr/local/bin/vpnconnect.sh", "stop"] utils.spawn_async(vpnstop)
def dequeue_song(info): utils.spawn_async((AUDTOOL, "playqueue-remove", "%d" % info))
def run(self): utils.spawn_async((AUDTOOL, "playlist-repeat-toggle"))
def activate(self, leaf): cli = ['gpg', '--symmetric', '--batch', leaf.object] utils.spawn_async(cli)
def activate_multiple(self, objects): cli = ['gpg', '--decrypt-files', '--batch'] cli.extend(obj.object for obj in objects) utils.spawn_async(cli)
def enqueue_song(info): utils.spawn_async((AUDTOOL, "playqueue-add", "%d" % info))
def activate_multiple(self, objects, iobjects): recipients = (iobj.object for iobj in iobjects) cli = ['gpg', '--encrypt-files', '--batch'] cli.extend(support.format_recipients_params(recipients)) cli.extend(obj.object for obj in objects) utils.spawn_async(cli)
def play_song(info): utils.spawn_async((AUDTOOL, "playlist-jump", "%d" % info)) utils.spawn_async((AUDTOOL, "playback-play"))
def activate(self, leaf): command = ("psoco pwd %s" % leaf.pwid) p1 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) out, ignored_err = p1.communicate() utils.spawn_async(['copyq', 'add', out.decode("utf-8").strip('\n')])
def run(self): utils.spawn_async((AUDTOOL, "playback-play"))
def activate(self, leaf, obj): lpath = leaf.object tag = obj.object utils.spawn_async(["tracker-tag", "--remove=%s" % tag, lpath])
def activate(self, leaf): terminal = __kupfer_settings__["terminal_emulator"] exarg = __kupfer_settings__["terminal_emulator_exarg"] utils.spawn_async([terminal, exarg, "ssh", leaf[HOST_ADDRESS_KEY]])
def activate(self, leaf): utils.spawn_async(["tracker-search-tool", leaf.object])