Closed fluffychaos closed 1 week ago
I've also tried to escape the quotes with \'
but this resulted in a different error
kanata.service - Kanata keyboard remapper
Loaded: loaded (/etc/systemd/user/kanata.service; enabled; preset: disabled)
Drop-In: /usr/lib/systemd/user/service.d
└─10-timeout-abort.conf
Active: failed (Result: exit-code) since Wed 2024-07-24 15:52:30 CEST; 3s ago
Duration: 5ms
Docs: https://github.com/jtroo/kanata
Process: 11542 ExecStart=/usr/bin/sh -c 'exec $$(which kanata) --cfg $${HOME}/.config/kanata/config.kbd' (code=exited, status=2)
Main PID: 11542 (code=exited, status=2)
CPU: 4ms
Started kanata.service - Kanata keyboard remapper.
$(which: -c: line 1: unexpected EOF while looking for matching `''
kanata.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
kanata.service: Failed with result 'exit-code'.
Interesting 🤔
Any improvement to the doc would be welcome! This has apparently worked for someone since they contributed the suggestion, but perhaps it doesn't work in all versions/configurations of systemd.
In my case this error was caused by which
not finding the executable in $HOME/.cargo/bin. Copying it to /usr/local/bin fixed the issue. Haven't taken the time to figure out the solution or the problem so cannot share any more details.
I didn't have much time lately to look at this problem again, unfortunately, but thanks to the help on the systemd matrix room I now have a working solution not involving the shell at all.
[Unit]
Description=Kanata keyboard remapper
Documentation=https://github.com/jtroo/kanata
[Service]
Environment=PATH=%h/.cargo/bin
Environment=DISPLAY=:0
ExecSearchPath=%h/.cargo/bin
Type=simple
ExecStart=kanata --cfg %h/.config/kanata/kanata.kbd
Restart=no
[Install]
WantedBy=default.target
PATH
and ExecSearchPath
obviously needs to be adjusted if kanata was not installed via cargo but this executes kanata without the need for a shell exec. The %h
is a systemd specifier for the home directory of the user running the current service manager. So if you are currently the user Bob
and execute systemctl --user start kanata.service
%h
would resolve to /home/Bob
I should note that, in my case, I also had to set ExecSearchPath
in order for systemd to find kanata. Only setting PATH
did not suffice for me.
Requirements
Describe the bug
When using the systemd service file shown in
setup-linux.md
launching the service fails withsh
complaining about--
being an invalid option. The error messages are shown in the service logs. When executing the command contained inExecStart
manually inzsh
everything works. When looking at the command executed the'
quotes around theexec
block are missing.Relevant kanata config
kanata.service
To Reproduce
setup-linux.md
, into the actual service file on the systemsystemctl --user daemon-reload
systemctl --user start kanata.service
systemctl --user status kanata.service
Expected behavior
Seeing Kanata starting normally in the logs
Kanata version
1.6.1
Debug logs
Operating system
Linux
Additional context
The concrete OS is Fedora 40 with systemd version 255.8-1.fc40