dotfiles/modules/common/applications/firefox.nix

193 lines
7.2 KiB
Nix
Raw Normal View History

2024-04-20 13:42:06 +00:00
{
config,
pkgs,
lib,
...
}:
2022-04-28 22:55:15 +00:00
{
2022-06-05 01:08:09 +00:00
2022-12-21 21:18:03 +00:00
options = {
firefox = {
enable = lib.mkEnableOption {
description = "Enable Firefox.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.firefox.enable) {
unfreePackages = [
(lib.mkIf config._1password.enable "onepassword-password-manager")
2022-12-21 21:18:03 +00:00
"okta-browser-plugin"
];
2022-06-05 01:08:09 +00:00
home-manager.users.${config.user} = {
2022-05-07 18:24:00 +00:00
2022-12-21 21:18:03 +00:00
programs.firefox = {
2022-05-07 18:24:00 +00:00
enable = true;
2024-04-20 13:42:06 +00:00
package = if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox;
2022-12-10 22:47:39 +00:00
profiles.default = {
2022-05-07 18:24:00 +00:00
id = 0;
name = "default";
isDefault = true;
2024-01-23 12:44:18 +00:00
# https://nur.nix-community.org/repos/rycee/
2023-02-13 02:26:12 +00:00
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
(lib.mkIf config._1password.enable onepassword-password-manager)
2024-01-02 01:50:48 +00:00
darkreader
don-t-fuck-with-paste
facebook-container
markdownload
multi-account-containers
2023-02-13 02:26:12 +00:00
okta-browser-plugin
reddit-enhancement-suite
return-youtube-dislikes
2024-01-02 01:50:48 +00:00
sponsorblock
ublock-origin
ublacklist
vimium
2023-02-13 02:26:12 +00:00
];
2022-05-07 18:24:00 +00:00
settings = {
2022-12-10 22:47:39 +00:00
"app.update.auto" = false;
2022-05-07 18:24:00 +00:00
"browser.aboutConfig.showWarning" = false;
"browser.warnOnQuit" = false;
2024-04-20 13:42:06 +00:00
"browser.quitShortcut.disabled" = if pkgs.stdenv.isLinux then true else false;
2022-05-07 18:24:00 +00:00
"browser.theme.dark-private-windows" = true;
2023-02-02 16:01:12 +00:00
"browser.toolbars.bookmarks.visibility" = false;
2022-05-07 18:24:00 +00:00
"browser.startup.page" = 3; # Restore previous session
"browser.newtabpage.enabled" = false; # Make new tabs blank
2024-04-20 13:42:06 +00:00
"trailhead.firstrun.didSeeAboutWelcome" = true; # Disable welcome splash
2022-11-16 20:52:24 +00:00
"dom.forms.autocomplete.formautofill" = false; # Disable autofill
2024-04-20 13:42:06 +00:00
"extensions.formautofill.creditCards.enabled" = false; # Disable credit cards
2022-12-10 22:47:39 +00:00
"dom.payments.defaults.saveAddress" = false; # Disable address save
2022-05-07 18:24:00 +00:00
"general.autoScroll" = true; # Drag middle-mouse to scroll
2024-04-20 13:42:06 +00:00
"services.sync.prefs.sync.general.autoScroll" = false; # Prevent disabling autoscroll
2022-05-07 18:24:00 +00:00
"extensions.pocket.enabled" = false;
2024-04-20 13:42:06 +00:00
"toolkit.legacyUserProfileCustomizations.stylesheets" = true; # Allow userChrome.css
2022-05-11 03:45:50 +00:00
"layout.css.color-mix.enabled" = true;
2024-04-20 13:42:06 +00:00
"ui.systemUsesDarkTheme" = if config.theme.dark == true then 1 else 0;
"media.ffmpeg.vaapi.enabled" = true; # Enable hardware video acceleration
2023-06-08 17:14:50 +00:00
"cookiebanners.ui.desktop.enabled" = true; # Reject cookie popups
2024-04-20 13:42:06 +00:00
"devtools.command-button-screenshot.enabled" = true; # Scrolling screenshot of entire page
"svg.context-properties.content.enabled" = true; # Sidebery styling
2022-05-07 18:24:00 +00:00
};
userChrome = ''
2022-05-08 01:05:11 +00:00
:root {
--focus-outline-color: ${config.theme.colors.base04} !important;
--toolbar-color: ${config.theme.colors.base07} !important;
2022-05-11 03:45:50 +00:00
--tab-min-height: 30px !important;
2022-05-08 01:05:11 +00:00
}
2022-05-07 18:24:00 +00:00
/* Background of tab bar */
.toolbar-items {
background-color: ${config.theme.colors.base00} !important;
2022-05-07 18:24:00 +00:00
}
2022-12-10 22:47:39 +00:00
/* Extra tab bar sides on macOS */
.titlebar-spacer {
background-color: ${config.theme.colors.base00} !important;
}
.titlebar-buttonbox-container {
background-color: ${config.theme.colors.base00} !important;
}
#tabbrowser-tabs {
border-inline-start: 0 !important;
}
/* Private Browsing indicator on macOS */
#private-browsing-indicator-with-label {
background-color: ${config.theme.colors.base00} !important;
margin-inline: 0 !important;
padding-inline: 7px;
}
2022-05-07 18:24:00 +00:00
/* Tabs themselves */
.tabbrowser-tab .tab-stack {
border-radius: 5px 5px 0 0;
overflow: hidden;
background-color: ${config.theme.colors.base00};
color: ${config.theme.colors.base06} !important;
2022-05-07 18:24:00 +00:00
}
.tab-content {
2022-05-11 03:45:50 +00:00
border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 40%, transparent);
border-radius: 5px 5px 0 0;
background-color: ${config.theme.colors.base00};
color: ${config.theme.colors.base06} !important;
2022-05-07 18:24:00 +00:00
}
.tab-content[selected] {
2022-05-11 03:45:50 +00:00
border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 25%, transparent);
background-color: ${config.theme.colors.base01} !important;
color: ${config.theme.colors.base07} !important;
2022-05-07 18:24:00 +00:00
}
/* Below tab bar */
#nav-bar {
background: ${config.theme.colors.base01} !important;
2022-05-07 18:24:00 +00:00
}
/* URL bar in nav bar */
2022-05-08 01:05:11 +00:00
#urlbar[focused=true] {
color: ${config.theme.colors.base07} !important;
background: ${config.theme.colors.base02} !important;
caret-color: ${config.theme.colors.base05} !important;
2022-05-08 01:05:11 +00:00
}
#urlbar:not([focused=true]) {
color: ${config.theme.colors.base04} !important;
background: ${config.theme.colors.base02} !important;
2022-05-08 01:05:11 +00:00
}
#urlbar ::-moz-selection {
color: ${config.theme.colors.base07} !important;
background: ${config.theme.colors.base02} !important;
2022-05-07 18:24:00 +00:00
}
2022-05-08 01:05:11 +00:00
#urlbar-input-container {
border: 1px solid ${config.theme.colors.base01} !important;
2022-05-08 01:05:11 +00:00
}
#urlbar-background {
background: ${config.theme.colors.base01} !important;
2022-05-08 01:05:11 +00:00
}
2022-05-07 18:24:00 +00:00
/* Text in URL bar */
2022-05-08 01:05:11 +00:00
#urlbar-input, #urlbar-scheme, .searchbar-textbox {
color: ${config.theme.colors.base07} !important;
2022-05-07 18:24:00 +00:00
}
'';
2022-05-08 01:05:11 +00:00
userContent = ''
@-moz-document url-prefix(about:blank) {
* {
background-color:${config.theme.colors.base01} !important;
2022-05-08 01:05:11 +00:00
}
}
'';
2022-05-07 18:24:00 +00:00
extraConfig = "";
};
};
2023-04-01 13:41:45 +00:00
2024-02-18 15:35:01 +00:00
xdg.mimeApps = {
2024-04-20 13:42:06 +00:00
associations.added = {
2024-06-23 15:42:43 +00:00
"text/html" = [ "firefox.desktop" ];
2024-04-20 13:42:06 +00:00
};
defaultApplications = {
2024-06-23 15:42:43 +00:00
"text/html" = [ "firefox.desktop" ];
2023-04-01 13:41:45 +00:00
};
2024-06-23 15:42:43 +00:00
associations.removed = {
"text/html" = [ "wine-extension-htm.desktop" ];
};
2024-04-20 13:42:06 +00:00
};
2023-04-01 13:41:45 +00:00
2024-04-20 13:42:06 +00:00
xsession.windowManager.i3.config.keybindings = lib.mkIf pkgs.stdenv.isLinux {
"${
config.home-manager.users.${config.user}.xsession.windowManager.i3.config.modifier
}+Shift+b" = "exec ${
# Don't name the script `firefox` or it will affect grep
builtins.toString (
pkgs.writeShellScript "focus-ff.sh" ''
count=$(ps aux | grep -c firefox)
if [ "$count" -eq 1 ]; then
i3-msg "exec --no-startup-id firefox"
sleep 0.5
fi
i3-msg "[class=firefox] focus"
''
)
}";
};
2022-04-29 03:04:48 +00:00
};
2022-04-29 01:56:21 +00:00
};
2022-04-28 22:55:15 +00:00
}