You are not logged in.

#1 2023-03-22 14:24:56

buzuddha
Member
Registered: 2020-10-02
Posts: 72

User input permissions? Dead keyboard with both xkeysnail and keyszer

Hi All,

I'm attempting to remap keys to provide the MacOS shortcuts provided by Kinto.sh. I'm aware there is a wiki on keyboard remap utilities, however Kinto functions based on xkeysnail and which isn't listed on that page.

If I run xkeysnail in the terminal, it complains that I don't have access to uinput. So I rerun xkeysnail with sudo and I can see key presses logged in terminal but no characters printed, window control, etc(keys mashed at bottom of pastebin entry).

One of the collaborators suggested a fork based on a different key remapper called keyszer and I've attempted to get this working using that utility but get the same result (plus the mouse input no longer works) (can see logged keypresses/mouse clicks in terminal).

My suspicion is that somewhere along the chain, keypresses are running into a permission issue somewhere and I'd be very grateful if anyone could provide help or point me in the right direction. I've consulted the author and collaborators on github, but they're not familiar with Arch and are stumped.

Link to github bug report

Note: Xorg in Gnome with 6.2.6-arch1-1 on bare metal.

Thanks!!

Offline

#2 2023-03-22 15:18:20

seth
Member
Registered: 2012-09-03
Posts: 55,778

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

stat /dev/uinput
getfacl /dev/uinput

https://wiki.archlinux.org/title/Kodi#K … oard_input

But according to your bug report

Failed to open `uinput` in write mode.
Make sure that you have executed xkeysnail with root privilege such as

    $ sudo xkeysnail config.py

sudo xkeysnail config.py

Which however leads to a completely unrelated bug

Traceback (most recent call last):
  File "/usr/bin/xkeysnail", line 6, in <module>
    cli_main()
  File "/usr/lib/python3.10/site-packages/xkeysnail/__init__.py", line 61, in cli_main
    eval_file(args.config)
  File "/usr/lib/python3.10/site-packages/xkeysnail/__init__.py", line 5, in eval_file
    with open(path, "rb") as file:
FileNotFoundError: [Errno 2] No such file or directory: 'config.py'

Since there seem no "kinto" or "keyszer" packages in repos or AUR: how do you install this stuff?

Offline

#3 2023-03-22 21:27:54

buzuddha
Member
Registered: 2020-10-02
Posts: 72

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

Hi Seth,

stat /dev/uinput. Not really sure how to interpret this output. Appears uinput has write mode enabled for user and group?
getfacl /dev/uinput. Same here.

I've attempted the fix you linked for Kodi, but no luck. 1) Created both config files for /etc/udev/rules.d. 2) I belong to the input group already from the keyszer setup. 3) rebooted.

Actually, I realized that I hadn't pasted the output of running keyszer as sudo. Weird that it's looking for a keyszer module.

sudo /home/hugh/.local/bin/keyszer -w -v -c ~/.config/kinto/toshy.py
Traceback (most recent call last):
  File "/home/hugh/.local/bin/keyszer", line 5, in <module>
    from keyszer.cli import main
ModuleNotFoundError: No module named 'keyszer'

sudo modprobe keyszer 
modprobe: FATAL: Module keyszer not found in directory /lib/modules/6.2.7-arch1-1

These install through python.

to install kinto:

git clone https://github.com/rbreaves/kinto.git
cd kinto
./setup.py

To install keyszer

Last edited by buzuddha (2023-03-24 13:23:18)

Offline

#4 2023-03-22 22:01:11

seth
Member
Registered: 2012-09-03
Posts: 55,778

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

You apparently ran a local install for your user, sudo fails for lacking the context.
The "module" there is (most likely) a python module, not a kernel one.
You didn't actually paste the output of getfcal but according to the stat, members of the input group should™ be able to read/write /dev/uinput

id

And do you still get the permission error?
keyszer apparently also requires access to /dev/input/event*, https://github.com/joshgoebel/keyszer#s … quirements

Offline

#5 2023-03-24 21:11:22

buzuddha
Member
Registered: 2020-10-02
Posts: 72

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

Whoops! Fixed the getfacl link above.

I am a member of input

$ id
uid=1000(myname) gid=1000(myname) groups=1000(myname),994(input),998(wheel)

In communicating with RedBearAK (one of the keyszer authors), they discouraged sudo pip installs. I can gave it a shot. No difference in the effect. Just my user executing from /bin instead of /home/myname/.local/bin.

For access to /dev/input/event*, I'm not so sure how to permit access. My understanding is that each event# is generated when a device is plugged in. How do you grant permission to a device that may be given a different event# depending upon the order it was attached? Am I understanding this correctly?

I think I should have access to /dev/input/event7 (my keyboard) based on being a member of the input group.

Last edited by buzuddha (2023-03-24 21:55:13)

Offline

#6 2023-03-24 22:09:57

seth
Member
Registered: 2012-09-03
Posts: 55,778

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

they discouraged sudo pip install

So does the wiki because it's a really bad idea.
But it also means that if you now run "sudo stuff" it might not be aware where to look for modules that got installed into your $HOME
The keyszer readme also doesn't suggest to sudo it.

How then to grant permission to a device

Udev rule, the previous kodi link actually lines this out as does https://github.com/joshgoebel/keyszer#a … ore-secure and https://github.com/joshgoebel/keyszer#g … ess-secure

