swaywm/swayidle

systemd user service

efouladi opened this issue · 6 comments

I've been trying to write a systemd user unit for swayidle. However swayidle fails to run swaylock with error execve failed!: No such file or directory

Here is my systemd service:

[Unit]
After=graphical-session.target
Description=Idle manager for Wayland
Documentation=man:swayidle(1)
PartOf=graphical-session.target

[Service]
Environment="LOCALE_ARCHIVE=/nix/store/xyzmznz9gjw0p78vmgfwwn813gnzpk9n-glibc-locales-2.30/lib/locale/locale-archive"
Environment="PATH=/nix/store/0fscv6z3qi2bsb8j8nfvnz52b37svx5w-swayidle-04a176ee91aee6cca45aa91b95f2626ecb2fbb28/bin:/nix/store/5msjs7cwfvxgvk7xzq47ncl47w0f5v53-swaylock-a99afe6a7075c962da72b140f02e18318052d833/bin:/nix/store/5k6nk721b96wij41723kxgjdijz7dkdj-sway-8b2ff2f1b3c03df9ec5573fe74ed076776869559/bin:/nix/store/3k8lm51wqhl7nyr55l9cn9w2glqbdw7n-coreutils-8.31/bin:/nix/store/asp8xjybxrwmirai24h8mvdz4plg3904-findutils-4.7.0/bin:/nix/store/fpmxrgczd54b2b0kspdi3c44m6hpxbzi-gnugrep-3.4/bin:/nix/store/abrakd4qy9py5s1mys72583r08mamkgc-gnused-4.8/bin:/nix/store/mygdcfxbghd8wa9jwa3p400bnz8k8sl1-systemd-245.5/bin:/nix/store/0fscv6z3qi2bsb8j8nfvnz52b37svx5w-swayidle-04a176ee91aee6cca45aa91b95f2626ecb2fbb28/sbin:/nix/store/5msjs7cwfvxgvk7xzq47ncl47w0f5v53-swaylock-a99afe6a7075c962da72b140f02e18318052d833/sbin:/nix/store/5k6nk721b96wij41723kxgjdijz7dkdj-sway-8b2ff2f1b3c03df9ec5573fe74ed076776869559/sbin:/nix/store/3k8lm51wqhl7nyr55l9cn9w2glqbdw7n-coreutils-8.31/sbin:/nix/store/asp8xjybxrwmirai24h8mvdz4plg3904-findutils-4.7.0/sbin:/nix/store/fpmxrgczd54b2b0kspdi3c44m6hpxbzi-gnugrep-3.4/sbin:/nix/store/abrakd4qy9py5s1mys72583r08mamkgc-gnused-4.8/sbin:/nix/store/mygdcfxbghd8wa9jwa3p400bnz8k8sl1-systemd-245.5/sbin"
Environment="TZDIR=/nix/store/zkf26f1f58axgr5fh5pwvi7js3jrma5r-tzdata-2019c/share/zoneinfo"



ExecStart=/nix/store/0fscv6z3qi2bsb8j8nfvnz52b37svx5w-swayidle-04a176ee91aee6cca45aa91b95f2626ecb2fbb28/bin/swayidle -d -w \
   timeout 5 'swaylock -f -c 000000' \
   timeout 10 'swaymsg "output * dpms off"' \
   resume 'swaymsg "output * dpms on"' \
   before-sleep 'swaylock -f -c 000000'

Type=simple

As you can see I add swaylock and sway paths to PATH environment variable for the service. I also tried passing swaylock with full path in the ExecStart command but it didn't make a difference.

Sorry, running as a systemd service is not supported.

Then why is it promoted in the official sway wiki: https://github.com/swaywm/sway/wiki/Systemd-integration

Also could you please not close my issues before I get a chance to reply to you?

Your issue lies with NixOS and not with swayidle. Swayidle invokes sh to run the commands, however as can be seen by looking at your $PATH, none of these include the sh binary. For my local service file, I use Environment=PATH=/run/current-system/sw/bin to ensure that sh can be found in $PATH.

Sorry, running as a systemd service is not supported.

@emersion any reasoning for why? Not that this is about swayidle, not about sway. swayidle in my experience runs perfectly fine as a user service.

Scratch that, I read "not supported" as "not working" instead of "not supported by upstream". I also remember there being some problems to register with logind to get the idle inhibition and lock signals if running as a user service, so this is a perfectly fine position to take. Sorry for the noise.

Yes the same here. I misread "not supported" as "not working"

Then why is it promoted in the official sway wiki

The official sway wiki is entirely community-maintained. This systemd page isn't written/endorsed by Sway core contributors.

I misread "not supported" as "not working"

Not supported means "you're on your own if it doesn't work". We don't have the bandwidth to debug systemd-specific issues.

Also could you please not close my issues before I get a chance to reply to you?

If something is not supported, there's no point in keeping the issue opened.