Skip to content

Commit

Permalink
Various Additions to PowerDevil Configuration (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
Green-D-683 authored Oct 16, 2024
1 parent a9960fe commit 508a077
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 4 deletions.
4 changes: 3 additions & 1 deletion modules/input.nix
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ in
Use.value = true;
LayoutList.value = strings.concatStringsSep "," (map (l: l.layout) cfg.input.keyboard.layouts);
VariantList.value = strings.concatStringsSep "," (map (l: l.variant) cfg.input.keyboard.layouts);
DisplayNames.value = strings.concatStringsSep "," (map (l: l.displayName) cfg.input.keyboard.layouts);
DisplayNames.value = strings.concatStringsSep "," (
map (l: l.displayName) cfg.input.keyboard.layouts
);
};
})
(mkIf (cfg.input.keyboard.options != null) {
Expand Down
81 changes: 78 additions & 3 deletions modules/powerdevil.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ let
shutDown = 8;
};

autoCriticalActions = {
nothing = 0;
hibernate = 2;
sleep = 1;
shutDown = 8;
};

whenSleepingEnterActions = {
standby = 1;
hybridSleep = 2;
Expand All @@ -31,7 +38,7 @@ let
doNothing = 0;
sleep = 1;
hibernate = 2;
shutdown = 8;
shutDown = 8;
lockScreen = 32;
turnOffScreen = 64;
};
Expand Down Expand Up @@ -81,7 +88,7 @@ let
whenLaptopLidClosed = lib.mkOption {
type = with lib.types; nullOr (enum (builtins.attrNames whenLaptopLidClosedActions));
default = null;
example = "shutdown";
example = "shutDown";
description = ''
The action, when on ${type}, to perform when the laptop lid is closed.
'';
Expand Down Expand Up @@ -157,6 +164,29 @@ let
'';
};
};
displayBrightness = lib.mkOption {
type = with lib.types; nullOr (ints.between 0 100);
default = null;
example = 10;
description = ''
The brightness to set the display to in this mode
'';
};
powerProfile = lib.mkOption {
type =
with lib.types;
nullOr (enum [
"performance"
"balanced"
"powerSaving"
]);
default = null;
example = "powerSaving";
description = ''
The Power Profile to Enter in this mode
'';
apply = profile: if profile == "powerSaving" then "power-saver" else profile;
};
};

# By the same logic as createPowerDevilOptions, we can generate the
Expand Down Expand Up @@ -184,7 +214,20 @@ let
true
else
null;
DimDisplayIdleTimeoutSec = cfg.powerdevil.${optionsName}.dimDisplay.idleTimeout;
DimDisplayIdleTimeoutSec =
if (cfg.powerdevil.${optionsName}.dimDisplay.idleTimeout != null) then
cfg.powerdevil.${optionsName}.dimDisplay.idleTimeout
else if (cfg.powerdevil.${optionsName}.dimDisplay.enable == false) then
-1
else
null;
DisplayBrightness = cfg.powerdevil.${optionsName}.displayBrightness;
UseProfileSpecificDisplayBrightness = (
if (cfg.powerdevil.${optionsName}.displayBrightness == null) then null else true
);
};
"${cfgSectName}/Performance" = {
PowerProfile = cfg.powerdevil.${optionsName}.powerProfile;
};
};
in
Expand Down Expand Up @@ -280,6 +323,33 @@ in
'';
};
};
batteryLevels = {
lowLevel = lib.mkOption {
type = with lib.types; nullOr (ints.between 0 100);
default = null;
example = 10;
description = ''
The battery level considered "low" for the laptop
'';
};
criticalLevel = lib.mkOption {
type = with lib.types; nullOr (ints.between 0 100);
default = null;
example = 2;
description = ''
The battery level considered "critical" for the laptop
'';
};
criticalAction = lib.mkOption {
type = with lib.types; nullOr (enum (builtins.attrNames autoCriticalActions));
default = null;
example = "shutDown";
description = ''
The action to perform when Critical Battery Level is reached
'';
apply = action: if (action == null) then null else autoCriticalActions."${action}";
};
};
};
};

Expand All @@ -292,6 +362,11 @@ in
General = {
pausePlayersOnSuspend = cfg.powerdevil.general.pausePlayersOnSuspend;
};
BatteryManagement = {
BatteryCriticalAction = cfg.powerdevil.batteryLevels.criticalAction;
BatteryCriticalLevel = cfg.powerdevil.batteryLevels.criticalLevel;
BatteryLowLevel = cfg.powerdevil.batteryLevels.lowLevel;
};
}
);
};
Expand Down

0 comments on commit 508a077

Please sign in to comment.