2020-09-15 11:15:48 +03:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "power-profiles-daemon";
|
2021-02-09 14:24:09 +03:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2020-09-15 11:15:48 +03:00
|
|
|
maintainers = [ mvnetbiz ];
|
|
|
|
};
|
2022-03-21 02:15:30 +03:00
|
|
|
nodes.machine = { pkgs, ... }: {
|
2023-04-19 17:21:15 +03:00
|
|
|
security.polkit.enable = true;
|
2020-09-15 11:15:48 +03:00
|
|
|
services.power-profiles-daemon.enable = true;
|
|
|
|
environment.systemPackages = [ pkgs.glib ];
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
def get_profile():
|
|
|
|
return machine.succeed(
|
|
|
|
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \
|
|
|
|
--method org.freedesktop.DBus.Properties.Get 'net.hadess.PowerProfiles' 'ActiveProfile'
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def set_profile(profile):
|
|
|
|
return machine.succeed(
|
|
|
|
"""gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \
|
|
|
|
--method org.freedesktop.DBus.Properties.Set 'net.hadess.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")
|
|
|
|
'';
|
|
|
|
})
|