Skip to content

Commit aa2fddf

Browse files
jacobgkaujackpot51
authored andcommitted
Check XDG_DATA_HOME in addition to XDG_DATA_DIRS, label results by location
1 parent 93634d6 commit aa2fddf

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/dialog_launcher.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const { Clutter, Gio, GLib, Meta } = imports.gi
2121
const { OK } = result;
2222

2323
const HOME_DIR: string = GLib.get_home_dir();
24-
const DATA_DIRS: string = GLib.get_system_data_dirs();
24+
const DATA_DIRS_SYSTEM: string = GLib.get_system_data_dirs();
25+
const DATA_DIRS_USER: string = GLib.get_user_data_dir();
2526

2627
export class Launcher extends search.Search {
2728
options: Array<launch.SearchOption>
@@ -320,14 +321,29 @@ export class Launcher extends search.Search {
320321
load_desktop_files() {
321322
lib.bench("load_desktop_files", () => {
322323
this.desktop_apps.splice(0);
323-
for (const _path of DATA_DIRS) {
324+
for (const _path of DATA_DIRS_USER.split().concat(DATA_DIRS_SYSTEM)) {
324325
const path = _path.replace(/\/$/, '') + "/applications";
325326
for (const result of app_info.load_desktop_entries(path)) {
326327
if (result.kind == OK) {
327328
const value = result.value;
328329
const existAt = this.desktop_apps.findIndex(([ _, app ]) => app.exec() == value.exec());
329330
if (existAt == -1) {
330-
this.desktop_apps.push(['System', value]);
331+
let appType = 'System';
332+
switch (path) {
333+
case (HOME_DIR + "/.local/share/applications"):
334+
appType = 'User';
335+
break;
336+
case ("/var/lib/flatpak/exports/share/applications"):
337+
appType = 'Flatpak (System)';
338+
break;
339+
case (HOME_DIR + "/.local/share/flatpak/exports/share/applications"):
340+
appType = 'Flatpak (User)';
341+
break;
342+
case ("/var/lib/snapd/desktop/applications"):
343+
appType = 'Snap (System)';
344+
break;
345+
}
346+
this.desktop_apps.push([appType, value]);
331347
}
332348
} else {
333349
const why = result.value;

0 commit comments

Comments
 (0)