1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[DRun] Add option to scan desktop for desktop files

This commit is contained in:
Dave Davenport 2023-04-08 21:14:20 +02:00
parent 0133697fd2
commit 5c393fb412
3 changed files with 23 additions and 7 deletions

View file

@ -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. */

View file

@ -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. */

View file

@ -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);
}
}