Skip to content

Clarify how to autostart with systemd after new security model #319

@heyzec

Description

@heyzec

Version Information:

  • Distribution: NixOS
  • swhkd version: Simple-Wayland-HotKey-Daemon 1.3.0-dev, built off c5c4071

After #270, the docs at https://github.com/waycrate/swhkd/tree/main/contrib/init/systemd for autostarting swhkd/swhks using systemd is outdated because pkexec is not longer required.

I tried to create a systemd service that starts swhkd on its own (while swhks is started by my compositor). However, once any keybind is triggered, swhkd coredumps and crashes:

Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z TRACE swhkd] Logger initialized.
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z DEBUG swhkd::perms] Setting EGID...
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z DEBUG swhkd::perms] Setting EUID...
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z DEBUG swhkd::perms] Setting initgroups...
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z DEBUG swhkd] Wating for server to start...
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z INFO  swhkd] Env refreshed
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z TRACE swhkd] Environment Aquired
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z TRACE swhkd] Setting process umask.
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z TRACE swhkd] Reading /run/user/1000/swhkd_4294967295.pid file and checking for running instances.
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z DEBUG swhkd] Previous PID: 6644
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z DEBUG swhkd] Using config file path: "/home/heyzec/.config/swhkd/swhkdrc"
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z DEBUG swhkd] 1 Keyboard device(s) detected.
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z ERROR swhkd] Could not open evdev device at /dev/input/mouse0: Inappropriate ioctl for device (os error 25)
Sep 06 12:49:50 devpad swhkd-start[17859]: [2025-09-06T04:49:50Z TRACE swhkd] Other: swhkd switches virtual output
...omitted...
Sep 06 13:07:36 devpad systemd-coredump[33005]: [🡕] Process 17859 (swhkd) of user 0 dumped core.
                                                
                                                Module /nix/store/1bdckwi5ki5n3mw589l99h8j9vbslazd-swhkd-c5c4071459a6465a3743a8bb5bb990e27cdf315b/bin/swhkd without build-id.
                                                Module libcap.so.2 without build-id.
                                                Module libgcc_s.so.1 without build-id.

From above, swhkd is using /run/user/1000/swhkd_4294967295.pid as the IPC socket. From

fn get_uid() -> Result<u32, Box<dyn Error>> {
we see 4294967295 (equivalent to -1 for 32-bit unsigned) is obtained from /proc/{}/loginuid. Login UID is unset when launched directly from systemd.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions