-
Notifications
You must be signed in to change notification settings - Fork 1
/
fire.d
80 lines (65 loc) · 1.8 KB
/
fire.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/+dub.sdl:
name "shoot"
dependency "desktopfile" path="../"
+/
import std.stdio;
import std.getopt;
import desktopfile.utils;
int main(string[] args)
{
bool onlyExec;
bool notFollow;
string[] appPaths;
getopt(
args,
"onlyExec", "Only start applications, don't open links", &onlyExec,
"notFollow", "Don't follow desktop files", ¬Follow,
"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;
appPaths = applicationsPaths();
}
version(Windows) {
try {
auto root = environment.get("SYSTEMDRIVE", "C:");
auto kdeAppDir = root ~ `\ProgramData\KDE\share\applications`;
if (kdeAppDir.isDir) {
appPaths = [kdeAppDir];
}
} catch(Exception e) {
}
}
}
if (inFile == inFile.baseName && inFile.extension == ".desktop") {
string desktopId = inFile;
inFile = findDesktopFile(desktopId, appPaths);
if (inFile is null) {
stderr.writeln("Could not find desktop file with such id: ", desktopId);
return 1;
}
}
FireOptions options;
options.urls = args[2..$];
if (onlyExec) {
options.flags = options.flags & ~FireOptions.Link;
}
if (notFollow) {
options.flags = options.flags & ~FireOptions.FollowLink;
}
try {
fireDesktopFile(inFile, options);
}
catch(Exception e) {
stderr.writeln(e.msg);
return 1;
}
return 0;
}