diff --git a/configuration.nix b/configuration.nix index 412e98b..db7e820 100644 --- a/configuration.nix +++ b/configuration.nix @@ -15,6 +15,7 @@ ./modules/hardware.nix ./modules/services.nix ./modules/aliases.nix + ./modules/theme.nix ]; nix.settings.experimental-features = [ "nix-command" "flakes" ]; diff --git a/modules/theme.nix b/modules/theme.nix new file mode 100644 index 0000000..85f1312 --- /dev/null +++ b/modules/theme.nix @@ -0,0 +1,39 @@ +{ pkgs, config, lib, ... }: + +let + # URL for the theme + themeUrl = "https://raw.githubusercontent.com/catppuccin/cosmic-desktop/main/themes/cosmic-settings/catppuccin-macchiato-blue%2Bround.ron"; + themeFile = pkgs.fetchurl { + url = themeUrl; + sha256 = "00hkydzjy87g18xqbg2a07hlh96akwnlbl1pdn006f3kkscyfkmr"; + }; +in +{ + # Create a systemd user service to apply the theme + systemd.user.services.apply-cosmic-theme = { + description = "Apply Catppuccin Macchiato theme to Cosmic"; + wantedBy = [ "graphical-session.target" ]; + partOf = [ "graphical-session.target" ]; + script = '' + mkdir -p %h/.config/cosmic/com.system76.CosmicTheme.Dark.Builder + + # The theme file from the repo is the "entries" part of the config. + # We need to wrap it in the structure Cosmic expects: ( entries: ..., version: 1 ) + + echo "(" > %h/.config/cosmic/com.system76.CosmicTheme.Dark.Builder/v1 + echo " entries: " >> %h/.config/cosmic/com.system76.CosmicTheme.Dark.Builder/v1 + cat ${themeFile} >> %h/.config/cosmic/com.system76.CosmicTheme.Dark.Builder/v1 + echo "," >> %h/.config/cosmic/com.system76.CosmicTheme.Dark.Builder/v1 + echo " version: 1" >> %h/.config/cosmic/com.system76.CosmicTheme.Dark.Builder/v1 + echo ")" >> %h/.config/cosmic/com.system76.CosmicTheme.Dark.Builder/v1 + + # Ensure Dark Mode is enabled + mkdir -p %h/.config/cosmic/com.system76.CosmicTheme.Mode + echo '( entries: ( is_dark: true ), version: 1 )' > %h/.config/cosmic/com.system76.CosmicTheme.Mode/v1 + ''; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + }; +}