Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using keyd for key-remapping breaks warpd #242

Closed
janmejay opened this issue Jun 22, 2022 · 7 comments
Closed

Using keyd for key-remapping breaks warpd #242

janmejay opened this issue Jun 22, 2022 · 7 comments

Comments

@janmejay
Copy link

Sounds like this is something wrong in my local env. Keyd in isolation works great, I use basic config

[ids]

*

[main]

# Maps capslock to escape when pressed and control when held.
capslock = overload(control, esc)

# Remaps the escape key to capslock
esc = capslock

and warpd works great in isolation too (with xmodmap).

One of the (possibly unexpected) things I do is, instead of setting it up as a systemd service (I use openrc locally, btw) I launch it manually this way (inside the X session).

┌(pts/3) janmejay at js in ~/projects/keyd/bin on master [ Wed 22  1:12PM ]  ✘ 2
└(10020) (Gentoo) ±➤ sudo env KEYD_CONFIG_DIR=/home/janmejay/.dev_utils/rc/keyd ./keyd
Starting keyd v2.4.1 (bb49007)
socket: /var/run/keyd.socket
device added: 0001:0001 AT Translated Set 2 keyboard (/dev/input/event5)
        matched /home/janmejay/.dev_utils/rc/keyd/default.conf

I launch warpd the same way too

└(10006) (Gentoo) ±➤ ./bin/warpd -f
Starting warpd v1.2.2 (52ceb2c)

It all works until warpd grabs keyboard in say hint or normal mode. When keyd is in use, warpd does not receive any keystrokes at all.

Here is my warpd config

hint_activation_key: C-A-g
activation_key: C-A-f
hint_size: 36
hint_bgcolor: #f3e260
hint_fgcolor: #000000
left: C-b
down: C-n
up: C-p
right: C-f
scroll_down: j
scroll_up: k
start: C-a
end: C-e
indicator: topleft
hint_exit: q
exit: q
top: A-<
middle: C-l
bottom: A->
indicator_color: #f3e260
indicator_size: 8
hint: C-A-g g
hint_chars: abcdef;ghijklmnoprst'uvwx[yz
drag: C-space
copy_and_exit: A-w

I run xorg-server version 21.1.3-r2 and linux-kernel 5.17.0.

Is there something inherently wrong with the way I have set it up?

@rvaiya
Copy link
Owner

rvaiya commented Jun 22, 2022

You need to start warpd after the virtual device has been created. This usually isn't a problem if you start keyd as a system service before launching the X session (as inteded).

Running keyd using sudo in your xsession is a bad idea, you should create an openrc script and treat it like any other privileged daemon. You should also avoid setting KEYD_CONFIG_DIR directly, this is an internal variable that is subject to change (which is why it is not documented).

See also #105.

Edit:

Apologies, the above is no longer true. warpd used to rely on a xinput loophole which was sensitive to hotplugging for its grab logic, but that is no longer the case. The initialization order shouldn't matter as long as keyd is not restarted while warpd is in one of its active modes.

My recommendations above still apply for other reasons, though your configs should work as is unless you are mixing keyd and X input logic (which is a common mistake). Make sure other remapping tools aren't running (e.g xcape, xmodmap invocations, etc).

@janmejay
Copy link
Author

I set it up as an openrc-service and got it to start before display-manager.

┌(pts/2) janmejay at js in ~/projects/warpd on master! [ Wed 22  4:45PM ]  ✘ 1
└(10057) (Gentoo) ±➤ cat /etc/keyd/default.conf
[ids]

*

[main]

# Maps capslock to escape when pressed and control when held.
capslock = overload(control, esc)

# Remaps the escape key to capslock
esc = capslock

┌(pts/2) janmejay at js in ~/projects/warpd on master! [ Wed 22  4:48PM ]
└(10061) (Gentoo) ±➤ cat /etc/init.d/keyd
#!/sbin/openrc-run

command="/opt/keyd"
command_args=""
command_user="root:keyd"
description="keyd key-remap process"
pidfile="/var/run/keyd.pid"
command_background=true

depend() {
  before display-manager
}

┌(pts/2) janmejay at js in ~/projects/warpd on master! [ Wed 22  4:48PM ]
└(10062) (Gentoo) ±➤

All works well until warpd grabs input (in normal or hint mode).

Until I activate warpd everything works well, key-remap is in effect, I can use caps-lock as ctrl and esc as caps-lock.

Once activated, keystrokes still go to the window in focus. I can see them being typed on the terminal below. Because I continue to access the terminal, I tried stopping keyd while warpd hint-mode was active and warpd started to process keystrokes as soon as keyd stopped.

Are there any diagnostics I can perform / input I can provide that'll help diagnose this?

@janmejay
Copy link
Author

Looks like the fd warpd polls never receives key-events when keyd is running. The screenshot shows my key-strokes aa which was supposed to select the top-left hint on the gdb prompt (while breakpt 1 which is the very next line was never hit).
screenshot-20220622@171052

@rvaiya
Copy link
Owner

rvaiya commented Jun 22, 2022

Thanks. It looks like this was a regression. It should be fixed in the latest keyd commit.

@janmejay
Copy link
Author

@rvaiya can you point me to the commit you are using locally? I'll use that for now until you have a chance to fix this.

@rvaiya
Copy link
Owner

rvaiya commented Jun 23, 2022

To clarify, this has already been fixed on master.

@janmejay
Copy link
Author

Pulled the latest, it works great! thanks a lot! 🙇‍♂️

@rvaiya rvaiya closed this as completed Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants