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

Add package for keyd #744

Open
wants to merge 23 commits into
base: testing
Choose a base branch
from
Open

Add package for keyd #744

wants to merge 23 commits into from

Conversation

kiwiz
Copy link

@kiwiz kiwiz commented Oct 1, 2023

This PR adds keyd, a tool for remapping keys. It has been tested on an rM2.

No configuration is currently bundled. My intent is to create a separate keyd-configs package with community configs (and possibly a mechanism to automatically apply the right one for the active keymap).

package/keyd/default.conf Outdated Show resolved Hide resolved
package/keyd/package Outdated Show resolved Hide resolved
Co-authored-by: Nathaniel van Diepen <Eeems@users.noreply.github.com>
@Eeems Eeems self-requested a review October 2, 2023 19:29
@Eeems
Copy link
Member

Eeems commented Oct 2, 2023

I'll have to give this a test on my rM1 to make sure it works as expected. I assume you've tested the latest changes on your rM2 to make sure it works as expected?

@kiwiz
Copy link
Author

kiwiz commented Oct 2, 2023

I'll have to give this a test on my rM1 to make sure it works as expected. I assume you've tested the latest changes on your rM2 to make sure it works as expected?

Yep, all the keys appear to remap properly.

Testing tips:

  • Remaps should be as simple as:
[main]
a = x # remaps the a key to output x
  • Output of keyd should give you device ids, or you can just specify *

@Eeems Eeems added this to the 2023-W39 Merge Window milestone Oct 3, 2023
@Eeems Eeems added the packages Add or improve packages of the repository label Oct 21, 2023
@Eeems
Copy link
Member

Eeems commented Oct 27, 2023

image
So it looks like this won't work on the rM1 in 2.15.1. This will also fail to work on the rM2 for the same reason.

The keyd group also doesn't exist, and the default configuration expects it to exist. This will either need to fixed by the install scripts, or the configuration changed to not use the group.

@kiwiz
Copy link
Author

kiwiz commented Oct 30, 2023

Do you know what version the uinput module was enabled from? Should a version check be added to the package script?

@Eeems
Copy link
Member

Eeems commented Oct 30, 2023

Not offhand, it was one of the earlier 3.x versions I believe.
A version check doesn't make too much sense in the package, in reality we need to better support version limiting in the toltec repos themselves.

At this point, we will have to hold off on merging this until 3.x support is in progress.

@Eeems Eeems marked this pull request as draft November 24, 2023 20:59
@FouzR
Copy link

FouzR commented Dec 30, 2023

I just want to note that, when I installed the ipk from the build artifact, in the keyd.service, the expected line for ExecStart is /opt/bin/keyd. However, when I installed it, it was /usr/bin/keyd

