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

loginctl lock-session isn't working as services.xserver.xautolock.locker #67350

Closed
misuzu opened this issue Aug 23, 2019 · 1 comment
Closed

Comments

@misuzu
Copy link
Contributor

misuzu commented Aug 23, 2019

I'm trying to setup xautolock with slimlock as locker. Using slimlock directly as services.xserver.xautolock.locker does not preserve SLIM_CFGFILE and SLIM_THEMESDIR environment variables so slimlock uses default slim theme.
There is workaround to start slimlock via xss-lock triggered by loginctl lock-session but here is what i get:

Aug 23 16:26:08 localhost xautolock[27959]: Failed to issue method call: Caller does not belong to any known session

Seems that loginctl lock-session wants $XDG_SESSION_ID (systemd/systemd#6032) but xautolock process does not have it.

Adding $XDG_SESSION_ID here may be a fix for this.

${config.systemd.package}/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS

Here is what home-manager does: https://github.com/rycee/home-manager/blob/eb1b86a5ec7baf1a1ce2c277d568a8751c24a7ee/modules/xsession.nix#L80

Maybe adding some kind of importedVariables option is even better.

My xserver config:

{ config, pkgs, ... }:

{
  services.xserver = {
    enable = true;
    autorun = true;

    displayManager = {
      slim = {
        enable = true;
        theme = pkgs.fetchurl {
          url = "https://maxwell.ydns.eu/git/rnhmjoj/nix-slim/archive/0.3.0.tar.gz";
          sha256 = "1m0l1bmagxq4i8db51ldgxwpyhrqh9fnm4szqcz871r8q3fqgl3k";
        };
      };
    };

    xautolock = {
      enable = true;
      locker = ''${pkgs.systemd}/bin/loginctl lock-session ''${XDG_SESSION_ID}'';
      time = 1;
    };

    windowManager.dwm.enable = true;

    desktopManager = {
      default = "none";
      xterm.enable = false;
    };
  };
  environment.systemPackages = with pkgs; [
    xss-lock
  ];
}

To Reproduce
Steps to reproduce the behavior:

  1. Use config from above
  2. Login to your account
  3. Start xss-lock: xss-lock -- slimlock &
  4. Run loginctl lock-session to make sure xss-lock is working
  5. Login to your account again
  6. Wait one minute and check logs: journalctl --user -u xautolock

Expected behavior
slimlock starts with correct theme

Metadata

% nix run nixpkgs.nix-info -c nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 5.2.9, NixOS, 19.09pre190139.54c76638733 (Loris)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.2.2`
 - channels(root): `"nixos-19.09pre190139.54c76638733, home-manager"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
- services.xserver.xautolock.locker
# a list of nixos modules affected by the problem
module:
- services.xserver.displayManager
- services.xserver.xautolock
@misuzu
Copy link
Contributor Author

misuzu commented Oct 9, 2019

services.xserver.displayManager.sessionCommands = pkgs.lib.mkAfter ''
  ${pkgs.xss-lock}/bin/xss-lock -- ${pkgs.slim}/bin/slimlock &
  ${pkgs.xorg.xset}/bin/xset s 300
'';

This did the trick.

@misuzu misuzu closed this as completed Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant