moved pp-adjuster script to home modules

This commit is contained in:
Aly Raffauf 2024-05-02 15:58:22 -04:00
parent f188dd3843
commit fe1ee27b8f
5 changed files with 43 additions and 24 deletions

View file

@ -58,6 +58,9 @@
vsCodium.enable = true; vsCodium.enable = true;
webCord.enable = true; webCord.enable = true;
}; };
scripts = {
pp-adjuster.enable = true;
};
}; };
wayland.windowManager.sway.config.assigns = { wayland.windowManager.sway.config.assigns = {
"workspace 1: web" = [{app_id = "firefox";}]; "workspace 1: web" = [{app_id = "firefox";}];

View file

@ -4,7 +4,7 @@
lib, lib,
... ...
}: { }: {
imports = [./apps ./desktop ./services]; imports = [./apps ./desktop ./services ./scripts];
nixpkgs = { nixpkgs = {
# Configure nixpkgs instance # Configure nixpkgs instance

View file

@ -0,0 +1,10 @@
{
config,
lib,
pkgs,
...
}: {
imports = [
./pp-adjuster
];
}

View file

@ -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];
};
}

View file

@ -30,28 +30,6 @@
plasma-apply-lookandfeel -a org.kde.breezedark.desktop plasma-apply-lookandfeel -a org.kde.breezedark.desktop
fi 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 { in {
imports = [ imports = [
./disko.nix ./disko.nix
@ -70,7 +48,7 @@ in {
networking.hostName = "petalburg"; # Define your hostname. networking.hostName = "petalburg"; # Define your hostname.
environment.systemPackages = [cs-adjuster cs-adjuster-plasma pp-adjuster]; environment.systemPackages = [cs-adjuster cs-adjuster-plasma];
alyraffauf = { alyraffauf = {
system = { system = {