desktopfile.utils

Utility functions for reading and executing desktop files.

Public Imports

inilike.common
public import inilike.common;
inilike.range
public import inilike.range;

Members

Classes

DesktopExecException
class DesktopExecException

Exception thrown when "Exec" value of DesktopFile or DesktopAction is invalid.

Enums

ParamSupport
enum ParamSupport

Flag set of parameter kinds supported by application. Having more than one flag means that Exec command is ambiguous.

Functions

desktopId
string desktopId(string fileName, Range appsPaths)

See Desktop File ID

desktopId
string desktopId(string fileName)

See Desktop File ID

expandExecArgs
string[] expandExecArgs(const(string)[] unquotedArgs, const(string)[] urls, string iconName, string displayName, string fileName)

Expand Exec arguments (usually returned by unquoteExec) replacing field codes with given values, making the array suitable for passing to spawnProcess. Deprecated field codes are ignored. Note: Returned array may be empty and must be checked before passing to spawning the process.

findDesktopFile
string findDesktopFile(string desktopId, Range appsPaths)

Find desktop file by Desktop File ID. Desktop file ID can be ambiguous when it has hyphen symbol, so this function can try both variants.

findDesktopFile
string findDesktopFile(string desktopId)

ditto Note: This function retrieves applications paths each time it's called and therefore can impact performance. To avoid this issue use the overload with argument.

fireDesktopFile
void fireDesktopFile(IniLikeReader reader, string fileName, FireOptions options)

Read the desktop file and run application or open link depending on the type of the given desktop file.

fireDesktopFile
void fireDesktopFile(string fileName, FireOptions options)

ditto, but automatically create IniLikeReader from the file.

getDefaultTerminalCommand
string[] getDefaultTerminalCommand()
Undocumented in source. Be warned that the author may not have intended to support it.
getNullStderr
File getNullStderr()
Undocumented in source. Be warned that the author may not have intended to support it.
getNullStdin
File getNullStdin()
Undocumented in source. Be warned that the author may not have intended to support it.
getNullStdout
File getNullStdout()
Undocumented in source. Be warned that the author may not have intended to support it.
getTerminalCommand
string[] getTerminalCommand()

Detect command which will run program in terminal emulator. It tries to detect your desktop environment and find default terminal emulator for it. If all guesses failed, it uses ["xterm", "-e"] as fallback. Note: This function always returns empty array on non-freedesktop systems.

isTrusted
bool isTrusted(string appFileName)

Check if .desktop file is trusted.

needMultipleInstances
bool needMultipleInstances(const(string)[] execArgs)

Check if application should be started multiple times to open multiple urls.

paramSupport
ParamSupport paramSupport(const(string)[] execArgs)

Evaluate ParamSupport flags for application Exec command.

readDesktopEntryValues
bool readDesktopEntryValues(IniLikeReader reader, string locale, string fileName, string iconName, string name, string execValue, string url, string workingDirectory, bool terminal)
Undocumented in source. Be warned that the author may not have intended to support it.
spawnApplication
void spawnApplication(const(string)[] unquotedArgs, SpawnParams params)

Spawn application with given params.

unquoteExec
auto unquoteExec(string unescapedValue)

Apply unquoting to Exec value making it into an array of escaped arguments. It automatically performs quote-related unescaping.

xdgOpen
void xdgOpen(string url)
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

ExecBuilder
struct ExecBuilder

Helper struct to build Exec string for desktop file. Note: While Desktop Entry Specification says that field codes must not be inside quoted argument, ExecBuilder does not consider it as error and may create quoted argument if field code is prepended by the string that needs quotation.

FireOptions
struct FireOptions

Options to pass to fireDesktopFile.

SpawnParams
struct SpawnParams

Parameters for spawnApplication.

See Also

Meta