mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[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 commit5c393fb412
Author: Dave Davenport <qball@gmpclient.org> Date: Sat Apr 8 21:14:20 2023 +0200 [DRun] Add option to scan desktop for desktop files
This commit is contained in:
parent
98c213a634
commit
21ac2d1930
3 changed files with 23 additions and 7 deletions
|
@ -1437,7 +1437,7 @@ See the debugging section for more info on DRUN mode, this will print why
|
||||||
desktop files are discarded.
|
desktop files are discarded.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
There are two advanced options to tweak the behaviour:
|
There are a few advanced options to tweak the behaviour:
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
.RS
|
.RS
|
||||||
|
@ -1445,6 +1445,8 @@ There are two advanced options to tweak the behaviour:
|
||||||
.nf
|
.nf
|
||||||
configuration {
|
configuration {
|
||||||
drun {
|
drun {
|
||||||
|
/** Scan the current users desktop for desktop files. */
|
||||||
|
scan-desktop: true;
|
||||||
/** Parse user desktop files. */
|
/** Parse user desktop files. */
|
||||||
parse-user: true;
|
parse-user: true;
|
||||||
/** Parse system desktop files. */
|
/** Parse system desktop files. */
|
||||||
|
|
|
@ -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
|
See the debugging section for more info on DRUN mode, this will print why
|
||||||
desktop files are discarded.
|
desktop files are discarded.
|
||||||
|
|
||||||
There are two advanced options to tweak the behaviour:
|
There are a few advanced options to tweak the behaviour:
|
||||||
|
|
||||||
```css
|
```css
|
||||||
configuration {
|
configuration {
|
||||||
drun {
|
drun {
|
||||||
|
/** Scan the current users desktop for desktop files. */
|
||||||
|
scan-desktop: true;
|
||||||
/** Parse user desktop files. */
|
/** Parse user desktop files. */
|
||||||
parse-user: true;
|
parse-user: true;
|
||||||
/** Parse system desktop files. */
|
/** Parse system desktop files. */
|
||||||
|
|
|
@ -712,7 +712,7 @@ static void read_desktop_file(DRunModePrivateData *pd, const char *root,
|
||||||
* Internal spider used to get list of executables.
|
* Internal spider used to get list of executables.
|
||||||
*/
|
*/
|
||||||
static void walk_dir(DRunModePrivateData *pd, const char *root,
|
static void walk_dir(DRunModePrivateData *pd, const char *root,
|
||||||
const char *dirname) {
|
const char *dirname, const gboolean recursive) {
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
|
|
||||||
g_debug("Checking directory %s for desktop files.", dirname);
|
g_debug("Checking directory %s for desktop files.", dirname);
|
||||||
|
@ -760,7 +760,9 @@ static void walk_dir(DRunModePrivateData *pd, const char *root,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DT_DIR:
|
case DT_DIR:
|
||||||
walk_dir(pd, root, filename);
|
if (recursive) {
|
||||||
|
walk_dir(pd, root, filename, recursive);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1007,13 +1009,23 @@ static void get_apps(DRunModePrivateData *pd) {
|
||||||
if (drun_read_cache(pd, cache_file)) {
|
if (drun_read_cache(pd, cache_file)) {
|
||||||
ThemeWidget *wid = rofi_config_find_widget(drun_mode.name, NULL, TRUE);
|
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 */
|
/** 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)) {
|
if (p == NULL || (p->type == P_BOOLEAN && p->value.b)) {
|
||||||
gchar *dir;
|
gchar *dir;
|
||||||
// First read the user directory.
|
// First read the user directory.
|
||||||
dir = g_build_filename(g_get_user_data_dir(), "applications", NULL);
|
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);
|
g_free(dir);
|
||||||
TICK_N("Get Desktop apps (user 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...
|
// Check, we seem to be getting empty string...
|
||||||
if (unique && (**iter) != '\0') {
|
if (unique && (**iter) != '\0') {
|
||||||
char *dir = g_build_filename(*iter, "applications", NULL);
|
char *dir = g_build_filename(*iter, "applications", NULL);
|
||||||
walk_dir(pd, dir, dir);
|
walk_dir(pd, dir, dir, TRUE);
|
||||||
g_free(dir);
|
g_free(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue