summary refs log blame commit diff
path: root/nixos/tests/xss-lock.nix
blob: 71f56e32c58a29963f5b15a29dd4b09cf10a67f0 (plain) (tree)
1
2
3
4
5
6
7
8
                                                  




                    
                                                         
 



                                                               
                                                      



                                                               
                                                      






                                                                                     


                 













                                                                   

     
import ./make-test-python.nix ({ pkgs, lib, ... }:

with lib;

{
  name = "xss-lock";
  meta.maintainers = with pkgs.lib.maintainers; [ ma27 ];

  nodes = {
    simple = {
      imports = [ ./common/x11.nix ./common/user-account.nix ];
      programs.xss-lock.enable = true;
      test-support.displayManager.auto.user = "alice";
    };

    custom_lockcmd = { pkgs, ... }: {
      imports = [ ./common/x11.nix ./common/user-account.nix ];
      test-support.displayManager.auto.user = "alice";

      programs.xss-lock = {
        enable = true;
        extraOptions = [ "-n" "${pkgs.libnotify}/bin/notify-send 'About to sleep!'"];
        lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant";
      };
    };
  };

  testScript = ''
    def perform_xsslock_test(machine, lockCmd):
        machine.start()
        machine.wait_for_x()
        machine.wait_for_unit("xss-lock.service", "alice")
        machine.fail(f"pgrep {lockCmd}")
        machine.succeed("su -l alice -c 'xset dpms force standby'")
        machine.wait_until_succeeds(f"pgrep {lockCmd}")


    with subtest("simple"):
        perform_xsslock_test(simple, "i3lock")

    with subtest("custom_cmd"):
        perform_xsslock_test(custom_lockcmd, "xlock")
  '';
})