desktopfile.utils

Utility functions for reading and executing desktop files.

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(in string[] unquotedArgs, in string[] urls = null, string iconName = null, string displayName = null, string fileName = null)

Expand Exec arguments (usually returned by unquoteExec) replacing field codes with given values, making the array suitable for passing to spawnProcess or spawnProcessDetached. 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.

getTerminalCommand
string[] getTerminalCommand()

Detect command which will run program in terminal emulator.

isTrusted
bool isTrusted(string appFileName)

Check if .desktop file is trusted.

needMultipleInstances
bool needMultipleInstances(in string[] execArgs)

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

paramSupport
ParamSupport paramSupport(in string[] execArgs)

Evaluate ParamSupport flags for application Exec command.

shootDesktopFile
void shootDesktopFile(IniLikeReader reader, string fileName = null, ShootOptions options = ShootOptions.init)

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

shootDesktopFile
void shootDesktopFile(string fileName, ShootOptions options = ShootOptions.init)

ditto, but automatically create IniLikeReader from the file.

spawnApplication
void spawnApplication(const(string)[] unquotedArgs, const 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.

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.

ShootOptions
struct ShootOptions

Options to pass to shootDesktopFile.

SpawnParams
struct SpawnParams

Parameters for spawnApplication.

See Also

Meta