diff --git a/aly.nix b/aly.nix index 37f5605d..c6393a20 100644 --- a/aly.nix +++ b/aly.nix @@ -58,6 +58,9 @@ vsCodium.enable = true; webCord.enable = true; }; + scripts = { + pp-adjuster.enable = true; + }; }; wayland.windowManager.sway.config.assigns = { "workspace 1: web" = [{app_id = "firefox";}]; diff --git a/homeManagerModules/default.nix b/homeManagerModules/default.nix index b0ba3cca..34362171 100644 --- a/homeManagerModules/default.nix +++ b/homeManagerModules/default.nix @@ -4,7 +4,7 @@ lib, ... }: { - imports = [./apps ./desktop ./services]; + imports = [./apps ./desktop ./services ./scripts]; nixpkgs = { # Configure nixpkgs instance diff --git a/homeManagerModules/scripts/default.nix b/homeManagerModules/scripts/default.nix new file mode 100644 index 00000000..34a3a7d0 --- /dev/null +++ b/homeManagerModules/scripts/default.nix @@ -0,0 +1,10 @@ +{ + config, + lib, + pkgs, + ... +}: { + imports = [ + ./pp-adjuster + ]; +} diff --git a/homeManagerModules/scripts/pp-adjuster/default.nix b/homeManagerModules/scripts/pp-adjuster/default.nix new file mode 100644 index 00000000..d5770f03 --- /dev/null +++ b/homeManagerModules/scripts/pp-adjuster/default.nix @@ -0,0 +1,28 @@ +{ + pkgs, + lib, + config, + ... +}: let + pp-adjuster = pkgs.writeShellScriptBin "pp-adjuster" '' + # Only works on petalburg. + current_profile=$(${pkgs.power-profiles-daemon}/bin/powerprofilesctl get | tr -d '[:space:]') + + if [ "$current_profile" == "power-saver" ]; then + ${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced + elif [ "$current_profile" == "balanced" ]; then + ${pkgs.power-profiles-daemon}/bin/powerprofilesctl set performance + elif [ "$current_profile" == "performance" ]; then + ${pkgs.power-profiles-daemon}/bin/powerprofilesctl set power-saver + fi + + new_profile=$(${pkgs.power-profiles-daemon}/bin/powerprofilesctl get | tr -d '[:space:]') + ${pkgs.libnotify}/bin/notify-send "Power profile set to $new_profile." + ''; +in { + options = {alyraffauf.scripts.pp-adjuster.enable = lib.mkEnableOption "Enable pp-adjuster script.";}; + + config = lib.mkIf config.alyraffauf.scripts.pp-adjuster.enable { + home.packages = [pp-adjuster]; + }; +} diff --git a/hosts/petalburg/default.nix b/hosts/petalburg/default.nix index dc2f2f7d..6a1dac7f 100644 --- a/hosts/petalburg/default.nix +++ b/hosts/petalburg/default.nix @@ -30,28 +30,6 @@ plasma-apply-lookandfeel -a org.kde.breezedark.desktop fi ''; - - pp-adjuster = pkgs.writeShellApplication { - name = "pp-adjuster"; - - runtimeInputs = [pkgs.libnotify pkgs.power-profiles-daemon]; - - text = '' - # Only works on petalburg. - current_profile=$(${pkgs.power-profiles-daemon}/bin/powerprofilesctl get | tr -d '[:space:]') - - if [ "$current_profile" == "power-saver" ]; then - ${pkgs.power-profiles-daemon}/bin/powerprofilesctl set balanced - elif [ "$current_profile" == "balanced" ]; then - ${pkgs.power-profiles-daemon}/bin/powerprofilesctl set performance - elif [ "$current_profile" == "performance" ]; then - ${pkgs.power-profiles-daemon}/bin/powerprofilesctl set power-saver - fi - - new_profile=$(${pkgs.power-profiles-daemon}/bin/powerprofilesctl get | tr -d '[:space:]') - ${pkgs.libnotify}/bin/notify-send "Power profile set to $new_profile." - ''; - }; in { imports = [ ./disko.nix @@ -70,7 +48,7 @@ in { networking.hostName = "petalburg"; # Define your hostname. - environment.systemPackages = [cs-adjuster cs-adjuster-plasma pp-adjuster]; + environment.systemPackages = [cs-adjuster cs-adjuster-plasma]; alyraffauf = { system = {