DesktopFile.startApplication

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

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

  1. void startApplication(const(string)[] urls, string locale, const(string)[] terminalCommand)
    class DesktopFile
    @trusted const
    void
    startApplication
    (
    scope const(string)[] urls = null
    ,
    string locale = null
    ,
    lazy const(string)[] terminalCommand = getTerminalCommand
    )
  2. void startApplication(string url, string locale, const(string)[] terminalCommand)

Parameters

urls const(string)[]

urls application will start with.

locale string

locale that may be needed to be placed in params if Exec value has %c code.

terminalCommand const(string)[]

preferable terminal emulator command. If not set then terminal is determined via desktopfile.utils.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. desktopfile.utils.DesktopExecException if exec string is invalid.

Examples

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) {

    }
}

See Also

Meta