Skip to content

Commit

Permalink
Remove trailing spaces, update .travis.yml, upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Oct 21, 2017
1 parent 732909a commit 99fae3a
Show file tree
Hide file tree
Showing 14 changed files with 419 additions and 425 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: d
matrix:
allow_failures:
- d: ldc-0.16.1
- d: ldc
include:
- d: dmd-2.069.2
- d: dmd
env: USE_DOVERALLS=true
- d: ldc-0.16.1
- d: ldc

script:
- chmod +x travis-script.sh
- ./travis-script.sh
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,57 +51,57 @@ string[] urls = ...;
try {
auto df = new DesktopFile(filePath);
//Detect current locale.
string locale = environment.get("LC_CTYPE", environment.get("LC_ALL", environment.get("LANG")));
string name = df.localizedDisplayName(locale); //Specific name of the application.
string genericName = df.localizedGenericName(locale); //Generic name of the application. Show it in menu under the specific name.
string comment = df.localizedComment(locale); //Show it as tooltip or description.
string iconName = df.iconName(); //Freedesktop icon name.
if (df.hidden()) {
//User uninstalled desktop file and it should not be shown in menus.
}
string[] onlyShowIn = df.onlyShowIn().array; //If not empty, show this application only in listed desktop environments.
string[] notShowIn = df.notShowIn().array; //Don't show this application in listed desktop environments.
string[] mimeTypes = df.mimeTypes().array; //MIME types supported by application.
string[] categories = df.categories().array; //Menu entries where this application should be shown.
string[] keywords = df.keywords().array; //Keywords can be used to improve searching of the application.
foreach(action; df.byAction()) { //Supported actions.
string actionName = action.localizedDisplayName(locale);
action.start(locale);
}
if (df.type() == DesktopFile.Type.Application) {
//This is application
string commandLine = df.execValue(); //Command line pattern used to start the application.
try {
df.startApplication(urls, locale); //Start application using given arguments and specified locale. It will be automatically started in terminal emulator if required.
}
catch(ProcessException e) { //Failed to start the application.
stderr.writeln(e.msg);
stderr.writeln(e.msg);
}
catch(DesktopExecException e) { //Malformed command line pattern.
stderr.writeln(e.msg);
stderr.writeln(e.msg);
}
} else if (df.type() == DesktopFile.Type.Link) {
//This is link to file or web resource.
string url = df.url(); //URL to open
} else if (df.type() == DesktopFile.Type.Directory) {
//This is directory or menu section description.
} else {
//Type is not defined or unknown, e.g. KDE Service.
string type = df.value("Type"); //Retrieve value manually as string if you know how to deal with non-standard types.
}
}
}
catch (IniLikeException e) { //Parsing error - file is not desktop file or has errors.
stderr.writeln(e.msg);
stderr.writeln(e.msg);
}
```
Expand All @@ -115,35 +115,35 @@ Utility that can parse, execute and rewrites .desktop files.
This will open $HOME/.bashrc in geany text editor:

dub run :util -- exec /usr/share/applications/geany.desktop dub.json

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

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

Additional application actions are supported too:

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

Running of multiple application instances if it does not support handling multiple urls:

dub run :util -- exec /usr/share/applications/leafpad.desktop dub.json README.md

Open link with preferred application:

dub run :util -- open /usr/share/desktop-base/debian-homepage.desktop

Starts .desktop file defined executable or opens link:

dub run :util -- start /path/to/file.desktop

Parse and write .desktop file to new location (for testing purposes):

dub run :util -- write /usr/share/applications/vlc.desktop $HOME/Desktop/vlc.desktop

Read basic information about desktop file:

dub run :util -- read /usr/share/applications/kde4/kate.desktop

When passing base name of desktop file instead of path it's treated like desktop file id and desktop file is searched in system applications paths.

dub run :util -- exec python2.7.desktop
Expand All @@ -158,7 +158,7 @@ Executing .desktop files with complicated Exec lines:

dub run :util -- exec "$HOME/.local/share/applications/wine/Programs/True Remembrance/True Remembrance.desktop" # launcher that was generated by wine
dub run :util -- exec $HOME/TorBrowser/tor-browser_en-US/start-tor-browser.desktop # Tor browser launcher

### [Desktop test](examples/test/source/app.d)

Parses all .desktop files in system's applications paths (usually /usr/local/share/applicatons and /usr/share/applications) and on the user's Desktop.
Expand All @@ -174,20 +174,20 @@ To print all directories examined by desktoptest to stdout, add --verbose flag:
Start desktoptest on specified directories:

dub run :test -- /path/to/applications /anotherpath/to/applications

Example using cmd on Windows (KDE installed):

set KDE_SHARE="%SYSTEMDRIVE%\ProgramData\KDE\share"
dub run :test -- %KDE_SHARE%\applications %KDE_SHARE%\templates %KDE_SHARE%\desktop-directories %KDE_SHARE%\autostart

### [Shoot desktop file](examples/shoot/source/app.d)

Uses the alternative way of starting desktop file. Instead of constructing DesktopFile object it just starts the application or opens link after read enough information from file.

dub run :shoot -- vlc.desktop
dub run :shoot -- python2.7.desktop
dub run :shoot -- geany.desktop dub.json

Running of multiple application instances if it does not support handling multiple urls:

dub run :shoot -- leafpad.desktop dub.json README.md
Expand Down
10 changes: 5 additions & 5 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"copyright": "Copyright © 2015-2016, Roman Chistokhodov",
"authors": ["Roman Chistokhodov"],
"dependencies": {
"inilike": "~>1.0.0",
"xdgpaths" : "~>0.2.2",
"detached" : "~>0.1.1"
"inilike": "~>1.0.3",
"xdgpaths" : "~>0.2.4",
"detached" : "~>0.1.7"
},
"targetName" : "desktopfile",
"targetPath" : "lib",
"targetPath" : "lib",
"targetType" : "library",

"versions" : ["desktopfileFileTest"],
"subPackages" : ["./examples/test", "./examples/util", "./examples/shoot"]
}
10 changes: 5 additions & 5 deletions dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"fileVersion": 1,
"versions": {
"detached": "0.1.1",
"findexecutable": "0.1.0",
"inilike": "1.0.0",
"isfreedesktop": "0.1.0",
"xdgpaths": "0.2.2"
"detached": "0.1.7",
"findexecutable": "0.1.1",
"inilike": "1.0.3",
"isfreedesktop": "0.1.1",
"xdgpaths": "0.2.4"
}
}
10 changes: 5 additions & 5 deletions examples/shoot/dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"fileVersion": 1,
"versions": {
"detached": "0.1.1",
"findexecutable" : "0.1.0",
"inilike": "1.0.0",
"isfreedesktop": "0.1.0",
"xdgpaths": "0.2.2"
"detached": "0.1.7",
"findexecutable": "0.1.1",
"inilike": "1.0.3",
"isfreedesktop": "0.1.1",
"xdgpaths": "0.2.4"
}
}
26 changes: 13 additions & 13 deletions examples/shoot/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ int main(string[] args)
bool onlyExec;
bool notFollow;
string[] appPaths;

getopt(
args,
args,
"onlyExec", "Only start applications, don't open links", &onlyExec,
"notFollow", "Don't follow desktop files", &notFollow,
"appPath", "Path of applications directory", &appPaths);


string inFile;
if (args.length > 1) {
inFile = args[1];
} else {
stderr.writeln("Must provide path to desktop file");
return 1;
}

if (appPaths.length == 0) {
static if (isFreedesktop) {
import desktopfile.paths;
Expand All @@ -37,11 +37,11 @@ int main(string[] args)
appPaths = [kdeAppDir];
}
} catch(Exception e) {

}
}
}

if (inFile == inFile.baseName && inFile.extension == ".desktop") {
string desktopId = inFile;
inFile = findDesktopFile(desktopId, appPaths);
Expand All @@ -50,26 +50,26 @@ int main(string[] args)
return 1;
}
}

ShootOptions options;

options.urls = args[2..$];

if (onlyExec) {
options.flags = options.flags & ~ShootOptions.Link;
}

if (notFollow) {
options.flags = options.flags & ~ ShootOptions.FollowLink;
}

try {
shootDesktopFile(inFile, options);
}
catch(Exception e) {
stderr.writeln(e.msg);
return 1;
}

return 0;
}
2 changes: 1 addition & 1 deletion examples/test/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"authors": ["freeslave"],
"dependencies": {
"desktopfile" : "*",
"standardpaths": "~>0.6.0"
"standardpaths": "~>0.8.0"
},
"targetPath" : "bin",
"targetType" : "executable"
Expand Down
12 changes: 6 additions & 6 deletions examples/test/dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"fileVersion": 1,
"versions": {
"detached": "0.1.1",
"findexecutable": "0.1.0",
"inilike": "1.0.0",
"isfreedesktop": "0.1.0",
"standardpaths": "0.7.0",
"xdgpaths": "0.2.2"
"detached": "0.1.7",
"findexecutable": "0.1.1",
"inilike": "1.0.3",
"isfreedesktop": "0.1.1",
"standardpaths": "0.8.0",
"xdgpaths": "0.2.4"
}
}
18 changes: 9 additions & 9 deletions examples/test/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ import isfreedesktop;
void main(string[] args)
{
string[] desktopDirs;

bool verbose;

getopt(args, "verbose", "Print name of each examined desktop file to standard output", &verbose);

if (args.length > 1) {
desktopDirs = args[1..$];
} else {
static if (isFreedesktop) {
import standardpaths;

string[] dataPaths = standardPaths(StandardPath.data);

desktopDirs = applicationsPaths() ~ dataPaths.map!(s => buildPath(s, "desktop-directories")).array ~ dataPaths.map!(s => buildPath(s, "templates")).array ~ standardPaths(StandardPath.startup) ~ writablePath(StandardPath.desktop);
}

version(Windows) {
try {
auto root = environment.get("SYSTEMDRIVE", "C:");
Expand All @@ -37,17 +37,17 @@ void main(string[] args)
desktopDirs = [buildPath(kdeDir, `applications`), buildPath(kdeDir, `desktop-directories`), buildPath(kdeDir, `templates`), buildPath(kdeDir, `autostart`)];
}
} catch(Exception e) {

}
}
}

if (!desktopDirs.length) {
stderr.writeln("No desktop directories given nor could be detected");
stderr.writefln("Usage: %s [DIRECTORY]...", args[0]);
return;
}

writefln("Using directories: %-(%s, %)", desktopDirs);

foreach(dir; desktopDirs.filter!(s => s.exists && s.isDir())) {
Expand Down
10 changes: 5 additions & 5 deletions examples/util/dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"fileVersion": 1,
"versions": {
"detached": "0.1.1",
"findexecutable" : "0.1.0",
"inilike": "1.0.0",
"isfreedesktop": "0.1.0",
"xdgpaths": "0.2.2"
"detached": "0.1.7",
"findexecutable": "0.1.1",
"inilike": "1.0.3",
"isfreedesktop": "0.1.1",
"xdgpaths": "0.2.4"
}
}

0 comments on commit 99fae3a

Please sign in to comment.