DesktopFile.startApplication - multiple declarations

Function DesktopFile.startApplication

Starts the application associated with this .desktop file using urls as command line params.

void startApplication (
  scope const(string)[] urls = null,
  string locale = null,
  lazy const(string)[] terminalCommand = getTerminalCommand()
) @trusted const;

If the program should be run in terminal it tries to find system defined terminal emulator to run in.

Parameters

NameDescription
urls urls application will start with.
locale locale that may be needed to be placed in params if Exec value has %c code.
terminalCommand preferable terminal emulator command. If not set then terminal is determined via getTerminalCommand.

Note

This function does not check if the type of desktop file is Application. It relies only on "Exec" value.

Throws

ProcessException on failure to start the process. DesktopExecException if exec string is invalid.

See Also

spawnApplication, getTerminalCommand, start, expandExecValue

Example

auto df = new DesktopFile();
assertThrown(df.startApplication(string[].init));

version(Posix) {
    static string[] emptyTerminalCommand() nothrow {
        return null;
    }

    df = new DesktopFile(iniLikeStringReader("[Desktop Entry]\nTerminal=true\nType=Application\nExec=whoami"));
    try {
        df.startApplication((string[]).init, null, emptyTerminalCommand);
    } catch(Exception e) {

    }
}

Function DesktopFile.startApplication

Starts the application associated with this .desktop file using url as command line params.

void startApplication (
  string url,
  string locale = null,
  lazy const(string)[] terminalCommand = getTerminalCommand()
) @trusted const;