-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
46 lines (38 loc) · 963 Bytes
/
app.go
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
package LinuxApps
type AppInfo struct {
Name string
Description string
IconName string
ExecName string
}
func GetApps() []*AppInfo {
desktopFilesPaths := getEnvPaths()
// Get all desktop, visible, files
desktopFiles := getDesktopFiles(DesktopFilesPath)
for _, path := range desktopFilesPaths {
desktopFiles = append(desktopFiles, getDesktopFiles(path)...)
}
desktopOverrideFiles := getDesktopFiles(DesktopFilesOverridePath)
appsMap := make(map[string]*AppInfo, 0)
for _, file := range desktopFiles {
appInfo, err := decodeDesktopFile(file)
if err != nil {
continue
}
if appsMap[appInfo.ExecName] == nil {
appsMap[appInfo.ExecName] = appInfo
}
}
for _, file := range desktopOverrideFiles {
appInfo, err := decodeDesktopFile(file)
if err != nil {
continue
}
appsMap[appInfo.ExecName] = appInfo
}
apps := make([]*AppInfo, 0)
for _, app := range appsMap {
apps = append(apps, app)
}
return apps
}