Skip to content

Commit

Permalink
Better coverage and action example
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Aug 23, 2015
1 parent 6a3e6de commit b0a807e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ This will start vlc with the first parameter set to $HOME/Music:

dub run desktopfile:desktoputil -- exec /usr/share/applications/vlc.desktop $HOME/Music

Should start command line application in terminal emulator (will be detected automatically):
This should start command line application in terminal emulator (will be detected automatically):

dub run desktopfile:desktoputil -- exec /usr/share/applications/python2.7.desktop

Run in specific terminal emulator:

dub run desktopfile:desktoputil -- exec /usr/share/applications/python2.7.desktop --term=xterm

Additional application actions are supported too:

dub run desktopfile:desktoputil -- exec /usr/share/applications/steam.desktop --action=Settings

Open link with preferred application:

Expand Down
20 changes: 14 additions & 6 deletions source/desktopfile.d
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@ public:
return null;
}

///
unittest
{
string contents =
`[Desktop Entry]
Name=Program
Type=Application`;
auto df = new DesktopFile(iniLikeStringReader(contents), DesktopFile.ReadOptions.noOptions, "/usr/share/applications/de/example.desktop");
assert(df.id() == "de-example.desktop");
}

/**
* Generic name of the application, for example "Web Browser".
* Returns: The value associated with "GenericName" key.
Expand Down Expand Up @@ -697,10 +708,7 @@ public:
} else if (token == "%c") {
toReturn ~= localizedName(locale);
} else if (token == "%k") {
auto fileStr = fileName();
if (fileStr.length) {
toReturn ~= fileStr;
}
toReturn ~= fileName();
} else if (token == "%d" || token == "%D" || token == "%n" || token == "%N" || token == "%m" || token == "%v") {
continue;
} else {
Expand All @@ -718,11 +726,11 @@ public:
`[Desktop Entry]
Name=Program
Name[ru]=Программа
Exec=program %i -w %c -f %k %U %D
Exec=program %i -w %c -f %k %U %D %u %f %F
Icon=folder`;
auto df = new DesktopFile(iniLikeStringReader(contents), DesktopFile.ReadOptions.noOptions, "/example.desktop");
assert(df.expandExecString(["one", "two"], "ru") ==
["program", "--icon", "folder", "-w", "Программа", "-f", "/example.desktop", "one", "two"]);
["program", "--icon", "folder", "-w", "Программа", "-f", "/example.desktop", "one", "two", "one", "one", "one", "two"]);
}

/**
Expand Down

0 comments on commit b0a807e

Please sign in to comment.