So either we add a symlink, or try and fix this(which shouldn't happen considering it was supposed to be /opt/bin/keyd)

@Eeems
Copy link
Member

Eeems commented Dec 30, 2023

I just want to note that, when I installed the ipk from the build artifact, in the keyd.service, the expected line for ExecStart is /opt/bin/keyd. However, when I installed it, it was /usr/bin/keyd

So either we add a symlink, or try and fix this(which shouldn't happen considering it was supposed to be /opt/bin/keyd)

No we wouldn't want to have it be in /usr/bin. That's very odd that the file provided isn't being used. My guess is that the keyd source has its own copy of the service file that is replacing the one included in this repo.

@FouzR
Copy link

FouzR commented Dec 30, 2023

Yup, so I thought, why not copy over keyd.service later in the package code instead of at the very beginning(So maybe put it in a temp folder first)
So maybe just copy it over to /etc/systemd/system/ in configure()

@Eeems
Copy link
Member

Eeems commented Dec 30, 2023

I haven't looked too closely, but if there is a keyd.service file in the source that's overwriting the one included in the package folder, changing the order you install the files from the source directory wont do anything. The file isn't there to copy, because it's been replaced. The file will need to be renamed in this repo, and then renamed as part of package() when it's installing it to the final location in the package. Ideally the toltec build system (and toltecmk) should be updated to detect this kind of thing and error if there are files that are going to be clobbered.

@Etn40ff
Copy link

Etn40ff commented Dec 30, 2023

Checking for clobbered files it is probably hard: in this particular instance there is no overlapping in the sources, the problem arises at compiel time: https://github.com/rvaiya/keyd/blob/master/Makefile#L37

@Etn40ff
Copy link

Etn40ff commented Dec 30, 2023

In this particular case having a separate keyd.service is not needed: it suffices to add PREFIX=/opt/ to the build environment

@Eeems
Copy link
Member

Eeems commented Dec 31, 2023

In this particular case having a separate keyd.service is not needed: it suffices to add PREFIX=/opt/ to the build environment

A tiny bit more than that was required to do it properly, but it should be working now.

@Etn40ff
Copy link

Etn40ff commented Dec 31, 2023

This is still not working: the binary is /opt/bin/keyd but the service calls /opt/usr/bin/keyd. I think you are over engineering it a little, setting PREFIX should take care of the path in keyd.service

@Eeems
Copy link
Member

Eeems commented Dec 31, 2023

This is still not working: the binary is /opt/bin/keyd but the service calls /opt/usr/bin/keyd. I think you are over engineering it a little, setting PREFIX should take care of the path in keyd.service

It does not, which is why I added the sed line. I forgot that the default prefix is /usr. The latest code does, but we are dealing with the v2.4.3 tag which is missing some build process fixes.

@Etn40ff
Copy link

Etn40ff commented Dec 31, 2023

The latest code does, but we are dealing with the v2.4.3 tag which is missing some build process fixes.

This is annoying

@Eeems
Copy link
Member

Eeems commented Dec 31, 2023

The latest code does, but we are dealing with the v2.4.3 tag which is missing some build process fixes.

This is annoying

It is 😆 , the next time they push a release it will no longer be an issue.

@Eeems
Copy link
Member

Eeems commented Jan 13, 2024

For future reference when we get here, I think this is a good/sane default for the US layout. It at least makes the legends match what the keyboard actually outputs, and exposes some needed keys for terminal usage.

[ids]
2edd:0001 # type folio

[main]
end = layer(opt)
leftshift+end = layer(opt+shift)
= = -
\ = ~

[shift]
= = _
\ = `

[opt]
1 = esc
= = =
\ = \
0 = +
, = [
. = ]
right = end
left = home

[opt+shift]
\ = |
, = {
. = }
right = pagedown
left = pageup

Xochitl doesn't seem completely happy with allowing +/= on the 0/- keys though.

@FouzR
Copy link

FouzR commented Jan 17, 2024

Keyd seems to freak out on boot and has key-repeats even when the key is clicked once.. I have to restart the service to fix it

@Eeems
Copy link
Member

Eeems commented Jan 17, 2024

Keyd seems to freak out on boot and has key-repeats even when the key is clicked once.. I have to restart the service to fix it

I haven't experienced this. What settings are you using?

@FouzR
Copy link

FouzR commented Jan 17, 2024

[ids]
2edd:0001 # type folio

[main]
capslock = overload(control, esc) # Sets the capslock to act as Esc when tapped and Control when held
leftcontrol = overload(control, capslock) # similar or left control

# below 2 lines setup the layers for
# Opt and AltOpt on the Type Folio
end = layer(opt)
rightalt = layer(alternate)

[opt]
1 = esc
, = [
. = ]
/ = \
= = -
right = end
left = home
up = pageup
down = pagedown
backspace = delete

[alternate:G]
1 = f1
2 = f2
3 = f3
4 = f4
5 = f5
6 = f6
7 = f7
8 = f8
9 = f9
0 = f10
= = f11
backspace = f12

That’s my config fire

@Eeems
Copy link
Member

Eeems commented Jan 17, 2024

Have you checked the keyd logs to see if it has anything useful? It works by grabbing all other physical keyboard input and creating it's own evdev device with uinput to emit events from. uinput handles automatically emitting the key repeat events. Because of this, keyd might just have missed the event that the key was released.

@gustaphe
Copy link

For the scandinavian keyboard (and others that need non-ascii input keys), one would need xkbmap to make the compose-hack work.

@Eeems Eeems marked this pull request as ready for review May 20, 2024 23:22
@plredmond
Copy link

plredmond commented Jun 27, 2024

I've tested a2ab078 (build 9670591399) on an rm2 at 3.3.2.1666.

Upon installation, it instructed me to disable the shutdown target, which seems not relevant.
reMarkable: ~/ opkg install keyd_2.4.3-1_rmall.ipk 
Installing keyd (2.4.3-1) to root...
Configuring keyd.

Run the following command(s) to enable the keyd service
$ systemctl disable --now shutdown.target
$ systemctl enable --now keyd

You will need to modify /opt/etc/keyd/default.conf before starting the service
I was able to set the `dvorak` layout with the following config file
[ids]
2edd:0001 # type folio

include layouts/dvorak

[global]
default_layout = dvorak

[main]

Having set the dvorak layout, the shortcuts in #744 (comment) do not work correctly. I'll post a full config later that makes those all work as expected.

@Eeems
Copy link
Member

Eeems commented Jun 27, 2024

Upon installation, it instructed me to disable the shutdown target, which seems not relevant.

What launcher are you using? And what is the output of toltecctl status?

I was able to set the dvorak layout with the following config file

Having set the dvorak layout, the shortcuts in #744 (comment)) do not work. I'll post a config later to make them work again.

If you have a configuration to change the layout to dvorak, it would conflict with the settings I provided. I would recommend reviewing the keyd logs to see if it complains about anything (journalctl -ae keyd), and then you'd need to modify the dvorak layout instead of using the configration.

@plredmond
Copy link

What launcher are you using?

reMarkable: ~/ opkg list-installed remux
remux - 0.3.0-4

And what is the output of toltecctl status?

reMarkable: ~/ toltecctl status
Enabled: Yes
Supported: Yes
Branch: stable
Model: rm2
OS: 3.3.2.1666

reviewing the keyd logs to see if it complains about anything

Nothing beyond the usual startup messages.

[[0;1;39m-- Reboot --[[0m
Jun 27 21:33:32 reMarkable systemd[1]: Started key remapping daemon.
Jun 27 21:33:32 reMarkable keyd[188]: CONFIG: parsing /opt/etc/keyd/default.conf
Jun 27 21:33:32 reMarkable keyd[188]: Starting keyd v2.4.3 ()
Jun 27 21:33:32 reMarkable keyd[188]: DEVICE: ignoring 0fac:1ade  (keyd virtual pointer)
Jun 27 21:33:32 reMarkable keyd[188]: DEVICE: match    2edd:0001  /opt/etc/keyd/default.conf    (rM_Keyboard)
Jun 27 21:33:32 reMarkable keyd[188]: DEVICE: ignoring 056a:0000  (Wacom I2C Digitizer)
Jun 27 21:41:04 reMarkable keyd[188]: DEVICE: removed   2edd:0001 rM_Keyboard
Jun 27 21:53:58 reMarkable keyd[188]: DEVICE: match    2edd:0001  /opt/etc/keyd/default.conf    (rM_Keyboard)

you'd need to modify the dvorak layout instead of using the configration.

Yes, I'll do that and post it.

@Eeems
Copy link
Member

Eeems commented Jun 27, 2024

launcherctl status would be another output you could share to show what launcher you are on. Forgot to ask for that instead. What you provided works though.

Everything looks fine here, so it would be just that the two configurations are compatible with each other, as one overrides the other.

Copy link
Member

@Eeems Eeems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since uinput isn't available on OS 2, this will need to be limited to the rmallos3 architecture, so it's only available on 3.x.

It would probably be worth sorting out how we intend on other packages providing configuration for keyd, but that is probably better served by the first package who does.

@plredmond
Copy link

here is my dvorak keyd config, along with an image of the keyboard with the symbols overlaid
https://gist.github.com/plredmond/6da75360e660a7e240a9013f56af0603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages Add or improve packages of the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants