Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant get suspend or hibernate working on NixOS #414

Open
1 task done
Daniel-McLarty opened this issue Jan 24, 2024 · 1 comment
Open
1 task done

Cant get suspend or hibernate working on NixOS #414

Daniel-McLarty opened this issue Jan 24, 2024 · 1 comment
Labels

Comments

@Daniel-McLarty
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Operating system

NixOS Stable 23.11

Installation method

Package Manager (from OS)

Betterlockscreen & Dependency-Versions

- Betterlockscreen:4.2.0
- i3lock-color:2.13.c.5
- ImageMagick:7.1.1-25
- dunst (if used):Version in NixOS repo
- feh (if used):Version in NixOS repo

Bug description

Even after translating the systemctl service to a version that works with NixOS I cant get sleep/suspend to work and trigger the lock screen. It is complaining of not getting authorization. Below is my configuration.nix for the systemd service and for my installed apps:

  # Set the X11 config.
  services.xserver = {
    enable = true;
    windowManager.awesome.enable = true;
    videoDrivers = ["nvidia"];
    libinput.mouse.accelProfile = "flat";
    displayManager.gdm.enable = true;
    xautolock = {
      enable = true;
      time = 1; # You can adjust this value according to your needs
      locker = "${pkgs.betterlockscreen}/bin/betterlockscreen --lock";
    };
  };

  # Custom Systemd setup.
  systemd.services = {
    "betterlockscreen@" = {
      description = "Lock screen when going to sleep/suspend";
      wantedBy = [ "sleep.target" "suspend.target" ];
      before = [ "sleep.target" "suspend.target" ];

      serviceConfig = {
        Type = "simple";
        Environment = "DISPLAY=:0";
        ExecStart = "${pkgs.betterlockscreen}/bin/betterlockscreen --lock --blur";
        ExecStartPost = "${pkgs.coreutils}/bin/sleep 1";
        TimeoutSec = "infinity";
      };
    };

    xss-lock = {
      description = "xss-lock integration";
      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];
      serviceConfig = {
        ExecStart = "${pkgs.xss-lock}/bin/xss-lock -- ${pkgs.betterlockscreen}/bin/betterlockscreen --lock";
        Restart = "always";
      };
    };
  };

  # Relevant installed apps
  environment.systemPackages = with pkgs; [
    dbus
    i3lock-color
    xss-lock
    betterlockscreen
    feh
    dunst
  ];

This could be something about my config, but from everything I found on making custom systemd services in NixOS this should work.

Steps to reproduce

  1. Use the relevant parts of my configuration.nix
  2. Rebuild and reboot
  3. Try to hibernate, sleep, or suspend
  4. It wont work
  5. If you try to start it manually it will start and work as expected, say for another bug where even with package.loaded["naughty.dbus"] = {} in AwesomeWM it will complain Error org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. and take a long time to run.

Relevant log output

systemctl status betterlockscreen@$USER
○ betterlockscreen@daniel.service - Lock screen when going to sleep/suspend
     Loaded: loaded (/etc/systemd/system/betterlockscreen@.service; static)
     Active: inactive (dead)

Jan 24 12:11:15 danielpc betterlockscreen[4316]:  -h, --help     display this help and exit
Jan 24 12:11:15 danielpc betterlockscreen[4316]:  -V, --version  output version information and exit
Jan 24 12:11:15 danielpc betterlockscreen[4316]: For more details see pgrep(1).
Jan 24 12:11:15 danielpc betterlockscreen[4299]: [*] Running prelock...
Jan 24 12:11:15 danielpc betterlockscreen[4299]: [*] Locking screen... (FAILSAFE MODE)
Jan 24 12:11:15 danielpc betterlockscreen[4317]: Authorization required, but no authorization protocol specified
Jan 24 12:11:15 danielpc betterlockscreen[4317]: i3lock-color: Could not connect to X11, maybe you need to set DISPLAY?
Jan 24 12:11:15 danielpc betterlockscreen[4299]: [*] Running postlock...
Jan 24 12:11:16 danielpc systemd[1]: betterlockscreen@daniel.service: Deactivated successfully.
Jan 24 12:11:16 danielpc systemd[1]: Started Lock screen when going to sleep/suspend.
@Daniel-McLarty
Copy link
Author

Update: I got it to half work with xss-lock, now it will lock on all the events as xss-lock is calling it. But this is still a half work as there is a massive delay in the time it takes to lock. I think it is related to part B of the NixOS bugs where even with package.loaded["naughty.dbus"] = {} in AwesomeWM rc.lua it will complain:

Error org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. Failed to communicate with dunst, is it running? Or maybe the version is outdated. You can try 'dunstctl debug' as a next debugging step.

and take a long time to run. I know that dunst must be running as dunstify "test" makes a popup, so I dont know why betterlockscreen cant see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant