예제 #1
0
파일: rhythmbox.py 프로젝트: pbx/kupfer
 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"))
예제 #2
0
 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)
예제 #3
0
 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("~"))
예제 #4
0
 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)
예제 #5
0
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))
예제 #6
0
 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"))
예제 #7
0
 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 {}'
     ])
예제 #8
0
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))
예제 #9
0
	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_)
예제 #10
0
 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)
예제 #11
0
	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)
예제 #12
0
 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_)
예제 #13
0
	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
예제 #14
0
 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)
예제 #15
0
파일: truecrypt.py 프로젝트: pbx/kupfer
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])
예제 #16
0
	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])
예제 #17
0
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])
예제 #18
0
 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)
예제 #19
0
파일: image.py 프로젝트: tuxcanfly/kupfer
	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)
예제 #20
0
파일: image.py 프로젝트: tuxcanfly/kupfer
	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)
예제 #21
0
파일: putty.py 프로젝트: pbx/kupfer
 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)
예제 #22
0
 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)
예제 #23
0
	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
예제 #24
0
 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
예제 #25
0
 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)
예제 #26
0
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)
예제 #27
0
 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])
예제 #28
0
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)
예제 #29
0
	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])
예제 #30
0
	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')
예제 #31
0
	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')
예제 #32
0
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
예제 #33
0
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
예제 #34
0
	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')
예제 #35
0
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])
예제 #36
0
 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)
예제 #37
0
 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)])
예제 #38
0
	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)])
예제 #39
0
	def run(self):
		utils.spawn_async((AUDTOOL, "playlist-shuffle-toggle"))
예제 #40
0
 def run(self):
     restart = ["/usr/local/bin/vpnconnect.sh", "restart"]
     utils.spawn_async(restart)
예제 #41
0
 def activate(self, leaf):
     session = leaf[TSCLIENT_SESSION_KEY]
     utils.spawn_async(["tsclient", "-x", session])
예제 #42
0
def clear_queue():
    utils.spawn_async((AUDTOOL, "playqueue-clear"))
예제 #43
0
파일: zim.py 프로젝트: somas95/kupfer
def _start_zim(notebook, page):
    ''' Start zim and open given notebook and page. '''
    utils.spawn_async(("zim", notebook, page.replace("'", "_")))
예제 #44
0
	def activate(self, leaf):
		session = leaf[TSCLIENT_SESSION_KEY]
		utils.spawn_async(["tsclient", "-x", session])
예제 #45
0
 def run(self):
     vpnstop = ["/usr/local/bin/vpnconnect.sh", "stop"]
     utils.spawn_async(vpnstop)
예제 #46
0
def clear_queue():
	utils.spawn_async((AUDTOOL, "playqueue-clear"))
예제 #47
0
def dequeue_song(info):
	utils.spawn_async((AUDTOOL, "playqueue-remove", "%d" % info))
예제 #48
0
	def run(self):
		utils.spawn_async((AUDTOOL, "playlist-repeat-toggle"))
예제 #49
0
 def activate(self, leaf):
     cli = ['gpg', '--symmetric', '--batch', leaf.object]
     utils.spawn_async(cli)
예제 #50
0
 def activate_multiple(self, objects):
     cli = ['gpg', '--decrypt-files', '--batch']
     cli.extend(obj.object for obj in objects)
     utils.spawn_async(cli)
예제 #51
0
def enqueue_song(info):
	utils.spawn_async((AUDTOOL, "playqueue-add", "%d" % info))
예제 #52
0
 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)
예제 #53
0
def play_song(info):
	utils.spawn_async((AUDTOOL, "playlist-jump", "%d" % info))
	utils.spawn_async((AUDTOOL, "playback-play"))
예제 #54
0
 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')])
예제 #55
0
	def run(self):
		utils.spawn_async((AUDTOOL, "playback-play"))
예제 #56
0
 def activate(self, leaf, obj):
     lpath = leaf.object
     tag = obj.object
     utils.spawn_async(["tracker-tag", "--remove=%s" % tag, lpath])
예제 #57
0
	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]])
예제 #58
0
 def activate(self, leaf):
     utils.spawn_async(["tracker-search-tool", leaf.object])