Offline

#7 2023-03-24 22:42:08

buzuddha
Member
Registered: 2020-10-02
Posts: 72

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

Hmmm. I've tried both of those rules...and the kodi rules. Still no luck.

cat /etc/udev/rules.d/90-keymapper-acl.rules
cat /etc/udev/rules.d/90-keymapper-input.rules
cat /etc/udev/rules.d/10-permissions.rules
cat /etc/udev/rules.d/99-input.rules

Last edited by buzuddha (2023-03-24 22:47:57)

Offline

#8 2023-03-24 23:06:44

seth
Member
Registered: 2012-09-03
Posts: 55,778

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

The permissions in your previous edid for event7 reflect those rules.

Still no luck.

The paste also suggests

(CG) User config sees: DISTRO_NAME = None
(CG) User config sees: DESKTOP_ENV = 'gnome'
(--) WATCH: Watching for new devices to hot-plug.
(--) Autodetecting all keyboards (--device not specified)
(+K) Grabbing Compx 2.4G Wireless Receiver (/dev/input/event2)
(+K) Grabbing Compx 2.4G Wireless Receiver Keyboard (/dev/input/event5)
(+K) Grabbing ASUSTeK ROG Strix Flare PNK LTD (/dev/input/event7)
(+K) Grabbing ASUSTeK ROG Strix Flare PNK LTD (/dev/input/event8)
(+K) Grabbing Logitech K400 Plus (/dev/input/event6)
(+K) Grabbing Logitech MX Ergo (/dev/input/event9)
(--) Ready to process input.

above from keyszer

that keyszer is able and ready to process input?

I assume the status quote is actually https://github.com/rbreaves/kinto/issue … 1471288453 ie. the uinput error/warning is long gone?
Step #: you constantly seem to "sudo xkeysnail kinto.py"? I'd stop putting the sudo there.

Offline

#9 2023-03-25 04:40:18

buzuddha
Member
Registered: 2020-10-02
Posts: 72

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

Ok I uninstalled keyszer and went back and reinstalled kinto using rbreaves's one-line install command and it works!

Not sure but my guess here is that the udev rules fixed xkeysnail.service? Mayhaps it's running with elevated permissions though. Looks like root owns it...

journalctl -f --unit=xkeysnail.service -b
[hugh@crabhouse kinto]$ journalctl -f --unit=xkeysnail.service -b
Mar 25 00:30:37 crabhouse systemd[1]: Started xkeysnail.
Mar 25 00:30:37 crabhouse sudo[1631]:     root : PWD=/ ; USER=root ; COMMAND=/bin/bash -c '/usr/bin/xhost +SI:localuser:root && /home/hugh/.config/kinto/killdups.sh && /usr/bin/xkeysnail --quiet --watch /home/hugh/.config/kinto/kinto.py'
Mar 25 00:30:37 crabhouse sudo[1631]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Mar 25 00:30:38 crabhouse sudo[1637]: localuser:root being added to access control list

To answer your questions:
1) Yes the uinput error warning is gone. I only had to run modprobe uinput one time.
2) Keyszer is able process input. If you look at the second to last link in the initial post, you can see it logging keystrokes and if you set these as remaps in the config file, this is also logged. Likewise, the emergency exit key works to turn off keyszer.

May do a fresh install and try the udev rules to see if that was what did it.

Last edited by buzuddha (2023-03-25 04:45:04)

Offline

#10 2023-04-01 03:35:43

buzuddha
Member
Registered: 2020-10-02
Posts: 72

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

Sorry,  still working on it. I have been trying on a demo fresh install on a different drive. Kinto still insn't working despite having tried multiple different avenues. Will report back when I've figured it out.

Offline

#11 2023-04-01 06:56:41

seth
Member
Registered: 2012-09-03
Posts: 55,778

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

Kinto still insn't working

Please don't paraphrase, https://bbs.archlinux.org/viewtopic.php?id=57855

despite having tried multiple different avenues

That all hopefully didn't include "sudo"?

Offline

#12 2023-04-08 00:17:17

buzuddha
Member
Registered: 2020-10-02
Posts: 72

Re: User input permissions? Dead keyboard with both xkeysnail and keyszer

Hi Seth,

Sorry for the paraphrasing.

I decided to start fresh.

First, I reinstalled arch/gnome/drivers/apps/. I then attempted the kinto.sh oneline install. This install failed - didn't have pip - installed python-pip -> retried the oneline install, which succeeded with one error. This produced the same issue I've described above where keystrokes give no input on the screen.

I then added myself to the input group

#usermod -aG input myuser

After the above command, I added the 4 files listed above:

/etc/udev/rules.d/90-keymapper-acl.rules
/etc/udev/rules.d/90-keymapper-input.rules
/etc/udev/rules.d/10-permissions.rules
/etc/udev/rules.d/99-input.rules

I then rebooted and the kinto.sh shortcuts work!

Upon writing out this post, I realized that I forgot to create the keymapper user as listed in the keyszer github page, which means that likely the 90-keymapper-acl.rules file is useless.

So I can perhaps go through and pull out these files one by one to figure out which ones are necessary.

And yes, none of the avenues involved sudo (aside from placing those rules files in /etc)!

Last edited by buzuddha (2023-04-08 00:18:13)

Offline

Board footer

Powered by FluxBB