[DRUN] Add drun-display-format.

This commit is contained in:
Dave Davenport 2018-10-17 23:02:50 +02:00
parent f80e7d52bc
commit 76ceac1f20
7 changed files with 62 additions and 12 deletions

View File

@ -116,6 +116,8 @@ Settings config = {
.matching_method = MM_NORMAL,
/** Desktop entry fields to match*/
.drun_match_fields = "name,generic,exec,categories",
/** Desktop format display */
.drun_display_format = "{name} [<span weight='light' size='small'><i>({generic})</i></span>]",
/** Desktop entry show actions */
.drun_show_actions = FALSE,
/** Desktop entry show actions */

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ROFI\-THEME\-SELECTOR" "1" "July 2018" "" ""
.TH "ROFI\-THEME\-SELECTOR" "1" "March 2018" "" ""
.
.SH "NAME"
\fBrofi\-theme\-selector\fR \- Preview and apply themes for \fBrofi\fR

View File

@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "ROFI" "1" "September 2018" "" ""
.TH "ROFI" "1" "October 2018" "" ""
.
.SH "NAME"
\fBrofi\fR \- A window switcher, application launcher, ssh dialog and dmenu replacement
@ -414,6 +414,32 @@ Default: \fIname,generic,exec,categories\fR
.IP "" 0
.
.P
\fB\-drun\-display\-format\fR
.
.P
The format string for the drun dialog:
.
.IP "\(bu" 4
\fBname\fR: the application\'s name
.
.IP "\(bu" 4
\fBgeneric\fR: the application\'s generic name
.
.IP "\(bu" 4
\fBexec\fR: the application\'s executable
.
.IP "\(bu" 4
\fBcategories\fR: the application\'s categories
.
.IP "\(bu" 4
\fBcomment\fR: the application comment
.
.IP
Default: \fI{name} [\fI({generic})\fR]\fR
.
.IP "" 0
.
.P
\fB\-[no\-]drun\-show\-actions\fR
.
.P

View File

@ -227,18 +227,30 @@ Tokenize the input.
`-drun-match-fields` *field1*,*field2*,...
When using drun, match only with the specified Desktop entry fields.
When using drun, match only with the specified Desktop entry fields.
The different fields are:
* **name**: the application's name
* **generic**: the application's generic name
* **exec**: the application's executable
* **exec**: the application's executable
* **categories**: the application's categories
* **comment**: the application comment
* **all**: all of the above
Default: *name,generic,exec,categories*
`-drun-display-format`
The format string for the drun dialog:
* **name**: the application's name
* **generic**: the application's generic name
* **exec**: the application's executable
* **categories**: the application's categories
* **comment**: the application comment
Default: *{name} [<span weight='light' size='small'><i>({generic})</i></span>]*
`-[no-]drun-show-actions`
Show actions present in the Desktop files.
@ -247,12 +259,12 @@ Show actions present in the Desktop files.
`-window-match-fields` *field1*,*field2*,...
When using window mode, match only with the specified fields.
When using window mode, match only with the specified fields.
The different fields are:
* **title**: window's title
* **class**: window's class
* **role**: window's role
* **role**: window's role
* **name**: window's name
* **desktop**: window's current desktop
* **all**: all of the above

View File

@ -118,6 +118,8 @@ typedef struct
char * drun_match_fields;
/** Desktop entry show actions */
unsigned int drun_show_actions;
/** Desktop entry show */
char * drun_display_format;
/** Search case sensitivity */
unsigned int case_sensitive;
/** Cycle through in the element list */

View File

@ -756,13 +756,19 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in
}
/* Free temp storage. */
DRunModeEntry *dr = &( pd->entry_list[selected_line] );
if ( dr->generic_name == NULL ) {
return g_markup_printf_escaped ( "%s", dr->name );
}
else {
return g_markup_printf_escaped ( "%s <span weight='light' size='small'><i>(%s)</i></span>", dr->name,
dr->generic_name );
gchar *cats = NULL;
if ( dr->categories ){
cats = g_strjoinv(",", dr->categories);
}
char *retv = helper_string_replace_if_exists ( config.drun_display_format,
"{generic}", dr->generic_name,
"{name}", dr->name,
"{comment}", dr->comment,
"{exec}", dr->exec,
"{categories}", cats,
NULL);
g_free(cats);
return retv;
}
static cairo_surface_t *_get_icon ( const Mode *sw, unsigned int selected_line, int height )

View File

@ -137,6 +137,8 @@ static XrmOption xrmOptions[] = {
"Desktop entry fields to match in drun", CONFIG_DEFAULT },
{ xrm_Boolean, "drun-show-actions", { .num = &config.drun_show_actions }, NULL,
"Desktop entry show actions.", CONFIG_DEFAULT },
{ xrm_String, "drun-display-format", { .str = &config.drun_display_format }, NULL,
"DRUN format string. (Supports: generic,name,comment,exec,categories)", CONFIG_DEFAULT },
{ xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL,
"Disable history in run/ssh", CONFIG_DEFAULT },
{ xrm_Boolean, "sort", { .num = &config.sort }, NULL,