diff options
author | Dave Davenport <qball@gmpclient.org> | 2023-04-22 21:50:20 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2023-04-22 21:50:20 +0200 |
commit | 21ac2d1930a418053c9c29df713f97921ec9b259 (patch) | |
tree | a174bf1302bd8d2cd1c21cb2754baecd58ce9380 | |
parent | 98c213a63427b963842d876645d1424f1fecdb8b (diff) |
[DRun] Add option to scan desktop directory for desktop files.
Squashed commit of the following:
commit ac12b66d86b36aaf349c15a5c8dab00a553a641f
Merge: 5c393fb4 98c213a6
Author: Dave Davenport <qball@gmpclient.org>
Date: Sat Apr 22 21:48:24 2023 +0200
Merge remote-tracking branch 'origin/next' into scan-desktop
commit 5c393fb4120e842d609e6d4366b1e0b822f66d7f
Author: Dave Davenport <qball@gmpclient.org>
Date: Sat Apr 8 21:14:20 2023 +0200
[DRun] Add option to scan desktop for desktop files
-rw-r--r-- | doc/rofi.1 | 4 | ||||
-rw-r--r-- | doc/rofi.1.markdown | 4 | ||||
-rw-r--r-- | source/modes/drun.c | 22 |
3 files changed, 23 insertions, 7 deletions
@@ -1437,7 +1437,7 @@ See the debugging section for more info on DRUN mode, this will print why desktop files are discarded. .PP -There are two advanced options to tweak the behaviour: +There are a few advanced options to tweak the behaviour: .PP .RS @@ -1445,6 +1445,8 @@ There are two advanced options to tweak the behaviour: .nf configuration { drun { + /** Scan the current users desktop for desktop files. */ + scan-desktop: true; /** Parse user desktop files. */ parse-user: true; /** Parse system desktop files. */ diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 052452d5..6801c102 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -961,11 +961,13 @@ applications create invalid desktop files, **rofi** will discard these entries. See the debugging section for more info on DRUN mode, this will print why desktop files are discarded. -There are two advanced options to tweak the behaviour: +There are a few advanced options to tweak the behaviour: ```css configuration { drun { + /** Scan the current users desktop for desktop files. */ + scan-desktop: true; /** Parse user desktop files. */ parse-user: true; /** Parse system desktop files. */ diff --git a/source/modes/drun.c b/source/modes/drun.c index dced6db7..635fed7b 100644 --- a/source/modes/drun.c +++ b/source/modes/drun.c @@ -712,7 +712,7 @@ static void read_desktop_file(DRunModePrivateData *pd, const char *root, * Internal spider used to get list of executables. */ static void walk_dir(DRunModePrivateData *pd, const char *root, - const char *dirname) { + const char *dirname, const gboolean recursive) { DIR *dir; g_debug("Checking directory %s for desktop files.", dirname); @@ -760,7 +760,9 @@ static void walk_dir(DRunModePrivateData *pd, const char *root, } break; case DT_DIR: - walk_dir(pd, root, filename); + if (recursive) { + walk_dir(pd, root, filename, recursive); + } break; default: break; @@ -1007,13 +1009,23 @@ static void get_apps(DRunModePrivateData *pd) { if (drun_read_cache(pd, cache_file)) { ThemeWidget *wid = rofi_config_find_widget(drun_mode.name, NULL, TRUE); + /** Load desktop entries */ + Property *p = + rofi_theme_find_property(wid, P_BOOLEAN, "scan-desktop", FALSE); + if (p != NULL && (p->type == P_BOOLEAN && p->value.b)) { + const gchar *dir; + // First read the user directory. + dir = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP); + walk_dir(pd, dir, dir, FALSE); + TICK_N("Get Desktop dir apps"); + } /** Load user entires */ - Property *p = rofi_theme_find_property(wid, P_BOOLEAN, "parse-user", TRUE); + p = rofi_theme_find_property(wid, P_BOOLEAN, "parse-user", TRUE); if (p == NULL || (p->type == P_BOOLEAN && p->value.b)) { gchar *dir; // First read the user directory. dir = g_build_filename(g_get_user_data_dir(), "applications", NULL); - walk_dir(pd, dir, dir); + walk_dir(pd, dir, dir, TRUE); g_free(dir); TICK_N("Get Desktop apps (user dir)"); } @@ -1034,7 +1046,7 @@ static void get_apps(DRunModePrivateData *pd) { // Check, we seem to be getting empty string... if (unique && (**iter) != '\0') { char *dir = g_build_filename(*iter, "applications", NULL); - walk_dir(pd, dir, dir); + walk_dir(pd, dir, dir, TRUE); g_free(dir); } } |