1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

[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
parent 74ef588d4e
commit f72bae02bb
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 .IP \(bu 2
\fB\fCShift\-Enter\fR: Launch the application in a terminal (in run mode) \fB\fCShift\-Enter\fR: Launch the application in a terminal (in run mode)
.IP \(bu 2 .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) \fB\fCShift\-Enter\fR: Return the selected entry and move to the next item while keeping \fBrofi\fP open. (in dmenu)
.IP \(bu 2 .IP \(bu 2
\fB\fCShift\-Right\fR: Switch to the next mode. The list can be customized with the \fB\fC\-switchers\fR argument. \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 See de debugging section how to get more information from the DRUN mode, this will print why desktop files are
discarded. 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 .SS ssh
.PP .PP
Shows a list of SSH targets based on your \fB\fCssh\fR config file, and allows to quickly \fB\fCssh\fR into them. 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 See de debugging section how to get more information from the DRUN mode, this will print why desktop files are
discarded. 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 ### ssh
Shows a list of SSH targets based on your `ssh` config file, and allows to quickly `ssh` into them. 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 ); char *cache_file = g_build_filename ( cache_dir, DRUN_DESKTOP_CACHE_FILE, NULL );
TICK_N ( "Get Desktop apps (start)" ); TICK_N ( "Get Desktop apps (start)" );
if ( drun_read_cache ( pd, cache_file ) ) { if ( drun_read_cache ( pd, cache_file ) ) {
gchar *dir; ThemeWidget *wid = rofi_config_find_widget ( drun_mode.name, NULL, TRUE );
// First read the user directory.
dir = g_build_filename ( g_get_user_data_dir (), "applications", NULL ); /** Load user entires */
walk_dir ( pd, dir, dir ); Property *p = rofi_theme_find_property ( wid, P_BOOLEAN, "parse-user", TRUE );
g_free ( dir ); if ( p == NULL || ( p->type == P_BOOLEAN && p->value.b )) {
TICK_N ( "Get Desktop apps (user dir)" ); gchar *dir;
// Then read thee system data dirs. // First read the user directory.
const gchar * const * sys = g_get_system_data_dirs (); dir = g_build_filename ( g_get_user_data_dir (), "applications", NULL );
for ( const gchar * const *iter = sys; *iter != NULL; ++iter ) { 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; gboolean unique = TRUE;
// Stupid duplicate detection, better then walking dir. // Stupid duplicate detection, better then walking dir.
for ( const gchar *const *iterd = sys; iterd != iter; ++iterd ) { for ( const gchar *const *iterd = sys; iterd != iter; ++iterd ) {
if ( g_strcmp0 ( *iter, *iterd ) == 0 ) { if ( g_strcmp0 ( *iter, *iterd ) == 0 ) {
unique = FALSE; unique = FALSE;
} }
} }
// Check, we seem to be getting empty string... // Check, we seem to be getting empty string...
if ( unique && ( **iter ) != '\0' ) { if ( unique && ( **iter ) != '\0' ) {
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 );
g_free ( dir ); g_free ( dir );
} }
}
TICK_N ( "Get Desktop apps (system dirs)" );
} }
TICK_N ( "Get Desktop apps (system dirs)" );
get_apps_history ( pd ); get_apps_history ( pd );
g_qsort_with_data ( pd->entry_list, pd->cmd_list_length, sizeof ( DRunModeEntry ), drun_int_sort_list, NULL ); g_qsort_with_data ( pd->entry_list, pd->cmd_list_length, sizeof ( DRunModeEntry ), drun_int_sort_list, NULL );