jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
3.21k stars 131 forks source link

kanata.service error finding config file #1179

Closed garcialn closed 4 months ago

garcialn commented 4 months ago

Requirements

Describe the bug

Problem

I installed kanata and running with sudo ~/.cargo/bin/kanata -c ~/.config/kanata/config.kbd it works fine, and with sh -c 'exec $(which kanata) --cfg $HOME/.config/kanata/config.kbd', it also works, but when trying to run with systemctl --user start kanata.service (so that it can run while booting), i get the 127 status code return (exit code).

Setup

Relevant kanata config

.config/systemd/user/kanata.service

[Unit]
Description=Kanata keyboard remapper
Documentation=https://github.com/jtroo/kanata

[Service]
Environment=PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin
Environment=DISPLAY=:0
Type=simple
ExecStart=/usr/bin/sh -c 'exec $$(which kanata) --cfg $${HOME}/.config/kanata/config.kbd'
Restart=no

[Install]
WantedBy=default.target

.config/kanata/config.kbd

;; Kanata config for <CAPSLCK> to CAPSLCK+CTRL

(defsrc
  caps
  alt
)

(defalias
  capsctrl (tap-hold 200 200 caps lctrl)
  altesc (tap-hold 200 200 esc alt )
)

(deflayer base
  @capsctrl
  @altesc
)

To Reproduce

  1. Docs steps 1-5a

Expected behavior

Run kanata.service with no problems.

Kanata version

kanata 1.6.1

Debug logs

I did go through the linux setup doc (including the input and uinput to my user group, and adding the udev rule), but when getting to the final part, running systemctl --user status kanata.service, this is the output:

× kanata.service - Kanata keyboard remapper
     Loaded: loaded (/home/garcia-ln/.config/systemd/user/kanata.service; enabled; vendo>
     Active: failed (Result: exit-code) since Fri 2024-08-02 19:05:42 -03; 4ms ago
       Docs: https://github.com/jtroo/kanata
    Process: 15795 ExecStart=/usr/bin/sh -c exec $$(which kanata) --cfg $${HOME}/.config>
   Main PID: 15795 (code=exited, status=127)
        CPU: 3ms

ago 02 19:05:42 pop-pizza systemd[3106]: Started Kanata keyboard remapper.
ago 02 19:05:42 pop-pizza sh[15795]: /usr/bin/sh: 1: exec: --cfg: not found
ago 02 19:05:42 pop-pizza systemd[3106]: kanata.service: Main process exited, code=exite>
ago 02 19:05:42 pop-pizza systemd[3106]: kanata.service: Failed with result 'exit-code'.

Operating system

Linux

Additional context

From the output of systemctl --user status kanata.service', it shows problem with the.config/kanata/config.kbd... I tried changing the config file location (and changing also the reference to it inkatana.service`), but nothing changed... I'm gonna keep trying something about it until debugging shows me it's something else... If someone has any idea of what the problem might be, i'd be thankful for the info... 😉

jtroo commented 4 months ago

Maybe simplify and instead of this:

try the absolute path instead:

garcialn commented 4 months ago

I did try but got the same response from systemctl --user status kanata.service .

jtroo commented 4 months ago

Oh I skimmed over the error too quickly.

Looks like the same problem as in this comment: https://github.com/jtroo/kanata/issues/1153#issuecomment-2265690809

kanata isn't found in $PATH of the systemd env.

garcialn commented 4 months ago

It was, indeed, the $PATH var that cause the problem. Just changed locations and it worked correctly. Thank you for the help and congrats for the amazing project!!