From 3c2ed253ffb1cb699bfeede197dee362af8741b1 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Thu, 23 May 2024 23:21:23 -0400 Subject: [PATCH] moved color scheme swap scripts to gnome and kde modules respectively gnome/kde: nixify cs adjustment scripts --- hosts/petalburg/default.nix | 31 +------------------- nixosModules/desktop/gnome/default.nix | 39 ++++++++++++++++++------- nixosModules/desktop/plasma/default.nix | 30 ++++++++++++++----- 3 files changed, 51 insertions(+), 49 deletions(-) diff --git a/hosts/petalburg/default.nix b/hosts/petalburg/default.nix index e342c7c2..9074f8ee 100644 --- a/hosts/petalburg/default.nix +++ b/hosts/petalburg/default.nix @@ -4,34 +4,7 @@ lib, pkgs, ... -}: let - cs-adjuster = pkgs.writeShellScriptBin "cs-adjuster" '' - # Get current color scheme - color_scheme=$(gsettings get org.gnome.desktop.interface color-scheme) - - # Toggle between light and dark color schemes - if [ "$color_scheme" == "'default'" ] || [ "$color_scheme" == "'prefer-light'" ]; then - color_scheme="'prefer-dark'" - else - color_scheme="'prefer-light'" - fi - - # Apply the updated color scheme - gsettings set org.gnome.desktop.interface color-scheme $color_scheme - ''; - - cs-adjuster-plasma = pkgs.writeShellScriptBin "cs-adjuster-plasma" '' - # Query the Desktop Portal Service for the current color scheme - color_scheme=$(qdbus org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read org.freedesktop.appearance color-scheme) - - # Check the color scheme and apply the appropriate look and feel - if [ "$color_scheme" = "1" ]; then - plasma-apply-lookandfeel -a org.kde.breeze.desktop - else - plasma-apply-lookandfeel -a org.kde.breezedark.desktop - fi - ''; -in { +}: { imports = [ ./disko.nix ./hardware-configuration.nix # Include the results of the hardware scan. @@ -49,8 +22,6 @@ in { networking.hostName = "petalburg"; # Define your hostname. - environment.systemPackages = [cs-adjuster cs-adjuster-plasma]; - alyraffauf = { system = { plymouth.enable = true; diff --git a/nixosModules/desktop/gnome/default.nix b/nixosModules/desktop/gnome/default.nix index 13a0e8cd..a73dc6e1 100644 --- a/nixosModules/desktop/gnome/default.nix +++ b/nixosModules/desktop/gnome/default.nix @@ -3,7 +3,22 @@ lib, config, ... -}: { +}: let + gnomeCsAdjuster = pkgs.writeShellScriptBin "gnome-cs-adjuster" '' + # Get current color scheme + color_scheme=$(${lib.getExe' pkgs.glib "gsettings"} get org.gnome.desktop.interface color-scheme) + + # Toggle between light and dark color schemes + if [ "$color_scheme" == "'default'" ] || [ "$color_scheme" == "'prefer-light'" ]; then + color_scheme="'prefer-dark'" + else + color_scheme="'prefer-light'" + fi + + # Apply the updated color scheme + ${lib.getExe' pkgs.glib "gsettings"} set org.gnome.desktop.interface color-scheme $color_scheme + ''; +in { imports = [ # Include X settings. ./fprintdFix.nix @@ -16,16 +31,18 @@ }; config = lib.mkIf config.alyraffauf.desktop.gnome.enable { - environment.systemPackages = with pkgs; [ - gnomeExtensions.appindicator - gnomeExtensions.blur-my-shell - gnomeExtensions.gsconnect - gnomeExtensions.light-shell - gnomeExtensions.night-theme-switcher - gnomeExtensions.noannoyance-fork - gnomeExtensions.tailscale-status - gnomeExtensions.tiling-assistant - ]; + environment.systemPackages = with pkgs; + [ + gnomeExtensions.appindicator + gnomeExtensions.blur-my-shell + gnomeExtensions.gsconnect + gnomeExtensions.light-shell + gnomeExtensions.night-theme-switcher + gnomeExtensions.noannoyance-fork + gnomeExtensions.tailscale-status + gnomeExtensions.tiling-assistant + ] + ++ [gnomeCsAdjuster]; # Enable keyring support for KDE apps in GNOME. security.pam.services.gdm.enableKwallet = true; diff --git a/nixosModules/desktop/plasma/default.nix b/nixosModules/desktop/plasma/default.nix index 9c1fc88b..6af0482a 100644 --- a/nixosModules/desktop/plasma/default.nix +++ b/nixosModules/desktop/plasma/default.nix @@ -3,7 +3,19 @@ lib, config, ... -}: { +}: let + plasmaCsAdjuster = pkgs.writeShellScriptBin "plasma-cs-adjuster" '' + # Query the Desktop Portal Service for the current color scheme + color_scheme=$(${lib.getExe' pkgs.kdePackages.qttools "qdbus"} org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read org.freedesktop.appearance color-scheme) + + # Check the color scheme and apply the appropriate look and feel + if [ "$color_scheme" = "1" ]; then + ${lib.getExe' pkgs.kdePackages.plasma-workspace "plasma-apply-lookandfeel"} -a org.kde.breeze.desktop + else + ${lib.getExe' pkgs.kdePackages.plasma-workspace "plasma-apply-lookandfeel"} -a org.kde.breezedark.desktop + fi + ''; +in { options = { alyraffauf.desktop.plasma.enable = lib.mkEnableOption "Enable plasma desktop session."; @@ -21,13 +33,15 @@ }; }; - environment.systemPackages = with pkgs; [ - kdePackages.kate - kdePackages.kimageformats - kdePackages.kio-gdrive - kdePackages.sddm-kcm - maliit-keyboard - ]; + environment.systemPackages = with pkgs; + [ + kdePackages.kate + kdePackages.kimageformats + kdePackages.kio-gdrive + kdePackages.sddm-kcm + maliit-keyboard + ] + ++ [plasmaCsAdjuster]; programs.kdeconnect.enable = true; # nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true;