mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
24 lines
674 B
Nix
24 lines
674 B
Nix
{
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}: {
|
|
powerManagement.powertop.enable = true;
|
|
systemd.services.powertop.serviceConfig.ExecStartPost = let
|
|
deviceList = [
|
|
"ThinkPad Dock"
|
|
"Razer"
|
|
"YubiKey"
|
|
"Keychron"
|
|
];
|
|
inherit (lib.strings) concatMapStrings;
|
|
deviceCommands =
|
|
concatMapStrings (device: ''
|
|
for f in $(${pkgs.gnugrep}/bin/grep -Rl "${device}" /sys/bus/usb/devices/*/product); do
|
|
${pkgs.coreutils}/bin/echo on > $(dirname $f)/power/control
|
|
done
|
|
'')
|
|
deviceList;
|
|
execStartPost = pkgs.writeShellScriptBin "powertop-execStartPost" deviceCommands;
|
|
in "${execStartPost}/bin/powertop-execStartPost";
|
|
}
|