vanadium: firefox search engine for each language

This commit is contained in:
Primrose 2025-06-20 23:52:03 +02:00
parent 26d1f9cf1e
commit 2be0eb8cc6
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -9,12 +9,6 @@
# reference: https://developers.google.com/custom-search/docs/xml_results?hl=zh-tw#advanced-search-query-parameters # reference: https://developers.google.com/custom-search/docs/xml_results?hl=zh-tw#advanced-search-query-parameters
mkLrFlag = languageRestrictions: mkLrFlag = languageRestrictions:
"&lr=" + lib.escapeURL (builtins.concatStringsSep "|" languageRestrictions); "&lr=" + lib.escapeURL (builtins.concatStringsSep "|" languageRestrictions);
mkGlFlag = preferredCountry:
"&gl=" + preferredCountry;
mkHlFlag = hostLanguage:
"&hl=" + hostLanguage;
in { in {
programs.firefox = { programs.firefox = {
enable = true; enable = true;
@ -23,91 +17,91 @@ in {
RequestedLocales = ["fr" "en-US" "zh-TW"]; RequestedLocales = ["fr" "en-US" "zh-TW"];
SearchEngines = { SearchEngines = {
Default = "Google Customized"; Default = "Google EN";
Remove = ["Google"]; Remove = ["Google"];
Add = let Add = let
withGoogleFlags = x: langs = ["lang_fr" "lang_en" "lang_zh-TW"];
x in
+ mkLrFlag ["lang_fr" "lang_en" "lang_zh-TW"] # Google specialized for each language
+ mkGlFlag "fr" map (lang: let
+ mkHlFlag "fr"; shortcode = lib.substring 0 2 (lib.removePrefix "lang_" lang);
in [ in {
# Google and its evil empire™ Name = "Google " + lib.toUpper shortcode;
{ Alias = "G" + shortcode;
Name = "Google Customized";
Alias = "G";
IconURL = "https://google.com/favicon.ico"; IconURL = "https://google.com/favicon.ico";
Description = "Your data yum yum"; Description = "Your data yum yum (but ${shortcode})";
SuggestURLTemplate = withGoogleFlags "https://suggestqueries.google.com/complete/search?q={searchTerms}"; SuggestURLTemplate = "https://suggestqueries.google.com/complete/search?q={searchTerms}" + mkLrFlag [lang];
URLTemplate = withGoogleFlags "https://google.com/search?q={searchTerms}"; URLTemplate = "https://google.com/search?q={searchTerms}" + mkLrFlag [lang];
} })
{ langs
Name = "YouTube"; ++ [
Alias = "yt"; {
IconURL = "https://youtube.com/favicon.ico"; Name = "YouTube";
SuggestURLTemplate = withGoogleFlags "http://suggestqueries.google.com/complete/search?q={searchTerms}&ds=yt"; Alias = "yt";
URLTemplate = withGoogleFlags "https://www.youtube.com/results?search_query={searchTerms}"; IconURL = "https://youtube.com/favicon.ico";
} SuggestURLTemplate = "http://suggestqueries.google.com/complete/search?q={searchTerms}&ds=yt";
URLTemplate = "https://www.youtube.com/results?search_query={searchTerms}";
}
# Forges # Forges
{ {
Name = "GitHub"; Name = "GitHub";
Alias = "ggh"; Alias = "ggh";
IconURL = "https://github.com/favicon.ico"; IconURL = "https://github.com/favicon.ico";
Description = "Your code yum yum"; Description = "Your code yum yum";
URLTemplate = "https://github.com/search?q={searchTerms}&type=repositories"; URLTemplate = "https://github.com/search?q={searchTerms}&type=repositories";
} }
{ {
Name = "GitHub (Code Search)"; Name = "GitHub (Code Search)";
Alias = "gghc"; Alias = "gghc";
IconURL = "https://github.com/favicon.ico"; IconURL = "https://github.com/favicon.ico";
Description = "Your code yum yum"; Description = "Your code yum yum";
URLTemplate = "https://github.com/search?q={searchTerms}&type=code"; URLTemplate = "https://github.com/search?q={searchTerms}&type=code";
} }
{ {
Name = "Codeberg"; Name = "Codeberg";
Alias = "gco"; Alias = "gco";
IconURL = "https://codeberg.org/favicon.ico"; IconURL = "https://codeberg.org/favicon.ico";
Description = "Software development, but free!"; Description = "Software development, but free!";
URLTemplate = "https://codeberg.org/explore/repos?q={searchTerms}"; URLTemplate = "https://codeberg.org/explore/repos?q={searchTerms}";
} }
{ {
Name = "?C"; Name = "?C";
Alias = "gcc"; Alias = "gcc";
IconURL = "https://git.confusedcompiler.org/favicon.ico"; IconURL = "https://git.confusedcompiler.org/favicon.ico";
URLTemplate = "https://git.confusedcompiler.org/explore/repos?q={searchTerms}"; URLTemplate = "https://git.confusedcompiler.org/explore/repos?q={searchTerms}";
} }
# Nix{,OS,pkgs} # Nix{,OS,pkgs}
{ {
Name = "NixOS Search (Package)"; Name = "NixOS Search (Package)";
Alias = "np"; Alias = "np";
IconURL = "https://nixos.org/favicon.ico"; IconURL = "https://nixos.org/favicon.ico";
Description = "Search in nixpkgs"; Description = "Search in nixpkgs";
URLTemplate = "https://search.nixos.org/packages?query={searchTerms}"; URLTemplate = "https://search.nixos.org/packages?query={searchTerms}";
} }
{ {
Name = "NixOS Search (Options)"; Name = "NixOS Search (Options)";
Alias = "no"; Alias = "no";
IconURL = "https://nixos.org/favicon.ico"; IconURL = "https://nixos.org/favicon.ico";
Description = "Search in NixOS options"; Description = "Search in NixOS options";
URLTemplate = "https://search.nixos.org/options?query={searchTerms}"; URLTemplate = "https://search.nixos.org/options?query={searchTerms}";
} }
# Discourse # Discourse
{ {
Name = "NixOS Discourse"; Name = "NixOS Discourse";
Alias = "nd"; Alias = "nd";
IconURL = "https://nixos.org/favicon.ico"; IconURL = "https://nixos.org/favicon.ico";
URLTemplate = "https://discourse.nixos.org/search?q={searchTerms}"; URLTemplate = "https://discourse.nixos.org/search?q={searchTerms}";
} }
{ {
Name = "Framework Discourse"; Name = "Framework Discourse";
Alias = "fd"; Alias = "fd";
IconURL = "https://frame.work/favicon.ico"; IconURL = "https://frame.work/favicon.ico";
URLTemplate = "https://community.frame.work/search?q={searchTerms}"; URLTemplate = "https://community.frame.work/search?q={searchTerms}";
} }
]; ];
}; };
}; };