Example #1
0
def spawn_terminal(workdir=None, screen=None):
    " Raises SpawnError "
    term = terminal.get_configured_terminal()
    notify = term["startup_notify"]
    app_id = term["desktopid"]
    argv = term["argv"]
    desktop_launch.spawn_app_id(app_id, argv, workdir, notify, screen)
Example #2
0
def spawn_terminal(workdir=None, screen=None):
	" Raises SpawnError "
	term = terminal.get_configured_terminal()
	notify = term["startup_notify"]
	app_id = term["desktopid"]
	argv = term["argv"]
	desktop_launch.spawn_app_id(app_id, argv, workdir, notify, screen)
Example #3
0
def spawn_in_terminal(argv, workdir=None):
	term = terminal.get_configured_terminal()
	notify = term["startup_notify"]
	_argv = list(term["argv"])
	if term["exearg"]:
		_argv.append(term["exearg"])
	_argv.extend(argv)
	desktop_launch.spawn_app_id(term["desktopid"], _argv , workdir, notify)
Example #4
0
def spawn_in_terminal(argv, workdir=None):
    " Raises SpawnError "
    term = terminal.get_configured_terminal()
    notify = term["startup_notify"]
    _argv = list(term["argv"])
    if term["exearg"]:
        _argv.append(term["exearg"])
    _argv.extend(argv)
    desktop_launch.spawn_app_id(term["desktopid"], _argv, workdir, notify)
Example #5
0
def launch_app_info(app_info,
                    gfiles=[],
                    in_terminal=None,
                    timestamp=None,
                    desktop_file=None,
                    launch_cb=None,
                    screen=None):
    """
	Launch @app_info, opening @gfiles

	@in_terminal: override Terminal flag
	@timestamp: override timestamp
	@desktop_file: specify location of desktop file
	@launch_cb: Called once per launched process,
	            like ``spawn_app``

	Will pass on exceptions from spawn_app
	"""
    desktop_file = desktop_file or _file_for_app_info(app_info)
    desktop_info = _info_for_desktop_file(desktop_file)
    if not desktop_file or not desktop_info:
        # Allow in-memory app_info creations (without id or desktop file)
        desktop_file = ""
        desktop_info = create_desktop_info(app_info.get_commandline() or "",
                                           app_info.get_name(), "", "", False,
                                           False)
        # in this case, the command line is already primarily escaped
        argv = desktop_parse.parse_argv(desktop_info["Exec"])
    else:
        # In the normal case, we must first escape one round
        argv = desktop_parse.parse_unesc_argv(desktop_info["Exec"])
    assert argv and argv[0]

    # Now Resolve the %f etc format codes
    multiple_needed, missing_format, launch_argv = \
      replace_format_specs(argv, desktop_file, desktop_info, gfiles)

    if not multiple_needed:
        # Launch 1 process
        launch_records = [(launch_argv, gfiles)]

    else:
        # Launch one process per file
        launch_records = [(launch_argv, [gfiles[0]])]
        for f in gfiles[1:]:
            _ignore1, _ignore2, launch_argv = \
             replace_format_specs(argv, desktop_file, desktop_info, [f])
            launch_records.append((launch_argv, [f]))

    notify = desktop_info["StartupNotify"]
    workdir = desktop_info["Path"] or None

    if in_terminal is None:
        in_terminal = desktop_info["Terminal"]
    if in_terminal:
        term = terminal.get_configured_terminal()
        notify = notify or term["startup_notify"]

    for argv, gfiles in launch_records:
        if in_terminal:
            term = terminal.get_configured_terminal()
            targv = list(term["argv"])
            if term["exearg"]:
                targv.append(term["exearg"])
            argv = targv + argv
        ret = spawn_app(app_info,
                        argv,
                        gfiles,
                        workdir,
                        notify,
                        timestamp=timestamp,
                        launch_cb=launch_cb,
                        screen=screen)
        if not ret:
            return False
    return True
Example #6
0
def launch_app_info(app_info, gfiles=[], in_terminal=None, timestamp=None,
	                desktop_file=None, launch_cb=None):
	"""
	Launch @app_info, opening @gfiles

	@in_terminal: override Terminal flag
	@timestamp: override timestamp
	@desktop_file: specify location of desktop file
	@launch_cb: Called once per launched process,
	            like ``spawn_app``

	Will pass on exceptions from spawn_app
	"""
	desktop_file = desktop_file or _file_for_app_info(app_info)
	desktop_info = _info_for_desktop_file(desktop_file)
	if not desktop_file or not desktop_info:
		# Allow in-memory app_info creations (without id or desktop file)
		desktop_file = ""
		desktop_info = create_desktop_info(app_info.get_commandline() or "",
		                                   app_info.get_name(),
		                                   "",
		                                   "",
		                                   False,
		                                   False)
		# in this case, the command line is already primarily escaped
		argv = desktop_parse.parse_argv(desktop_info["Exec"])
	else:
		# In the normal case, we must first escape one round
		argv = desktop_parse.parse_unesc_argv(desktop_info["Exec"])
	assert argv and argv[0]

	# Now Resolve the %f etc format codes
	multiple_needed, missing_format, launch_argv = \
			replace_format_specs(argv, desktop_file, desktop_info, gfiles)

	if not multiple_needed:
		# Launch 1 process
		launch_records = [(launch_argv, gfiles)]

	else:
		# Launch one process per file
		launch_records = [(launch_argv, [gfiles[0]])]
		for f in gfiles[1:]:
			_ignore1, _ignore2, launch_argv = \
				replace_format_specs(argv, desktop_file, desktop_info, [f])
			launch_records.append((launch_argv, [f]))

	notify = desktop_info["StartupNotify"]
	workdir = desktop_info["Path"] or None

	if in_terminal is None:
		in_terminal = desktop_info["Terminal"]
	if in_terminal:
		term = terminal.get_configured_terminal()
		notify = notify or term["startup_notify"]

	for argv, gfiles in launch_records:
		if in_terminal:
			term = terminal.get_configured_terminal()
			targv = list(term["argv"])
			if term["exearg"]:
				targv.append(term["exearg"])
			argv = targv + argv
		ret = spawn_app(app_info, argv, gfiles, workdir, notify,
		                timestamp=timestamp, launch_cb=launch_cb)
		if not ret:
			return False
	return True
Example #7
0
def spawn_terminal(workdir=None):
	term = terminal.get_configured_terminal()
	notify = term["startup_notify"]
	app_id = term["desktopid"]
	argv = term["argv"]
	desktop_launch.spawn_app_id(app_id, argv, workdir, notify)