Reads desktop file from file.
Reads desktop file from range of IniLikeLines.
Constructs DesktopFile with "Desktop Entry" group and Version set to 1.0
This alias allows to call functions related to "Desktop Entry" group without need to call desktopEntry explicitly.
Desktop entry type
Get additional application action by name.
Actions supported by application.
Sets the list of values for "Actions" list.
Iterating over existing actions.
Categories this program belongs to.
Sets the list of values for the "Categories" list.
Tooltip for the entry, for example "View sites on the Internet".
A boolean value specifying if D-Bus activation is supported for this application.
Expand "Exec" value into the array of command line arguments to use to start the program. It applies unquoting and unescaping.
Generic name of the application, for example "Web Browser".
Hidden means the user deleted (at his level) something that was present (at an upper level, e.g. in the system dirs). It's strictly equivalent to the .desktop file not existing at all, as far as that user is concerned.
Icon to display in file manager, menus, etc.
See Desktop File ID
See Desktop File ID
A list of strings which may be used in addition to other metadata to describe this entry.
Sets the list of values for the "Keywords" list.
The MIME type(s) supported by this application.
Sets the list of values for the "MimeType" list.
Specific name of the application, for example "Mozilla".
NoDisplay means "this application exists, but don't display it in the menus".
A list of strings identifying the desktop environments that should not display a given desktop entry.
A list of strings identifying the desktop environments that should display a given desktop entry.
Removes group by name. You can't remove "Desktop Entry" group with this function.
Starts application or open link depending on desktop entry type.
ditto, but uses the only url.
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.
Opens url defined in .desktop file using xdg-open. Note: This function does not check if the type of desktop file is Link. It relies only on "URL" value.
Whether the program runs in a terminal window.
Sets "Terminal" field to true or false.
Value used to determine if the program is actually installed. If the path is not an absolute path, the file should be looked up in the PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example).
Type of desktop entry.
Sets "Type" field to type Note: Setting the Unknown type removes type field.
URL to access.
The working directory to run the program in.
Join range of multiple values into a string using semicolon as separator. Adds trailing semicolon.
Some keys can have multiple values, separated by semicolon. This function helps to parse such kind of strings into the range.
1 import std.file; 2 //Test DesktopFile 3 string desktopFileContents = 4 `[Desktop Entry] 5 # Comment 6 Name=Double Commander 7 Name[ru]=Двухпанельный коммандер 8 GenericName=File manager 9 GenericName[ru]=Файловый менеджер 10 Comment=Double Commander is a cross platform open source file manager with two panels side by side. 11 Comment[ru]=Double Commander - кроссплатформенный файловый менеджер. 12 Terminal=false 13 Icon=doublecmd 14 Icon[ru]=doublecmd_ru 15 Exec=doublecmd %f 16 TryExec=doublecmd 17 Type=Application 18 Categories=Application;Utility;FileManager; 19 Keywords=folder;manager;disk;filesystem;operations; 20 Actions=OpenDirectory;NotPresented;Settings;NoName; 21 MimeType=inode/directory;application/x-directory; 22 NoDisplay=false 23 Hidden=false 24 StartupNotify=true 25 DBusActivatable=true 26 Path=/opt/doublecmd 27 OnlyShowIn=GNOME;XFCE;LXDE; 28 NotShowIn=KDE; 29 30 [Desktop Action OpenDirectory] 31 Name=Open directory 32 Name[ru]=Открыть папку 33 Icon=open 34 Exec=doublecmd %u 35 36 [NoName] 37 Icon=folder 38 39 [Desktop Action Settings] 40 Name=Settings 41 Name[ru]=Настройки 42 Icon=edit 43 Exec=doublecmd settings 44 45 [Desktop Action Notspecified] 46 Name=Notspecified Action`; 47 48 auto df = new DesktopFile(iniLikeStringReader(desktopFileContents), DesktopFile.ReadOptions.preserveComments); 49 assert(df.name() == "Double Commander"); 50 assert(df.localizedName("ru_RU") == "Двухпанельный коммандер"); 51 assert(df.genericName() == "File manager"); 52 assert(df.localizedGenericName("ru_RU") == "Файловый менеджер"); 53 assert(df.comment() == "Double Commander is a cross platform open source file manager with two panels side by side."); 54 assert(df.localizedComment("ru_RU") == "Double Commander - кроссплатформенный файловый менеджер."); 55 assert(df.iconName() == "doublecmd"); 56 assert(df.localizedIconName("ru_RU") == "doublecmd_ru"); 57 assert(df.tryExecString() == "doublecmd"); 58 assert(!df.terminal()); 59 assert(!df.noDisplay()); 60 assert(!df.hidden()); 61 assert(df.startupNotify()); 62 assert(df.dbusActivable()); 63 assert(df.workingDirectory() == "/opt/doublecmd"); 64 assert(df.type() == DesktopFile.Type.Application); 65 assert(equal(df.keywords(), ["folder", "manager", "disk", "filesystem", "operations"])); 66 assert(equal(df.categories(), ["Application", "Utility", "FileManager"])); 67 assert(equal(df.actions(), ["OpenDirectory", "NotPresented", "Settings", "NoName"])); 68 assert(equal(df.mimeTypes(), ["inode/directory", "application/x-directory"])); 69 assert(equal(df.onlyShowIn(), ["GNOME", "XFCE", "LXDE"])); 70 assert(equal(df.notShowIn(), ["KDE"])); 71 72 assert(equal(df.byAction().map!(desktopAction => 73 tuple(desktopAction.name(), desktopAction.localizedName("ru"), desktopAction.iconName(), desktopAction.execString())), 74 [tuple("Open directory", "Открыть папку", "open", "doublecmd %u"), tuple("Settings", "Настройки", "edit", "doublecmd settings")])); 75 76 assert(df.action("NotPresented").group() is null); 77 assert(df.action("Notspecified").group() is null); 78 assert(df.action("NoName").group() is null); 79 assert(df.action("Settings").group() !is null); 80 81 assert(df.saveToString() == desktopFileContents); 82 83 assert(df.contains("Icon")); 84 df.removeEntry("Icon"); 85 assert(!df.contains("Icon")); 86 df["Icon"] = "files"; 87 assert(df.contains("Icon")); 88 89 df = new DesktopFile(); 90 df.terminal = true; 91 df.type = DesktopFile.Type.Application; 92 df.categories = ["Development", "Compilers"]; 93 94 assert(df.terminal() == true); 95 assert(df.type() == DesktopFile.Type.Application); 96 assert(equal(df.categories(), ["Development", "Compilers"])); 97 98 string contents = 99 `[Not desktop entry] 100 Key=Value`; 101 assertThrown(new DesktopFile(iniLikeStringReader(contents)));
Represents .desktop file.