sxhkd: sxhkd not starting as a systemd service
I’m trying to start sxhkd as a systemd service. I started by following the Arch Wiki and used the example file provided, but I can’t make it work.
There is an ongoing discussion on the subject on Arch forum.
What we tried so far:
- First, the systemd service unit must be started as a user, not as root.
The unit must be copied in the /etc/systemd/user/ folder and it must be enabled using systemctl --user enable sxhkd.service (no sudo!)
- Then the following lines are not necessary anymore
BindsTo=display-manager.service
After=display-manager.service
Because the display-manager service is not visible by the user, and anyway, when the user session starts, we are past this target.
- The WantedBy instruction must also be changed to:
WantedBy=default.target
because there is no grapical target visible by the user-level unit
Still, sxhkd crashes upon startup (see https://imgur.com/a/q46tI76 ). I can successfully start it manually afterwards however.
I’m stuck here because I don’t really know why sxhkd has crashed. Is there a way to have a log file that would explain why it crashes?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 18
I got a working solution on my Arch. In first I create
~/.config/systemd/user/sxhkd.servicefile by following lines:After it, I enable this service:
and reboot. So, it works:
Note: if you got error
sxhkd.service: Start request repeated too quickly., try to increaseRestartSecoption (2s on my example)I discovered
systemctl --user show-environment, and you’re completely right!Yeah, but at point systemd tries to use
SHELL(which it somehow guesses isfish) in conjunction withsxhkd.fishbreaks parts of my sxhkd config, and is possibly slower than other shells.In the end, I just added my prefered set of environment variables to
~/.config/environment.d/XYZ.conf, as outlined on the arch wiki , which was then reflected insystemctl --user show-environment. As such, I didn’t really have to add anEnvironment=line to the service, but could just overrideSHELLin said.conffile.sxhkdfinally runs fine as systemd service!@rien333 @shimarulin Adding
KillMode=processto[Service]should fix that problem!FYI you can place user units in
~/.config/systemd/user/too. That’s how I have it set up.As for the actual issue, I’m using some other hacks to run it as an service 😉
Is what I got in my
bspwmrc. Everytime bspwm is started/restarted, so is sxhkd. This way though,sxhkd.serviceis never enabled. I’ve also got more units set up like this (oof). I know it’s not really “how you’re supposed to do it” but I never really cared enough to solve it the “right” way by enabling them and setting up display manager targets and stuff.Okay but to actually tackle the issue: My guess is that sxhkd is starting before Xorg and this makes sxhkd crash. Can you get more output from sxhkd by doing
journalctl --user --boot -u sxhkd?