You are not logged in.

#1 2020-07-18 23:18:20

ThinkPad
Member
Registered: 2019-01-29
Posts: 125

kbdrate not taking effect at console login for external keyboard

In addition to what I've tried in this post, I created a udev rule to run when my keyboard is plugged in:

/usr/udev/rules.d/10-local.rules
----
ATTRS{name}=="foostan Corne Keyboard (crkbd)", ACTION=="add", RUN+="/usr/local/shsc/kbdrate"
/usr/local/shsc/kbdrate
----
/usr/bin/kbdrate -s -d 1000 -r 15
touch /home/loaf/triggered

I confirm that it's run by writing the file 'triggered', but it does not take effect at the login console for my external keyboard. I am not sure how to further debug this. As stated in my other post, if I run the command as root after logging in, it works for my external keyboard. If I try to trigger it at or after login by plugging and unplugging the keyboard, it does not work. At the console login and after login it works for the built in laptop keyboard, but not my USB keyboard.

Last edited by ThinkPad (2020-07-18 23:18:59)

Offline

#2 2020-07-19 06:03:19

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: kbdrate not taking effect at console login for external keyboard

Overridden? Runs before keyboard is initialized?
Did you try to delay the call, eg. prepend "sleep 1"?

Offline

#3 2020-07-19 17:58:35

ThinkPad
Member
Registered: 2019-01-29
Posts: 125

Re: kbdrate not taking effect at console login for external keyboard

This is what I tried:

/usr/local/shsc/kbdrate
----
#!/bin/sh

/bin/sleep 1
/usr/bin/kbdrate -s -d 1000 -r 15
touch /home/loaf/triggered

It didn't work.

Last edited by ThinkPad (2020-07-19 18:00:55)

Offline

#4 2020-07-19 18:32:09

loqs
Member
Registered: 2014-03-06
Posts: 17,326

Re: kbdrate not taking effect at console login for external keyboard

If you replace touch with the following to check the exit status of kbdrate

echo $? > /home/loaf/triggered

Is the exit status 0?

Offline

#5 2020-07-19 19:08:40

ThinkPad
Member
Registered: 2019-01-29
Posts: 125

Re: kbdrate not taking effect at console login for external keyboard

Oddly, the service, but not the udev rule, seems to work now after installing powertop, running powertop --calibrate, and enabling the powertop service as per these instructions. powertop --calibrate soft blocked my wifi card and bluetooth, not sure if that is causation. This is all with the sleep line removed. I've since disabled the powertop service as it was affecting keyboard input and missing strokes. The service also works with powertop uninstalled.

Using your suggestion, the rule writes a '0'.

I will wait to mark as solved as I am not sure what the fix was or if it will persist. If you have anything you'd like me to test let me know. I appreciate the help.

Last edited by ThinkPad (2020-07-19 19:10:47)

Offline

#6 2020-07-20 12:28:46

ondoho
Member
Registered: 2013-04-30
Posts: 692
Website

Re: kbdrate not taking effect at console login for external keyboard

ThinkPad wrote:

I am not sure how to further debug this.

'udevadm monitor', 'udevadm info' etc. can give insight.
the Archwiki has a long page on udev too.

Offline

#7 2020-07-20 13:47:00

ThinkPad
Member
Registered: 2019-01-29
Posts: 125

Re: kbdrate not taking effect at console login for external keyboard

So it seems the udev does not take effect, and that the service only takes effect if the keyboard is plugged in before the machine is powered on. I tested with the rule in place and the service and tried unplugging and plugging at login to trigger.

I will reread the udev wiki entry. I thought udevadm info was to get parameters to use in rules. I will explore both, thank you for the guidance.

Offline

#8 2020-07-20 13:54:24

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: kbdrate not taking effect at console login for external keyboard

If the udev rule doesn't work, why would /home/loaf/triggered get updated (and exit status 0)?

Offline

#9 2020-07-24 02:02:10

ThinkPad
Member
Registered: 2019-01-29
Posts: 125

Re: kbdrate not taking effect at console login for external keyboard

Not sure. Even when the service wasn't working it still showed correct output that the delay was changed. Again, it takes effect for my built in keyboard, but not the external which is why I think it returns without error. The external only works as intended when the computer is started after the board is plugged in and with the service, not the udev.

Offline

#10 2020-07-24 06:30:33

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: kbdrate not taking effect at console login for external keyboard

If  /home/loaf/triggered gets updated  when you plug in the keyboard (maybe ensure that this isn't a false positive because it got updated w/ eg. the service only?) the udev rule hits and the script gets called.
If "/usr/bin/kbdrate -s -d 1000 -r 15" generally works and is called by the script when you plug the keyboard, it either fails to affect the keyboard at that time or gets reset later on.
In that case, adding a random delay should™ sanitize the situation unless the reset is triggered by a voluntary later action (eg. a login script and your login)

Offline

#11 2021-05-07 16:50:59

ThinkPad
Member
Registered: 2019-01-29
Posts: 125

Re: kbdrate not taking effect at console login for external keyboard

This problem still persists.

Updated udev

SUBSYSTEM=="input", ATTRS{manufacturer}=="foostan", ATTRS{product}=="Corne", ATTRS{idProduct}=="0001", ATTRS{idVendor}=="4653", ACTION=="add", RUN+="/usr/local/shsc/kbdrate"

Updated script

#!/bin/sh

/usr/bin/kbdrate -d 50000000 -r 4
printf "%d\n%s\n" $? "`date`" > /home/loaf/triggered
printf "kbdrate script called\n" > /dev/stdin

Service

[Unit]
Description=Keyboard repeat rate in tty.

[Service]
Type=oneshot
RemainAfterExit=yes
StandardInput=tty
StandardOutput=tty
ExecStart=/usr/bin/kbdrate -d 50000000 -r 4
 
[Install]
WantedBy=multi-user.target

Observed behavior
1. udev rule triggers successfully on keyboard plugin during boot, but does not take effect for external keyboard; only takes
effect for the built-in keyboard. Oddly,

sudo kbdrate -p

shows the defaults, even though the built-in keyboard is still affected. Same behavior with and without a `sleep 5`. This was tested with the service disabled.
2. Service starts successfully, but only takes effect on external keyboard if it's plugged in before boot. This was tested with the udev disabled.

Questions
1. Is it normal for kbdrate to only effect the input devices plugged in? I would imagine it is the setting for any console input. Is there a way to set this behavior?
2. Why won't the udev rule take effect for the external keyboard?

Offline

Board footer

Powered by FluxBB