From ebd1a1aabba6fee235034ef7668c24a32525c51c Mon Sep 17 00:00:00 2001 From: ene Date: Sat, 11 Mar 2023 11:43:50 +0100 Subject: Fix(hm/conf/firefox): Move bookmarks to the toolbar --- home-manager/config/firefox/default.nix | 73 ++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 11 deletions(-) (limited to 'home-manager/config/firefox/default.nix') diff --git a/home-manager/config/firefox/default.nix b/home-manager/config/firefox/default.nix index d07895a6..a5201388 100644 --- a/home-manager/config/firefox/default.nix +++ b/home-manager/config/firefox/default.nix @@ -9,6 +9,63 @@ system, ... }: let + bookmarks = [ + { + name = "Feed - Piped"; + url = "https://piped.video/feed"; + } + + { + name = "DeepL Translate"; + url = "https://www.deepl.com/translator#en/de/test"; + } + ]; + firefoxBookmarksFile = bookmarks: let + indent = level: + lib.concatStringsSep "" (map (lib.const " ") (lib.range 1 level)); + + bookmarkToHTML = indentLevel: bookmark: '' + ${indent indentLevel}
${lib.escapeXML bookmark.name}''; + + directoryToHTML = indentLevel: directory: '' + ${indent indentLevel}
${ + if directory.toolbar + then ''

Bookmarks Toolbar'' + else "

${lib.escapeXML directory.name}" + }

+ ${indent indentLevel}

+ ${allItemsToHTML (indentLevel + 1) directory.bookmarks} + ${indent indentLevel}

''; + + itemToHTMLOrRecurse = indentLevel: item: + if item ? "url" + then bookmarkToHTML indentLevel item + else directoryToHTML indentLevel item; + + allItemsToHTML = indentLevel: bookmarks: + lib.concatStringsSep "\n" + (map (itemToHTMLOrRecurse indentLevel) bookmarks); + + bookmarkEntries = allItemsToHTML 1 bookmarks; + in + pkgs.writeText "firefox-bookmarks.html" '' + + + + Bookmarks +

Bookmarks Menu

+ +

+

Bookmarks Toolbar

+

+ ${bookmarkEntries} +

+

+ ''; userChrome = builtins.readFile ./chrome/userChrome.css; user_js_override = pkgs.writeText "user.override.js" (builtins.readFile ./settings/override.js); @@ -18,6 +75,10 @@ cat "${user_js_override}" >> $out/user.js; cat << EOF >> $out/user.js; + // My bookmarks + user_pref("browser.bookmarks.file", "${toString (firefoxBookmarksFile bookmarks)}"); + user_pref("browser.places.importBookmarksHTML", true); + // Allow my custom css user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true); @@ -208,17 +269,7 @@ in { }; }; - bookmarks = [ - { - name = "Feed - Piped"; - url = "https://piped.video/feed"; - } - - { - name = "DeepL Translate"; - url = "https://www.deepl.com/translator#en/de/test"; - } - ]; + bookmarks = []; inherit settings; extraConfig = builtins.readFile "${user_js_nix}/user.js"; }; -- cgit 1.4.1