From f72bae02bb846af0091ff083e34325314907ea52 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 15 Jun 2021 16:19:57 +0200 Subject: [DRun] Add advanced parse-user and parse-system config option. --- doc/rofi.1 | 21 +++++++++++++++++++++ doc/rofi.1.markdown | 15 +++++++++++++++ source/dialogs/drun.c | 43 +++++++++++++++++++++++++++---------------- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/doc/rofi.1 b/doc/rofi.1 index 5aaa0bef..7bfebb05 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1257,6 +1257,8 @@ Please see \fBrofi\-theme(5)\fP manpage for more information on theming. .IP \(bu 2 \fB\fCShift\-Enter\fR: Launch the application in a terminal (in run mode) .IP \(bu 2 +\fB\fCCtrl\-Shift\-Enter\fR: As Ctrl\-Enter and run the command in terminal (in run mode) +.IP \(bu 2 \fB\fCShift\-Enter\fR: Return the selected entry and move to the next item while keeping \fBrofi\fP open. (in dmenu) .IP \(bu 2 \fB\fCShift\-Right\fR: Switch to the next mode. The list can be customized with the \fB\fC\-switchers\fR argument. @@ -1338,6 +1340,25 @@ applications using this standard. Some application create invalid desktop files See de debugging section how to get more information from the DRUN mode, this will print why desktop files are discarded. +.PP +There are two advanced options to tweak the behaviour: + +.PP +.RS + +.nf +configuration { + drun { + /** Parse user desktop files. */ + parse\-user: true; + /** Parse system desktop files. */ + parse\-system: false; + } +} + +.fi +.RE + .SS ssh .PP Shows a list of SSH targets based on your \fB\fCssh\fR config file, and allows to quickly \fB\fCssh\fR into them. diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 8ee28f52..51c17642 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -855,6 +855,21 @@ applications using this standard. Some application create invalid desktop files See de debugging section how to get more information from the DRUN mode, this will print why desktop files are discarded. +There are two advanced options to tweak the behaviour: + +```css +configuration { + drun { + /** Parse user desktop files. */ + parse-user: true; + /** Parse system desktop files. */ + parse-system: false; + } +} +``` + + + ### ssh Shows a list of SSH targets based on your `ssh` config file, and allows to quickly `ssh` into them. diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 85c6f8ae..73b51ae4 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -947,30 +947,41 @@ static void get_apps ( DRunModePrivateData *pd ) char *cache_file = g_build_filename ( cache_dir, DRUN_DESKTOP_CACHE_FILE, NULL ); TICK_N ( "Get Desktop apps (start)" ); if ( drun_read_cache ( pd, cache_file ) ) { - gchar *dir; - // First read the user directory. - dir = g_build_filename ( g_get_user_data_dir (), "applications", NULL ); - walk_dir ( pd, dir, dir ); - g_free ( dir ); - TICK_N ( "Get Desktop apps (user dir)" ); - // Then read thee system data dirs. - const gchar * const * sys = g_get_system_data_dirs (); - for ( const gchar * const *iter = sys; *iter != NULL; ++iter ) { + ThemeWidget *wid = rofi_config_find_widget ( drun_mode.name, NULL, TRUE ); + + /** Load user entires */ + Property *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 ); + g_free ( dir ); + TICK_N ( "Get Desktop apps (user dir)" ); + } + + /** Load application entires */ + p = rofi_theme_find_property ( wid, P_BOOLEAN, "parse-system", TRUE ); + if ( p == NULL || ( p->type == P_BOOLEAN && p->value.b )) { + // Then read thee system data dirs. + const gchar * const * sys = g_get_system_data_dirs (); + for ( const gchar * const *iter = sys; *iter != NULL; ++iter ) { gboolean unique = TRUE; // Stupid duplicate detection, better then walking dir. for ( const gchar *const *iterd = sys; iterd != iter; ++iterd ) { - if ( g_strcmp0 ( *iter, *iterd ) == 0 ) { - unique = FALSE; - } + if ( g_strcmp0 ( *iter, *iterd ) == 0 ) { + unique = FALSE; + } } // Check, we seem to be getting empty string... if ( unique && ( **iter ) != '\0' ) { - dir = g_build_filename ( *iter, "applications", NULL ); - walk_dir ( pd, dir, dir ); - g_free ( dir ); + char *dir = g_build_filename ( *iter, "applications", NULL ); + walk_dir ( pd, dir, dir ); + g_free ( dir ); } + } + TICK_N ( "Get Desktop apps (system dirs)" ); } - TICK_N ( "Get Desktop apps (system dirs)" ); get_apps_history ( pd ); g_qsort_with_data ( pd->entry_list, pd->cmd_list_length, sizeof ( DRunModeEntry ), drun_int_sort_list, NULL ); -- cgit v1.2.3