From e10079e5781a6b1eeaebde46d16351d47a07b5a1 Mon Sep 17 00:00:00 2001 From: Jan-Bulthuis Date: Fri, 9 May 2025 15:00:21 +0200 Subject: [PATCH] Updated some theming --- user-modules/desktop/theming/background.nix | 95 +++++++++++-------- user-modules/desktop/theming/colors.nix | 7 +- user-modules/desktop/theming/default.nix | 6 +- .../desktop/theming/fonts/adwaita-mono.nix | 8 ++ .../desktop/theming/fonts/adwaita-sans.nix | 8 ++ 5 files changed, 80 insertions(+), 44 deletions(-) create mode 100644 user-modules/desktop/theming/fonts/adwaita-mono.nix create mode 100644 user-modules/desktop/theming/fonts/adwaita-sans.nix diff --git a/user-modules/desktop/theming/background.nix b/user-modules/desktop/theming/background.nix index fcb641a..0032059 100644 --- a/user-modules/desktop/theming/background.nix +++ b/user-modules/desktop/theming/background.nix @@ -11,26 +11,30 @@ let in { options.desktop.theming.background = { - path = mkOption { - type = types.str; - default = "minimal/a_flower_on_a_dark_background.png"; - description = "Path to the background image."; - }; - themed = mkEnableOption "themed background"; - invert = mkEnableOption "invert background"; - src = mkOption { - default = pkgs.fetchFromGitHub { - owner = "dharmx"; - repo = "walls"; - rev = "6bf4d733ebf2b484a37c17d742eb47e5139e6a14"; - sha256 = "sha256-M96jJy3L0a+VkJ+DcbtrRAquwDWaIG9hAUxenr/TcQU="; + image = { + url = mkOption { + type = types.str; + default = "https://raw.githubusercontent.com/dharmx/walls/refs/heads/main/digital/a_drawing_of_a_spider_on_a_white_surface.png"; + description = "URL to the background image."; + }; + hash = mkOption { + type = types.str; + default = "sha256-eCEjM7R9yeHNhZZtvHjrgkfwT25JA7FeMoVwnQ887CQ="; + description = "SHA256 hash of the background image."; }; }; + themed = mkEnableOption "themed background"; + inverted = mkEnableOption "invert background"; }; config = with pkgs; let + src = pkgs.fetchurl { + url = cfg.image.url; + hash = cfg.image.hash; + }; + theme = writeTextFile { name = "gowall-theme"; text = builtins.toJSON { @@ -61,45 +65,56 @@ in executable = true; }; + fileExtension = + name: + let + parts = splitString "." name; + in + if length parts > 1 then lists.last parts else ""; + + fileName = + name: + let + parts = splitString "/" name; + in + if length parts > 1 then lists.last parts else name; + + image = fileName cfg.image.url; + background-themed = stdenv.mkDerivation { name = "background-themed-1.0.0"; - src = cfg.src; + src = src; buildInputs = [ gowall imagemagick (writeShellScriptBin "xdg-open" "") + tree ]; - buildPhase = - if cfg.themed then - if cfg.invert then - '' - cp ${theme} ./theme.json + unpackPhase = '' + cp ${src} ./${image} + chmod u+w ./${image} + ''; - export HOME=$PWD - convert ./${cfg.path} -channel RGB -negate ./${cfg.path} + buildPhase = '' + ${optionalString cfg.inverted '' + convert ./${image} -channel RGB -negate ./${image} + ''} + ${optionalString cfg.themed '' + cp ${theme} ./theme.json - gowall convert ./${cfg.path} -o themed -t ./theme.json - mv Pictures/gowall/themed.* ./ - mogrify -format png themed.* - '' - else - '' - cp ${theme} ./theme.json + export HOME=$PWD - export HOME=$PWD - - gowall convert ./${cfg.path} -o themed -t ./theme.json - mv Pictures/gowall/themed.* ./ - mogrify -format png themed.* - '' - else - '' - cp ${cfg.path} ./themed - - mogrify -format png themed - ''; + gowall convert ./${image} --output themed -t ./theme.json + tree + mv ./themed/*.* ./ + ''} + mv ./${image} themed.${fileExtension image} + ${optionalString (fileExtension image != "png") '' + mogrify -format png themed.* + ''} + ''; installPhase = '' install -Dm644 -t $out themed.png diff --git a/user-modules/desktop/theming/colors.nix b/user-modules/desktop/theming/colors.nix index 00f6b1e..70fc854 100644 --- a/user-modules/desktop/theming/colors.nix +++ b/user-modules/desktop/theming/colors.nix @@ -110,8 +110,11 @@ in # Configure qt theme qt = mkIf config.desktop.enable { enable = true; - platformTheme.name = "adwaita"; - style.name = if cfg.darkMode then "adwaita-dark" else "adwaita-light"; + platformTheme.name = "gtk"; + style = { + name = if cfg.darkMode then "adwaita-dark" else "adwaita-light"; + package = pkgs.adwaita-qt; + }; }; # Configure gtk theme diff --git a/user-modules/desktop/theming/default.nix b/user-modules/desktop/theming/default.nix index 5e512e0..f61fff3 100644 --- a/user-modules/desktop/theming/default.nix +++ b/user-modules/desktop/theming/default.nix @@ -35,6 +35,8 @@ let fontModules = [ # Import all fonts + ./fonts/adwaita-mono.nix + ./fonts/adwaita-sans.nix ./fonts/cozette-vector.nix ./fonts/cozette.nix ./fonts/dejavu-sans.nix @@ -190,8 +192,8 @@ in { enable = true; # TODO: Toggles - gtk3.extraCss = disableCSD; - gtk4.extraCss = disableCSD; + gtk3.extraCss = mkIf config.modules.river.enable disableCSD; + gtk4.extraCss = mkIf config.modules.river.enable disableCSD; }; # TODO: Make cursors configurable using modules. diff --git a/user-modules/desktop/theming/fonts/adwaita-mono.nix b/user-modules/desktop/theming/fonts/adwaita-mono.nix new file mode 100644 index 0000000..ccbd09b --- /dev/null +++ b/user-modules/desktop/theming/fonts/adwaita-mono.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: + +{ + name = "Adwaita Mono"; + package = pkgs.adwaita-fonts; + recommendedSize = 12; + fallbackFonts = [ ]; +} diff --git a/user-modules/desktop/theming/fonts/adwaita-sans.nix b/user-modules/desktop/theming/fonts/adwaita-sans.nix new file mode 100644 index 0000000..4d89a97 --- /dev/null +++ b/user-modules/desktop/theming/fonts/adwaita-sans.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: + +{ + name = "Adwaita Sans"; + package = pkgs.adwaita-fonts; + recommendedSize = 12; + fallbackFonts = [ ]; +}