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(in string[] urls = null, string locale = null, lazy const(string)[] terminalCommand = getTerminalCommand)
    class DesktopFile
    @trusted
    void
    startApplication
    const
    (
    in string[] urls = null
    ,
    string locale = null
    ,
    lazy const(string)[] terminalCommand = getTerminalCommand
    )
  2. void startApplication(string url, string locale = null, lazy const(string)[] terminalCommand = getTerminalCommand)

Parameters

urls
Type: string[]

urls application will start with.

locale
Type: string

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

terminalCommand
Type: const(string)[]

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. desktopfile.utils.DesktopExecException if exec string is invalid.

Examples

1 auto df = new DesktopFile();
2 assertThrown(df.startApplication(string[].init));
3 
4 version(Posix) {
5     static string[] emptyTerminalCommand() nothrow {
6         return null;
7     }
8 
9     df = new DesktopFile(iniLikeStringReader("[Desktop Entry]\nTerminal=true\nType=Application\nExec=whoami"));
10     try {
11         df.startApplication((string[]).init, null, emptyTerminalCommand);
12     } catch(Exception e) {
13 
14     }
15 }

See Also

Meta