From 7108ef458c246c30bc37d3a056d2df76317eed0d Mon Sep 17 00:00:00 2001 From: bricked Date: Mon, 23 Dec 2024 22:49:04 +0100 Subject: [PATCH] steam: init with option to install adwaita theme This adds the steam module and its adwaitaForSteam.enable option which installs Adwaita for Steam with the Stylix color palette. Note that Adwaita for Steam is installed directly on the host system using an activation script. This is a slightly modified version of the code linked to in https://github.com/danth/stylix/issues/551#issuecomment-2486272591 by @reedrw. --- modules/steam/custom.mustache | 80 +++++++++++++++++++++++++++++++++++ modules/steam/hm.nix | 39 +++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 modules/steam/custom.mustache create mode 100644 modules/steam/hm.nix diff --git a/modules/steam/custom.mustache b/modules/steam/custom.mustache new file mode 100644 index 000000000..8747377e0 --- /dev/null +++ b/modules/steam/custom.mustache @@ -0,0 +1,80 @@ +:root { + /* The main accent color and the matching text value */ + --adw-accent-bg-rbg: {{base0D-rgb-r}}, {{base0D-rgb-g}}, {{base0D-rgb-b}}; + --adw-accent-fg-rbg: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-accent-rgb: {{base0D-rgb-r}}, {{base0D-rgb-g}}, {{base0D-rgb-b}}; + + /* destructive-action buttons */ + --adw-destructive-bg-rgb: {{base08-rgb-r}}, {{base08-rgb-g}}, {{base08-rgb-b}}; + --adw-destructive-fg-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-destructive-rgb: {{base08-rgb-r}}, {{base08-rgb-g}}, {{base08-rgb-b}}; + + /* Levelbars, entries, labels and infobars. These don't need text colors */ + --adw-success-bg-rgb: {{base0B-rgb-r}}, {{base0B-rgb-g}}, {{base0B-rgb-b}}; + --adw-success-fg-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-success-rgb: {{base0B-rgb-r}}, {{base0B-rgb-g}}, {{base0B-rgb-b}}; + + --adw-warning-bg-rgb: {{base0E-rgb-r}}, {{base0E-rgb-g}}, {{base0E-rgb-b}}; + --adw-warning-fg-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-warning-fg-a: 0.8; + --adw-warning-rgb: {{base0E-rgb-r}}, {{base0E-rgb-g}}, {{base0E-rgb-b}}; + + --adw-error-bg-rgb: {{base08-rgb-r}}, {{base08-rgb-g}}, {{base08-rgb-b}}; + --adw-error-fg-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-error-rgb: {{base08-rgb-r}}, {{base08-rgb-g}}, {{base08-rgb-b}}; + + /* Window */ + --adw-window-bg-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-window-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + + /* Views - e.g. text view or tree view */ + --adw-view-bg-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-view-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + + /* Header bar, search bar, tab bar */ + --adw-headerbar-bg-rgb: {{base01-rgb-r}}, {{base01-rgb-g}}, {{base01-rgb-b}}; + --adw-headerbar-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + --adw-headerbar-border-rgb: {{base01-rgb-r}}, {{base01-rgb-g}}, {{base01-rgb-b}}; + --adw-headerbar-backdrop-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-headerbar-shade-rgb: 0, 0, 0; + --adw-headerbar-shade-a: 0.9; + + /* Split pane views */ + --adw-sidebar-bg-rgb: {{base01-rgb-r}}, {{base01-rgb-g}}, {{base01-rgb-b}}; + --adw-sidebar-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + --adw-sidebar-backdrop-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-sidebar-shade-rgb: 0, 0, 0; + --adw-sidebar-shade-a: 0.36; + + --adw-secondary-sidebar-bg-rgb: {{base01-rgb-r}}, {{base01-rgb-g}}, {{base01-rgb-b}}; + --adw-secondary-sidebar-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + --adw-secondary-sidebar-backdrop-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-secondary-sidebar-shade-rgb: 0, 0, 0; + --adw-secondary-sidebar-shade-a: 0.36; + + /* Cards, boxed lists */ + --adw-card-bg-rgb: 0, 0, 0; + --adw-card-bg-a: 0.08; + --adw-card-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + --adw-card-shade-rgb: 0, 0, 0; + --adw-card-shade-a: 0.36; + + /* Dialogs */ + --adw-dialog-bg-rgb: {{base01-rgb-r}}, {{base01-rgb-g}}, {{base01-rgb-b}}; + --adw-dialog-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + + /* Popovers */ + --adw-popover-bg-rgb: {{base01-rgb-r}}, {{base01-rgb-g}}, {{base01-rgb-b}}; + --adw-popover-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + --adw-popover-shade-rgb: {{base01-rgb-r}}, {{base01-rgb-g}}, {{base01-rgb-b}}; + --adw-popover-shade-a: 0.36; + + /* Thumbnails */ + --adw-thumbnail-bg-rgb: {{base00-rgb-r}}, {{base00-rgb-g}}, {{base00-rgb-b}}; + --adw-thumbnail-fg-rgb: {{base05-rgb-r}}, {{base05-rgb-g}}, {{base05-rgb-b}}; + + /* Miscellaneous */ + --adw-shade-rgb: 0, 0, 0; + --adw-shade-a: 0.36; +} + diff --git a/modules/steam/hm.nix b/modules/steam/hm.nix new file mode 100644 index 000000000..92e2d7508 --- /dev/null +++ b/modules/steam/hm.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.stylix.targets.steam; +in { + options.stylix.targets.steam = { + enable = config.lib.stylix.mkEnableTarget "Steam" true; + adwaitaForSteam.enable = config.lib.stylix.mkEnableTarget "Adwaita for Steam" false; + }; + + config = lib.mkIf (config.stylix.enable && cfg.enable) (lib.mkMerge [ + { + # Generic configuration + } + + (lib.mkIf cfg.adwaitaForSteam.enable { + home.packages = with pkgs; [adwsteamgtk]; + + home.activation.adwaitaForSteam = let + shellScript = pkgs.writeShellScript "adwaitaForSteam" '' + rm -f "$HOME/.cache/AdwSteamInstaller/extracted/custom/custom.css" + ${lib.getExe pkgs.adwsteamgtk} -i + ''; + in + config.lib.dag.entryAfter ["writeBoundary" "dconfSettings"] '' + run --quiet ${shellScript} + ''; + + # Use custom.css + dconf.settings."io/github/Foldex/AdwSteamGtk".prefs-install-custom-css = true; + + xdg.configFile."AdwSteamGtk/custom.css".source = config.lib.stylix.colors { + template = ./custom.mustache; + extension = "css"; + }; + + }) + ]); +}