1 import ./make-test-python.nix ({ pkgs, ... }:
4 name = "power-profiles-daemon";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ mvnetbiz ];
8 nodes.machine = { pkgs, ... }: {
9 security.polkit.enable = true;
10 services.power-profiles-daemon.enable = true;
11 environment.systemPackages = [ pkgs.glib pkgs.power-profiles-daemon ];
16 return machine.succeed(
17 """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
18 --method org.freedesktop.DBus.Properties.Get 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile'
23 def set_profile(profile):
24 return machine.succeed(
25 """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \
26 --method org.freedesktop.DBus.Properties.Set 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile' "<'{profile}'>"
33 machine.wait_for_unit("multi-user.target")
35 set_profile("power-saver")
36 profile = get_profile()
37 if not "power-saver" in profile:
38 raise Exception("Unable to set power-saver profile")
41 set_profile("balanced")
42 profile = get_profile()
43 if not "balanced" in profile:
44 raise Exception("Unable to set balanced profile")
46 # test powerprofilectl CLI
47 machine.succeed("powerprofilesctl set power-saver")
48 profile = get_profile()
49 if not "power-saver" in profile:
50 raise Exception("Unable to set power-saver profile with powerprofilectl")
52 machine.succeed("powerprofilesctl set balanced")
53 profile = get_profile()
54 if not "balanced" in profile:
55 raise Exception("Unable to set balanced profile with powerprofilectl")