[DRun] Add advanced parse-user and parse-system config option.

This commit is contained in:
Dave Davenport 2021-06-15 16:19:57 +02:00 committed by Dave Davenport
parent 22b7228ea6
commit 4f3ee061a1
3 changed files with 63 additions and 16 deletions

View File

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

View File

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

View File

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