You are not logged in.

#26 2020-07-25 20:56:07

neopium
Member
Registered: 2019-05-02
Posts: 85

Re: [SOLVED] Can't start sxhkd as a systemd service

seth wrote:

My guess is that WantedBy=default.target means my service is started *before* default.target.

I'm pretty sure it works™ but something™ still alters the keyboard config, resulting in a different keyboard map and invalidating the sxhkd key grabs.

I don't understand why it would work™ while the status of the unit says it's not running. It really works™ once I start it manually or when I add a 2s sleep delay. Otherwise sxhkd *crashes* (but I don't have an error message this time). It just says it crashed.

*Edit*:
See https://imgur.com/a/q46tI76

Last edited by neopium (2020-07-25 21:00:16)

Offline

#27 2020-07-25 21:01:31

seth
Member
Registered: 2012-09-03
Posts: 49,957

Re: [SOLVED] Can't start sxhkd as a systemd service

The only mention of a crash so far hags been https://bbs.archlinux.org/viewtopic.php … 5#p1917325 and I thought https://bbs.archlinux.org/viewtopic.php … 2#p1917392 had resolved https://bbs.archlinux.org/viewtopic.php … 0#p1917360 because you said "And it worked."…

Online

#28 2020-07-25 21:07:12

neopium
Member
Registered: 2019-05-02
Posts: 85

Re: [SOLVED] Can't start sxhkd as a systemd service

seth wrote:

That should not require further xkbmap changes… however:

What if you play w/ the "-m 1" parameter? It indicates that you had to cover for at least one mapping event. Maybe
a) this is no longer the case and you can just omit the parameter
b) you're now facing 2 or more changes

I removed the -m 1 argument entirely and I have the same result, i.e. sxhkd does not start automatically, but works when started manually (with systemctl --user start sxhkd.service). Surprisingly, the -m 1 argument didn't change anything. I would have expected that changing the workspace with "super+é" to go to the worspace 2 wouldn't have worked... but it does

Offline

#29 2020-07-25 21:08:49

neopium
Member
Registered: 2019-05-02
Posts: 85

Re: [SOLVED] Can't start sxhkd as a systemd service

seth wrote:

The only mention of a crash so far hags been https://bbs.archlinux.org/viewtopic.php … 5#p1917325 and I thought https://bbs.archlinux.org/viewtopic.php … 2#p1917392 had resolved https://bbs.archlinux.org/viewtopic.php … 0#p1917360 because you said "And it worked."…

My bad, I wasn't clear enough.

Let's recap.

What works:
- When I add a 2 sec delay before starting the service, with:

[Unit]
Description=Simple X Hotkey Daemon
Documentation=man:sxhkd(1)

[Service]
ExecStartPre=/usr/bin/sleep 2
ExecStart=/usr/bin/sxhkd
ExecReload=/usr/bin/kill -SIGUSR1 $MAINPID

[Install]
WantedBy=default.target

- When I start it manually with systemctl --user start sxhkd (with or without the `ExecStartPre=/usr/bin/sleep 2` command)

What does not work (see https://imgur.com/a/q46tI76):
- When I remove the 2 sec delay and only enable the service to be launched at startup with

[Unit]
Description=Simple X Hotkey Daemon
Documentation=man:sxhkd(1)

[Service]
ExecStart=/usr/bin/sxhkd
ExecReload=/usr/bin/kill -SIGUSR1 $MAINPID

[Install]
WantedBy=default.target

Using `-m 1` or not does not change the behaviour

Last edited by neopium (2020-07-25 21:17:34)

Offline

#30 2020-07-25 22:00:34

seth
Member
Registered: 2012-09-03
Posts: 49,957

Re: [SOLVED] Can't start sxhkd as a systemd service

The last case is probably executed before lightdm has imported the environment into your session .
https://wiki.archlinux.org/index.php/Sy … XAUTHORITY

Not sure if this works:

ExecStartPre=systemctl --user import-environment DISPLAY XAUTHORITY

Online

#31 2020-07-26 08:05:15

neopium
Member
Registered: 2019-05-02
Posts: 85

Re: [SOLVED] Can't start sxhkd as a systemd service

seth wrote:

The last case is probably executed before lightdm has imported the environment into your session .
https://wiki.archlinux.org/index.php/Sy … XAUTHORITY

Not sure if this works:

ExecStartPre=systemctl --user import-environment DISPLAY XAUTHORITY

No luck: https://imgur.com/a/2q7A29d

The ExecStartPre instruction is successful, not the ExecStart one.

Offline

#32 2021-02-21 21:14:18

neopium
Member
Registered: 2019-05-02
Posts: 85

Re: [SOLVED] Can't start sxhkd as a systemd service

As mentioned here, even if it seemed to work, running sxhkd with systemd does NOT work as far as I know. It leads to the environment not being loaded properly.

Anyway. Just don't do it, there might be other side effects. I don't think it's worth the effort anyway.

Offline

#33 2022-07-14 03:24:46

Sidharta
Member
Registered: 2022-07-14
Posts: 1

Re: [SOLVED] Can't start sxhkd as a systemd service

I had the exact same problem, and figured out a solution that works for me

What I did was list my user systemd services using

systemctl --user list-units --type=service

and look for a service that initializes with or after my display manager. In my case, the best thing was

xdg-desktop-portal.service

I then added this service as an "After" and "Wants" section to my sxhkd systemd unit file, which ended up like this:

[Unit]
Description=sxhkd init service
Documentation=man:sxhkd(1)
After=xdg-desktop-portal.service
Wants=xdg-desktop-portal.service

[Service]
Type=simple
ExecReload=/usr/bin/kill -SIGUSR1 $MAINPID
ExecStart=/usr/bin/sxhkd

[Install]
WantedBy=default.target

And it worked as intended! It seems a bit hacky, but I couldn't find a better solution.
I hope this serves as reference for future users.

Offline

Board footer

Powered by FluxBB