-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.d
44 lines (38 loc) · 1.44 KB
/
list.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
/+dub.sdl:
name "list"
dependency "mimeapps" path="../"
+/
import std.stdio;
import std.algorithm : map;
import desktopfile.paths;
import mimeapps;
void main(string[] args)
{
auto mimeTypes = args[1..$];
auto appPaths = applicationsPaths();
auto provider = new DesktopFileProvider(appPaths);
auto mimeAppsLists = mimeAppsListFiles();
auto mimeInfoCaches = mimeInfoCacheFiles();
writeln("Using application paths: ", appPaths);
writeln("Using mimeapps.list files: ", mimeAppsLists.map!(mimeAppsList => mimeAppsList.fileName));
writeln("Using mimeinfo.cache files: ", mimeInfoCaches.map!(mimeInfoCache => mimeInfoCache.fileName));
foreach(mimeType; mimeTypes) {
auto associatedApps = findAssociatedApplications(mimeType, mimeAppsLists, mimeInfoCaches, provider);
auto defaultApp = findDefaultApplication(mimeType, mimeAppsLists, mimeInfoCaches, provider);
writefln("Default application for %s: ", mimeType);
if (defaultApp is null) {
writeln("\tCould not find default application");
} else {
writefln("\t%s", defaultApp.fileName);
}
writefln("Applications associated with %s: ", mimeType);
if(associatedApps.length) {
foreach(desktopFile; associatedApps) {
writefln("\t%s", desktopFile.fileName);
}
} else {
writeln("\tCould not find any application");
}
writeln();
}
}