summaryrefslogtreecommitdiff
path: root/home/config/firefox/default.nix
blob: 6885251b7a449233bec3aff49c6aa206dbce4f5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{ pkgs, lib, config, fetchurl, stdenv, ... }:

with lib;
let
  mkUserJs = prefs: ''
    ${concatStrings (mapAttrsToList (name: value: ''
      user_pref("${name}", ${builtins.toJSON value});
    '') prefs)}
  '';
  config-template =
    builtins.readFile "${pkgs.personal.firefoxPackages.arkenfox-userjs}";
  config-default = config-template + mkUserJs {
    "browser.shell.checkDefaultBrowser" = true; # 0101
    "keyword.enabled" = true; # 0801
    "signon.rememberSignons" = false; # 0901
    "security.nocertdb" = true; # 1222
    "dom.allow_cut_copy" = true; # 2404
    "dom.battery.enabled" = false; # 2502
    "dom.vr.enabled" = false; # 2520
    "permissions.default.xr" = 2; # 2521

    # Personal
    "browser.tabs.warnOnClose" = false;
    "browser.tabs.warnOnCloseOtherTabs" = false;
    "clipboard.autocopy" = false;
    "browser.quitShortcut.disabled" = true;
    "browser.tabs.closeWindowWithLastTab" = false;
    "extensions.pocket.enabled" = false;
    "identity.fxaccounts.enabled" = false;
    "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
  };

  userchrome-treestyletabs = ''
    /* Hide main tabs toolbar */
    #TabsToolbar {
    visibility: collapse;
    }
    /* Sidebar min and max width removal */
    #sidebar {
    max-width: none !important;
    min-width: 0px !important;
    }
    /* Hide sidebar header, when using Tree Style Tab. */
    #sidebar-box[sidebarcommand="treestyletab_piro_sakura_ne_jp-sidebar-action"] #sidebar-header {
    visibility: collapse;
    }
  '';

in {
  programs.firefox = {
    enable = true;

    extensions = attrValues pkgs.personal.firefoxPackages.addons;
    # to add :
    # floccus + LoFloccus
    # Zotero

    profiles = {
      default = {
        id = 0; # isDefault = true

        extraConfig = config-default;
        userChrome = userchrome-treestyletabs;
      };

      # For video streaming
      streaming = {
        id = 1;

        extraConfig = config-default + mkUserJs {
          # Widevine (DRMs)
          "media.gmp-widevinecdm.enabled" = true;
          "media.eme.enabled" = true;
          # Cache
          "browser.cache.disk.enable" = true;
          "browser.cache.offline.storage" = true;
          # Privacy
          "privacy.clearOnShutdown.cache" = false;
          "privacy.clearOnShutdown.cookies" = false;
          "privacy.clearOnShutdown.siteSettings" = false;
        };
        userChrome = userchrome-treestyletabs;
      };

      videoconferencing = {
        id = 2;

        extraConfig = config-default + mkUserJs {
          # IMPORTANT: uncheck "Prevent WebRTC from leaking local IP addresses" in uBlock Origin's settings
          # NOTE: if using RFP (4501)
          # some sites, e.g. Zoom, need a canvas site exception [Right Click>View Page Info>Permissions]
          # Discord video does not work: it thinks you are FF78: use a separate profile or spoof the user agent
          "media.peerconnection.enabled" = true;
          "media.peerconnection.ice.no_host" =
            false; # may or may not be required
          "webgl.disabled" = false; # required for Zoom
          "webgl.min_capability_mode" = false;
          "media.getusermedia.screensharing.enabled" = true; # optional
          "media.autoplay.blocking_policy" =
            0; # optional (otherwise add site exceptions)
          "javascript.options.wasm" =
            true; # optional (some platforms may require this)
          "dom.webaudio.enabled" = true;
        };
        userChrome = userchrome-treestyletabs;
      };
    };
  };

  xdg.desktopEntries = let
    icons = pkgs.personal.icons;
    firefox-profiles-dir = "${config.home.homeDirectory}/.mozilla/firefox";
    firefoxInProfile = profile:
      "${pkgs.firefox}/bin/firefox --profile \"${firefox-profiles-dir}/${profile}\"";
  in {
    netflix = {
      name = "Netflix";
      genericName = "Streaming service";
      icon = "${icons.netflix}";
      comment = "Unlimited movies, TV shows, and more.";
      exec =
        "${firefoxInProfile "streaming"} https://www.netflix.com/fr-en/login";
      categories = [ "AudioVideo" "Video" "Player" ];
    };
    mubi = {
      name = "MUBI";
      genericName = "Streaming service";
      icon = "${icons.mubi}";
      comment = "Watch hand-picked cinema.";
      exec = "${firefoxInProfile "streaming"} https://mubi.com";
      categories = [ "AudioVideo" "Video" "Player" ];
    };
    deezer = {
      name = "Deezer";
      genericName = "Streaming service";
      icon = "${icons.deezer}";
      comment = "Listen to music online";
      exec = "${firefoxInProfile "streaming"} https://deezer.com/login";
      categories = [ "AudioVideo" "Audio" "Player" "Music" ];
    };
    videoconferences = {
      name = "Video Conferences";
      genericName = "Video conference";
      comment = "Use video conferencing software in a browser.";
      exec = "${firefoxInProfile "videoconferencing"}";
      categories = [ "Network" "VideoConference" ];
    };
  };
}