mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-27 08:04:14 +00:00
1da7dfa57d
We also take advantage of that change to point to the new dbus canonical names.
58 lines
1.8 KiB
Nix
58 lines
1.8 KiB
Nix
import ./make-test-python.nix ({ pkgs, ... }:
|
|
|
|
{
|
|
name = "power-profiles-daemon";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [ mvnetbiz ];
|
|
};
|
|
nodes.machine = { pkgs, ... }: {
|
|
security.polkit.enable = true;
|
|
services.power-profiles-daemon.enable = true;
|
|
environment.systemPackages = [ pkgs.glib pkgs.power-profiles-daemon ];
|
|
};
|
|
|
|
testScript = ''
|
|
def get_profile():
|
|
return machine.succeed(
|
|
"""gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
|
|
--method org.freedesktop.DBus.Properties.Get 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile'
|
|
"""
|
|
)
|
|
|
|
|
|
def set_profile(profile):
|
|
return machine.succeed(
|
|
"""gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
|
|
--method org.freedesktop.DBus.Properties.Set 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
|
|
""".format(
|
|
profile=profile
|
|
)
|
|
)
|
|
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
set_profile("power-saver")
|
|
profile = get_profile()
|
|
if not "power-saver" in profile:
|
|
raise Exception("Unable to set power-saver profile")
|
|
|
|
|
|
set_profile("balanced")
|
|
profile = get_profile()
|
|
if not "balanced" in profile:
|
|
raise Exception("Unable to set balanced profile")
|
|
|
|
# test powerprofilectl CLI
|
|
machine.succeed("powerprofilesctl set power-saver")
|
|
profile = get_profile()
|
|
if not "power-saver" in profile:
|
|
raise Exception("Unable to set power-saver profile with powerprofilectl")
|
|
|
|
machine.succeed("powerprofilesctl set balanced")
|
|
profile = get_profile()
|
|
if not "balanced" in profile:
|
|
raise Exception("Unable to set balanced profile with powerprofilectl")
|
|
'';
|
|
})
|