diff options
author | Dave Davenport <qball@blame.services> | 2023-01-06 11:54:43 +0100 |
---|---|---|
committer | Dave Davenport <qball@blame.services> | 2023-01-06 11:54:43 +0100 |
commit | 5a29565fc88e350019a8159ae054a4c36b407983 (patch) | |
tree | c20e9e4b3c53ea79a40ec5dc34f9e6d1168f72b1 | |
parent | d786129fd125ebce4116b6b7dcc9ef434c66d073 (diff) |
[filebrowser] Add option to return 1 on cancel.
Fixes: #1732
-rw-r--r-- | doc/rofi.1 | 14 | ||||
-rw-r--r-- | doc/rofi.1.markdown | 8 | ||||
-rw-r--r-- | source/modes/filebrowser.c | 13 |
3 files changed, 33 insertions, 2 deletions
@@ -1155,6 +1155,8 @@ configuration { directories-first: true; /** Show hidden files. */ show-hidden: false; + /** return 1 on cancel. */ + cancel-returns-1: true; } } @@ -1162,6 +1164,18 @@ configuration { .RE .PP +These options can also be passed on the commandline, for example: + +.PP +.RS + +.nf +rofi -filebrowser-cancel-returns-1 true -show filebrowser + +.fi +.RE + +.PP The \fB\fCshow-hidden\fR can also be triggered with the \fB\fCkb-delete-entry\fR keybinding. .SS Other diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index dc1bde35..50838919 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -710,10 +710,18 @@ configuration { directories-first: true; /** Show hidden files. */ show-hidden: false; + /** return 1 on cancel. */ + cancel-returns-1: true; } } ``` +These options can also be passed on the commandline, for example: + +```bash +rofi -filebrowser-cancel-returns-1 true -show filebrowser +``` + The `show-hidden` can also be triggered with the `kb-delete-entry` keybinding. ### Other diff --git a/source/modes/filebrowser.c b/source/modes/filebrowser.c index df3c8c12..9095fc71 100644 --- a/source/modes/filebrowser.c +++ b/source/modes/filebrowser.c @@ -374,12 +374,12 @@ static void file_browser_mode_init_config(Mode *sw) { if (p != NULL && p->type == P_BOOLEAN) { file_browser_config.directories_first = p->value.b; } - + p = rofi_theme_find_property(wid, P_BOOLEAN, "show-hidden", TRUE); if (p != NULL && p->type == P_BOOLEAN) { file_browser_config.show_hidden = p->value.b; } - + if (found_error) { rofi_view_error_dialog(msg, FALSE); @@ -450,6 +450,15 @@ static ModeMode file_browser_mode_result(Mode *sw, int mretv, char **input, FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *)mode_get_private_data(sw); + if ((mretv & MENU_CANCEL) == MENU_CANCEL) { + ThemeWidget *wid = rofi_config_find_widget(sw->name, NULL, TRUE); + Property *p = + rofi_theme_find_property(wid, P_BOOLEAN, "cancel-returns-1", TRUE); + if (p && p->type == P_BOOLEAN && p->value.b == TRUE) { + rofi_set_return_code(1); + } + return MODE_EXIT; + } gboolean special_command = ((mretv & MENU_CUSTOM_ACTION) == MENU_CUSTOM_ACTION); if (mretv & MENU_NEXT) { |