From ea7dd98c0955a71760530751b9d4cbdf73dce32e Mon Sep 17 00:00:00 2001 From: Artur Manuel Date: Mon, 14 Apr 2025 19:01:34 +0100 Subject: [PATCH] refactor: better modularise arturm/configs/qutebrowser There are other changes too, such as some tiny refactors to make some things a small bit more readable. For example: I added a variable in `cityseventeen/apps.nix` to make environment variables a small bit easier to read. It is pretty much the same case in `cityseventeen/themes.nix` except I used map to get each attribute set with package instead of mapAttrs. There are also some minor tweaks here and there but it isn't worth talking about. --- flake.lock | 36 +++++------ hosts/cityseventeen/apps.nix | 11 ++-- hosts/cityseventeen/theme.nix | 5 +- .../configs/qutebrowser/colours/__init__.py | 0 .../configs/qutebrowser/colours/darkmode.py | 3 + .../{theme/__init__.py => colours/themes.py} | 23 +++++++- .../arturm/configs/qutebrowser/config.py | 59 ++++++++----------- hosts/cityseventeen/users/arturm/default.nix | 4 +- 8 files changed, 81 insertions(+), 60 deletions(-) create mode 100644 hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/__init__.py create mode 100644 hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/darkmode.py rename hosts/cityseventeen/users/arturm/configs/qutebrowser/{theme/__init__.py => colours/themes.py} (90%) diff --git a/flake.lock b/flake.lock index b4bea93..5b91fb0 100644 --- a/flake.lock +++ b/flake.lock @@ -47,11 +47,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1744300958, - "narHash": "sha256-ijCSbAFTvMkjHKivrhCVxti3lPELwFKvV4Gv4BPSRrg=", + "lastModified": 1744455756, + "narHash": "sha256-wPZ1GfwpUsz/4nFrVXk8fmiXn8kHiYSQEQWeAq48ONY=", "owner": "chaotic-cx", "repo": "nyx", - "rev": "72d8607e498dc1fe463ae5bfec8b590a138fd1db", + "rev": "99f9f08455cf22de124c059b18988ee8d452285b", "type": "github" }, "original": { @@ -104,11 +104,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1742452566, - "narHash": "sha256-sVuLDQ2UIWfXUBbctzrZrXM2X05YjX08K7XHMztt36E=", + "lastModified": 1744231114, + "narHash": "sha256-60gLl2rJFt6SRwqWimsTAeHgfsIE1iV0zChdJFOvx8w=", "owner": "nix-community", "repo": "fenix", - "rev": "7d9ba794daf5e8cc7ee728859bc688d8e26d5f06", + "rev": "0ccfe532b1433da8e5a23cd513ff6847e0f6a8c2", "type": "github" }, "original": { @@ -314,11 +314,11 @@ "nixpkgs": ["chaotic", "nixpkgs"] }, "locked": { - "lastModified": 1744172174, - "narHash": "sha256-Ud0ClYf8YHhbYmg1piPJx2iuYOh62HQiRzDObD2gzsk=", + "lastModified": 1744400600, + "narHash": "sha256-qYhUgA98mhq1QK13r9qVY+sG1ri6FBgyp+GApX6wS20=", "owner": "nix-community", "repo": "home-manager", - "rev": "4040c5779ce56d36805bc7a83e072f0f894eae7d", + "rev": "b74b22bb6167e8dff083ec6988c98798bf8954d3", "type": "github" }, "original": { @@ -333,11 +333,11 @@ "nixpkgs": ["chaotic", "nixpkgs"] }, "locked": { - "lastModified": 1744117730, - "narHash": "sha256-kcxkKeBYyhy3BT5wfGmMo6kNo3XM5R7h/bu5fLdbnG4=", + "lastModified": 1744270169, + "narHash": "sha256-yV6OhBUj3Ag1l9gdf7eObkAoli35SUxDtFvC8JbsVrk=", "owner": "Jovian-Experiments", "repo": "Jovian-NixOS", - "rev": "92a01193c13d5ef9085899e22715c6e5f2590af8", + "rev": "10d3614023e2fb15e5e7089235e9958b9aa71a6c", "type": "github" }, "original": { @@ -402,11 +402,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1744098102, - "narHash": "sha256-tzCdyIJj9AjysC3OuKA+tMD/kDEDAF9mICPDU7ix0JA=", + "lastModified": 1744232761, + "narHash": "sha256-gbl9hE39nQRpZaLjhWKmEu5ejtQsgI5TWYrIVVJn30U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c8cd81426f45942bb2906d5ed2fe21d2f19d95b7", + "rev": "f675531bc7e6657c10a18b565cfebd8aa9e24c14", "type": "github" }, "original": { @@ -474,11 +474,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1744098102, - "narHash": "sha256-tzCdyIJj9AjysC3OuKA+tMD/kDEDAF9mICPDU7ix0JA=", + "lastModified": 1744232761, + "narHash": "sha256-gbl9hE39nQRpZaLjhWKmEu5ejtQsgI5TWYrIVVJn30U=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c8cd81426f45942bb2906d5ed2fe21d2f19d95b7", + "rev": "f675531bc7e6657c10a18b565cfebd8aa9e24c14", "type": "github" }, "original": { diff --git a/hosts/cityseventeen/apps.nix b/hosts/cityseventeen/apps.nix index dfe7015..6eac168 100644 --- a/hosts/cityseventeen/apps.nix +++ b/hosts/cityseventeen/apps.nix @@ -1,15 +1,16 @@ { inputs, pkgs, + config, ... }: +let + env = config.environment.variables; +in { environment = { + shellAliases.e = "${env.EDITOR}"; systemPackages = [ pkgs.amadaluzian-zsh ]; - sessionVariables.EDITOR = "emacsclient -c"; - shellAliases = { - "e" = "$EDITOR"; - }; }; alqueva = { @@ -45,8 +46,8 @@ emacs = { enable = true; package = inputs.pankomacs.packages.${pkgs.system}.pgtk; - startWithGraphical = true; install = true; + defaultEditor = true; }; rsyncd.enable = true; }; diff --git a/hosts/cityseventeen/theme.nix b/hosts/cityseventeen/theme.nix index c9ddc04..8c6a8e2 100644 --- a/hosts/cityseventeen/theme.nix +++ b/hosts/cityseventeen/theme.nix @@ -17,6 +17,7 @@ let package = pkgs.rose-pine-cursor; }; }; + themePackages = map (subset: subset.package) (builtins.attrValues themes); in { alqueva.system.dconf = { @@ -40,5 +41,7 @@ in "L+ %h/.config/gtk-4.0 - - - - ${themes.gtk.package}/share/themes/${themes.gtk.name}/gtk-4.0" ]; - environment.systemPackages = builtins.attrValues (builtins.mapAttrs (_: v: v.package) themes); + # This is really just to please the functor. + # Any value can be used in null's place. + environment.systemPackages = themePackages; } diff --git a/hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/__init__.py b/hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/darkmode.py b/hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/darkmode.py new file mode 100644 index 0000000..7a1681e --- /dev/null +++ b/hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/darkmode.py @@ -0,0 +1,3 @@ +def darkmode_on(config, pages): + for p in pages: + config.set("colors.webpage.darkmode.enabled", True, p) diff --git a/hosts/cityseventeen/users/arturm/configs/qutebrowser/theme/__init__.py b/hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/themes.py similarity index 90% rename from hosts/cityseventeen/users/arturm/configs/qutebrowser/theme/__init__.py rename to hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/themes.py index 67e9761..072f496 100644 --- a/hosts/cityseventeen/users/arturm/configs/qutebrowser/theme/__init__.py +++ b/hosts/cityseventeen/users/arturm/configs/qutebrowser/colours/themes.py @@ -1,4 +1,25 @@ -def load_theme(c, palette): +class Palettes: + rose_pine = { + "base00": "#191724", + "base01": "#1f1d2e", + "base02": "#26233a", + "base03": "#6e6a86", + "base04": "#908caa", + "base05": "#e0def4", + "base06": "#e0def4", + "base07": "#524f67", + "base08": "#eb6f92", + "base09": "#f6c177", + "base0A": "#ebbcba", + "base0B": "#31748f", + "base0C": "#9ccfd8", + "base0D": "#c4a7e7", + "base0E": "#f6c177", + "base0F": "#524f67", + } + + +def load_colours(c, palette): c.colors.completion.fg = palette["base05"] c.colors.completion.odd.bg = palette["base01"] c.colors.completion.even.bg = palette["base00"] diff --git a/hosts/cityseventeen/users/arturm/configs/qutebrowser/config.py b/hosts/cityseventeen/users/arturm/configs/qutebrowser/config.py index 812c99c..dde7697 100644 --- a/hosts/cityseventeen/users/arturm/configs/qutebrowser/config.py +++ b/hosts/cityseventeen/users/arturm/configs/qutebrowser/config.py @@ -1,37 +1,30 @@ -from theme import load_theme +from colours.themes import load_colours, Palettes +from colours.darkmode import darkmode_on -config.load_autoconfig() -theme = { - "base00": "#191724", - "base01": "#1f1d2e", - "base02": "#26233a", - "base03": "#6e6a86", - "base04": "#908caa", - "base05": "#e0def4", - "base06": "#e0def4", - "base07": "#524f67", - "base08": "#eb6f92", - "base09": "#f6c177", - "base0A": "#ebbcba", - "base0B": "#31748f", - "base0C": "#9ccfd8", - "base0D": "#c4a7e7", - "base0E": "#f6c177", - "base0F": "#524f67", -} +def main(): + # leave this alone! + config.load_autoconfig() -load_theme(c, theme) + # rose-pine + load_colours(c, Palettes.rose_pine) -c.colors.webpage.preferred_color_scheme = "dark" -c.tabs.position = "top" -c.tabs.width = 32 -c.fonts.default_size = "13pt" -c.fonts.default_family = "sans-serif" -c.tabs.padding = { - "bottom": 4, - "top": 4, - "left": 6, - "right": 6, -} -c.tabs.indicator.width = 0 + darkmode_on(config, ["about:blank"]) + + c.colors.webpage.darkmode.enabled = False + c.colors.webpage.preferred_color_scheme = "dark" + c.tabs.position = "top" + c.tabs.width = 32 + c.fonts.default_size = "13pt" + c.fonts.default_family = "sans-serif" + c.tabs.padding = { + "bottom": 4, + "top": 4, + "left": 6, + "right": 6, + } + c.tabs.indicator.width = 0 + c.url.start_pages = "about:blank" + + +main() diff --git a/hosts/cityseventeen/users/arturm/default.nix b/hosts/cityseventeen/users/arturm/default.nix index 90f5fdc..58f6501 100644 --- a/hosts/cityseventeen/users/arturm/default.nix +++ b/hosts/cityseventeen/users/arturm/default.nix @@ -5,10 +5,10 @@ }: { alqueva.users.arturm = { - shell = pkgs.zsh; + shell = pkgs.amadaluzian-zsh; tmpfiles = [ "L+ %h/.config/qutebrowser/config.py - - - - ${./configs/qutebrowser/config.py}" - "L+ %h/.config/qutebrowser/theme - - - - ${./configs/qutebrowser/theme}" + "L+ %h/.config/qutebrowser/colours - - - - ${./configs/qutebrowser/colours}" "L+ %h/.config/kanshi/ - - - - ${./configs/kanshi}" "L+ %h/.config/mako/ - - - - ${./configs/mako}" "L+ %h/.config/niri/ - - - - ${./configs/niri}"