Skip to content

Commit

Permalink
Examples as single file packages. Remove dub.selections.json
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed May 4, 2018
1 parent 499fc15 commit 96b175a
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 122 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ bin/
lib/
docs/
*.lst
dub.selections.json
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,91 +108,91 @@ catch (IniLikeException e) { //Parsing error - file is not desktop file or has e

## Examples

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

Utility that can parse, execute and rewrites .desktop files.
Utility that can parse, execute and rewrite .desktop files.

This will open $HOME/.bashrc in geany text editor:
This will open dub.json in geany text editor:

dub run :util -- exec /usr/share/applications/geany.desktop dub.json
dub examples/util.d 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
dub examples/util.d exec /usr/share/applications/python2.7.desktop

Additional application actions are supported too:

dub run :util -- exec /usr/share/applications/steam.desktop --action=Settings
dub examples/util.d 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
dub examples/util.d exec /usr/share/applications/leafpad.desktop dub.json README.md

Open link with preferred application:
Open a link with preferred application:

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

Starts .desktop file defined executable or opens link:
Looks up the .desktop file type and executes it if it's an application or opens a link if it's a link.

dub run :util -- start /path/to/file.desktop
dub examples/util.d 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
dub examples/util.d 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
dub examples/util.d 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
dub run :util -- exec kde4-kate.desktop
dub examples/util.d exec python2.7.desktop
dub examples/util.d exec kde4-kate.desktop

On non-freedesktop systems appPath should be passed and PATH variable prepared. Example using cmd on Windows (KDE installed):

set PATH=C:\ProgramData\KDE\bin
dub run :util -- --appPath=C:\ProgramData\KDE\share\applications exec kde4-gwenview.desktop
dub examples/util.d --appPath=C:\ProgramData\KDE\share\applications exec kde4-gwenview.desktop

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
dub examples/util.d exec "$HOME/.local/share/applications/wine/Programs/True Remembrance/True Remembrance.desktop" # launcher that was generated by wine
dub examples/util.d exec $HOME/TorBrowser/tor-browser_en-US/start-tor-browser.desktop # Tor browser launcher

### [Desktop test](examples/test/source/app.d)
### [Desktop test](examples/test.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.
Writes errors (if any) to stderr.
Use this example to check if the desktopfile library can parse all .desktop files on your system.

dub run :test
dub examples/test.d

To print all directories examined by desktoptest to stdout, add --verbose flag:

dub run :test -- --verbose
dub examples/test.d --verbose

Start desktoptest on specified directories:

dub run :test -- /path/to/applications /anotherpath/to/applications
dub examples/test.d -- /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
dub examples/test.d -- %KDE_SHARE%\applications %KDE_SHARE%\templates %KDE_SHARE%\desktop-directories %KDE_SHARE%\autostart

### [Shoot desktop file](examples/shoot/source/app.d)
### [Fire desktop file](examples/fire.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.
Uses the alternative way of starting desktop file. Instead of constructing DesktopFile object it just starts a referenced application or opens a link after it read enough information from file.

dub run :shoot -- vlc.desktop
dub run :shoot -- python2.7.desktop
dub run :shoot -- geany.desktop dub.json
dub examples/fire.d vlc.desktop
dub examples/fire.d python2.7.desktop
dub examples/fire.d 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
dub examples/fire.d leafpad.desktop dub.json README.md

On Windows (KDE installed):

set PATH=C:\ProgramData\KDE\bin;%PATH%
dub run :shoot -- C:\ProgramData\KDE\share\applications\kde4\gwenview.desktop
dub examples/fire.d C:\ProgramData\KDE\share\applications\kde4\gwenview.desktop
3 changes: 1 addition & 2 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
"targetName" : "desktopfile",
"targetPath" : "lib",
"targetType" : "library",
"versions" : ["desktopfileFileTest"],
"subPackages" : ["./examples/test", "./examples/util", "./examples/shoot"]
"versions" : ["desktopfileFileTest"]
}
10 changes: 0 additions & 10 deletions dub.selections.json

This file was deleted.

5 changes: 5 additions & 0 deletions examples/shoot/source/app.d → examples/fire.d
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/+dub.sdl:
name "shoot"
dependency "desktopfile" path="../"
+/

import std.stdio;
import std.getopt;

Expand Down
5 changes: 0 additions & 5 deletions examples/shoot/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions examples/shoot/dub.json

This file was deleted.

10 changes: 0 additions & 10 deletions examples/shoot/dub.selections.json

This file was deleted.

6 changes: 6 additions & 0 deletions examples/test/source/app.d → examples/test.d
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/+dub.sdl:
name "test"
dependency "desktopfile" path="../"
dependency "standardpaths" version="~>0.8.0"
+/

import std.stdio;
import std.algorithm;
import std.array;
Expand Down
5 changes: 0 additions & 5 deletions examples/test/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions examples/test/dub.json

This file was deleted.

11 changes: 0 additions & 11 deletions examples/test/dub.selections.json

This file was deleted.

5 changes: 5 additions & 0 deletions examples/util/source/app.d → examples/util.d
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/+dub.sdl:
name "util"
dependency "desktopfile" path="../"
+/

import std.stdio;
import std.getopt;
import std.process;
Expand Down
5 changes: 0 additions & 5 deletions examples/util/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions examples/util/dub.json

This file was deleted.

10 changes: 0 additions & 10 deletions examples/util/dub.selections.json

This file was deleted.

0 comments on commit 96b175a

Please sign in to comment.