keyd icon indicating copy to clipboard operation
keyd copied to clipboard

Daemon is running, but still fail on KDE/Wayland (And internal SyntaxWarning)

Open Majoramari opened this issue 6 months ago • 3 comments

Running keyd-application-mapper on Arch Linux with KDE Plasma on Wayland produces two issues:

1. SyntaxWarning

/usr/bin/keyd-application-mapper:476: SyntaxWarning: invalid escape sequence '\W'
  return re.sub('[\W_]+', '-', s).strip('-').lower()

2. Socket connection failure under KDE/Wayland

ERROR: Failed to connect to "/var/run/keyd.socket", make sure the daemon is running and you have permission to access the socket.

Occurs even though the keyd daemon is active and the user is a member of the keyd group.

● keyd.service - key remapping daemon
     Loaded: loaded (/usr/lib/systemd/system/keyd.service; enabled; preset: disabled)
     Active: active (running) since Sun 2025-08-31 10:24:40 EEST; 9min ago
       Main PID: 13712 (keyd)
        Tasks: 1 (limit: 18841)
        Memory: 508K (peak: 1.8M)
        CPU: 460ms
     CGroup: /system.slice/keyd.service
             └─13712 /usr/bin/keyd

Steps to Reproduce

  1. Install keyd and keyd-application-mapper and dependencies:
sudo pacman -S keyd python python-dbus python-xlib
  1. Start and enable the daemon:
sudo systemctl enable --now keyd
  1. Create a simple per-app config:
# ~/.config/keyd/app.conf
[kitty]
pageup = delete
  1. Run the mapper:
keyd-application-mapper

Environment / System Info

  • OS: Arch Linux
  • Desktop Environment: KDE Plasma
  • Display Server: Wayland
  • Python version: 3.13 (tried 3.11.9)
  • keyd version: 2.5.0
  • Full log:
❯ keyd-application-mapper
/usr/bin/keyd-application-mapper:476: SyntaxWarning: invalid escape sequence '\W'
  return re.sub('[\W_]+', '-', s).strip('-').lower()
kde detected
ERROR: Failed to connect to "/var/run/keyd.socket", make sure the daemon is running and you have permission to access the socket.
ERROR: Failed to connect to "/var/run/keyd.socket", make sure the daemon is running and you have permission to access the socket.
ERROR: Failed to connect to "/var/run/keyd.socket", make sure the daemon is running and you have permission to access the socket.
ERROR: Failed to connect to "/var/run/keyd.socket", make sure the daemon is running and you have permission to access the socket.
ERROR: Failed to connect to "/var/run/keyd.socket", make sure the daemon is running and you have permission to access the socket.
^CTraceback (most recent call last):
  File "/usr/bin/keyd-application-mapper", line 506, in <module>
    mon.run()
    ~~~~~~~^^
  File "/usr/bin/keyd-application-mapper", line 171, in run
    gi.repository.GLib.MainLoop().run()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/gi/overrides/GLib.py", line 495, in run
    with register_sigint_fallback(self.quit):
         ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3.13/contextlib.py", line 148, in __exit__
    next(self.gen)
    ~~~~^^^^^^^^^^                                                                  File "/usr/lib/python3.13/site-packages/gi/_ossighelper.py", line 239, in register_sigint_fallback                                                                    signal.default_int_handler(signal.SIGINT, None)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^                               KeyboardInterrupt

Majoramari avatar Aug 31 '25 07:08 Majoramari

Same is happening to me.

serranomorante avatar Sep 16 '25 23:09 serranomorante

Same is happening to me.

For the /var/run/keyd.socket error I just had to restart my computer after adding my user to the keyd group.

For the invalid escape sequence '\W' I modified the keyd-application-mapper python file to include an extra backslash like this: \\W, then compiled keyd from source (very easy as keyd don't need too much dependencies).

And with that it should work on arch+KDE+kwin as window manager.

If anyone don't use kwin but dwm (as me) they need an extra step, they not only need to patch the \\W line, but also several other lines in the keyd-application-mapper.

You can look at it on my commit

serranomorante avatar Sep 17 '25 17:09 serranomorante

@Majoramari first check weather the keyd is running or not by running this systemctl status keyd if its not running enable the service by this command sudo systemctl enable --now keyd if its running then check if the socket is persistent or not by running this command and you should see some thing like this,

ls -l /var/run/keyd.socket
srw-rw---- 1 root keyd 0 Nov  3 00:08 /var/run/keyd.socket

if not than add youself to keyd's group as this program fundamentally controls this input so the devloper has made this not to be used by everyone sudo usermod -aG keyd $USER

now check you should not get this ERROR: Failed to connect to "/var/run/keyd.socket"

Sandyeee0094 avatar Nov 03 '25 05:11 Sandyeee0094