diff --git a/Changelog b/Changelog index 5f99b88e..dd9ffaaf 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,7 @@ - Word movement in entry box. (#126) - PID file to avoid duplicate Rofi. - Generic keybinding and launching for modi. (#128) + - Auto select mode (previously called zeltak mode) Bug fixes: - Shift left/right movement between modi (#125) - Document updates (#123,#116,#124,etc.) diff --git a/config/config.def.c b/config/config.def.c index 6ddea334..ac698b14 100644 --- a/config/config.def.c +++ b/config/config.def.c @@ -102,6 +102,8 @@ Settings config = { /** Sidebar mode, show the switchers */ .sidebar_mode = FALSE, /** Lazy mode setting */ - .lazy_filter_limit = 5000 + .lazy_filter_limit = 5000, + /** auto select */ + .auto_select = FALSE }; diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 45a907fa..0727af02 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -43,6 +43,7 @@ rofi - A window switcher, run dialog and dmenu replacement [ -version ] [ -help] [ -dump-xresources ] +[ -auto-select ] ## DESCRIPTION @@ -267,6 +268,10 @@ daemon listening to specific key-combinations. Default: *5000* +`-auto-select` + + When one entry is left, automatically select this. + ### PATTERN setting `-terminal` diff --git a/doc/rofi.1 b/doc/rofi.1 index acb516b5..5bec76e2 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -41,6 +41,7 @@ rofi \- A window switcher, run dialog and dmenu replacement [ \-version ] [ \-help] [ \-dump\-xresources ] +[ \-auto\-select ] .SH DESCRIPTION .PP \fBrofi\fP is an X11 popup window switcher, run dialog, dmenu replacement and more. It focusses on @@ -340,6 +341,14 @@ To show sidebar use: for 250ms. Experiments shows that the default (5000 lines) works well, set to 0 to always enable. .PP Default: \fI5000\fP +.PP +\fB\fC\-auto\-select\fR +.PP +.RS +.nf +When one entry is left, automatically select this. +.fi +.RE .SS PATTERN setting .PP \fB\fC\-terminal\fR diff --git a/include/rofi.h b/include/rofi.h index 1e5b0a7d..74999a4a 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -198,6 +198,8 @@ typedef struct _Settings unsigned int sidebar_mode; /** Lazy filter limit. */ unsigned int lazy_filter_limit; + /** Auto select. */ + unsigned int auto_select; } Settings; /** Global Settings structure. */ diff --git a/source/rofi.c b/source/rofi.c index a2f05d6c..77b945fc 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -788,6 +788,12 @@ static void menu_refilter ( MenuState *state, char **lines, menu_match_cb mmc, v } state->selected = MIN ( state->selected, state->filtered_lines - 1 ); + if ( config.auto_select == TRUE && state->filtered_lines == 1 ) { + *( state->selected_line ) = state->line_map[state->selected]; + state->retv = MENU_OK; + state->quit = TRUE; + } + state->refilter = FALSE; } diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 829e1b86..32b3d68d 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -103,7 +103,8 @@ static XrmOption xrmOptions[] = { { xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL }, { xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL }, { xrm_Number, "lazy-filter-limit", { .num = &config.lazy_filter_limit }, NULL }, - { xrm_SNumber, "eh", { .snum = &config.element_height }, NULL } + { xrm_SNumber, "eh", { .snum = &config.element_height }, NULL }, + { xrm_Boolean, "auto-select", { .num = &config.auto_select }, NULL } }; // Dynamic options.