Closed spikespaz closed 2 years ago
Does systemctl --user show-environment
include WAYLAND_DISPLAY
? What about XDG_SESSION_ID
?
I can confirm they are set. I do not have access to the system at the moment but @fufexan can also verify.
@spikespaz try adding {pkgs.swaylock}/bin
to the Environment
PATH
, or manually using "${pkgs.swaylock}/bin/swaylock"
. SystemD services do not inherit the user PATH.
Using the above works for me.
@spikespaz try adding
{pkgs.swaylock}/bin
to theEnvironment
PATH
, or manually using"${pkgs.swaylock}/bin/swaylock"
. SystemD services do not inherit the user PATH.Using the above works for me.
Alternatively, if you're configuring the service from a central location (as with NixOS or home-manager), you could instead hard-code the binary path. I personally have my exec statement like
ExecStart=${pkgs.swayidle}/bin/swayidle timeout 5 '${pkgs.swaylock}/bin/swaylock --daemonize'
It's probably a more "declarative" way, since that way it doesn't rely on PATH
.
@houstdav000 That's what I'm currently doing.
Fufexan's suggestion was to add the binary to PATH
only for the systemd unit. It won't affect anything else.
I have the following systemd unit:
I can confirm that it starts successfully.
I have the following lines in my config for the Hyprland window manager:
Hopefully they are self-explanatory. The second line should have set any environment variables for swayidle, but I can see that it only cares about XDG directories according to the source code.
Note that when I run that command that is in the unit directly in the command line, it executes the swaylock command after 5 seconds as expected.