From 5d53aac20f0cb0737bb475d51ce429e8547d3e33 Mon Sep 17 00:00:00 2001 From: Alex Balgavy Date: Sat, 7 Oct 2023 21:05:46 +0200 Subject: [PATCH] [mod] add hotkeys option to settings.yml The change in the hotkey mechanism introduced in 317db5b04 does not allow configuration via `settings.yml`. This commit adds that functionality. Closes: #2898 --- docs/admin/settings/settings_ui.rst | 4 ++++ searx/preferences.py | 2 +- searx/settings.yml | 2 ++ searx/settings_defaults.py | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/admin/settings/settings_ui.rst b/docs/admin/settings/settings_ui.rst index 0039f6fb2..a5d1076ec 100644 --- a/docs/admin/settings/settings_ui.rst +++ b/docs/admin/settings/settings_ui.rst @@ -20,6 +20,7 @@ theme_args: simple_style: auto search_on_category_select: true + hotkeys: default .. _static_use_hash: @@ -64,3 +65,6 @@ ``search_on_category_select``: Perform search immediately if a category selected. Disable to select multiple categories. + +``hotkeys``: + Hotkeys to use in the search interface: ``default``, ``vim`` (Vim-like). diff --git a/searx/preferences.py b/searx/preferences.py index c65a9b9d0..ad0e2867e 100644 --- a/searx/preferences.py +++ b/searx/preferences.py @@ -466,7 +466,7 @@ class Preferences: locked=is_locked('search_on_category_select') ), 'hotkeys': EnumStringSetting( - 'default', + settings['ui']['hotkeys'], choices=['default', 'vim'] ), # fmt: on diff --git a/searx/settings.yml b/searx/settings.yml index 2e78c8f2d..695b7f812 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -127,6 +127,8 @@ ui: # Perform search immediately if a category selected. # Disable to select multiple categories at once and start the search manually. search_on_category_select: true + # Hotkeys: default or vim + hotkeys: default # Lock arbitrary settings on the preferences page. To find the ID of the user # setting you want to lock, check the ID of the form on the page "preferences". diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index ad45f8617..a0d0daa09 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -201,6 +201,7 @@ SCHEMA = { 'infinite_scroll': SettingsValue(bool, False), 'cache_url': SettingsValue(str, 'https://web.archive.org/web/'), 'search_on_category_select': SettingsValue(bool, True), + 'hotkeys': SettingsValue(('default', 'vim'), 'default'), }, 'preferences': { 'lock': SettingsValue(list, []),