From e66b0d54d03202e183458481fb76cad017d9115a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Fri, 30 May 2025 13:59:10 +0200 Subject: [PATCH] vanadium: use parameterized google search engine --- nix/configurations/vanadium/home/firefox.nix | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/nix/configurations/vanadium/home/firefox.nix b/nix/configurations/vanadium/home/firefox.nix index 42373181..bc3fef14 100644 --- a/nix/configurations/vanadium/home/firefox.nix +++ b/nix/configurations/vanadium/home/firefox.nix @@ -1,20 +1,44 @@ { pkgs, config, + lib, ... }: let inherit (pkgs) nur; + + # reference: https://developers.google.com/custom-search/docs/xml_results?hl=zh-tw#advanced-search-query-parameters + mkLrFlag = languageRestrictions: + "&lr=" + lib.escapeURL (builtins.concatStringsSep "|" languageRestrictions); + + mkGlFlag = preferredCountry: + "&gl=" + preferredCountry; + + mkHlFlag = hostLanguage: + "&hl=" + hostLanguage; in { programs.firefox = { enable = true; policies.SearchEngines = { - Default = "searxng"; + Default = "Google Customized"; Add = [ + /* + searxng doesn't + - have good multilingual search support + - use google backend on my server for some reason + */ { Name = "searxng"; URLTemplate = "https://sxng.confusedcompiler.org/search?q={searchTerms}"; } + { + Name = "Google Customized"; + URLTemplate = + "https://google.com/search?q={searchTerms}" + + mkLrFlag ["lang_fr" "lang_en" "lang_zh-TW"] + + mkGlFlag "fr" + + mkHlFlag "fr"; + } ]; };