kinto icon indicating copy to clipboard operation
kinto copied to clipboard

Auto detect keyboard based on input on installer and add --devices parameter to xkeysnail

Open florisdipt opened this issue 5 years ago • 14 comments

Is your feature request related to a problem? Please describe. I've found that when having multiple keyboard(or in my case another usb device with buttons) keysnail will get confused what device to remap buttons for.

I wish it would detect my current input device when pressing the key two spaces from the spacebar and append it to the --devices parameter like so: {xkeysnail} --devices "Logitech MX Keys" --quiet

Describe alternatives you've considered I currently solved it by forking the repo and append the parameter manually in /xkeysnail-config/xkeysnail.service I also forked this repo in the hope of being able to create a PR which I might still do but imho i think the code is really long and that doesnt mix well with my limited python experience and I've found no proper way to debug it yet.

Additional context Add any other context or screenshots about the feature request here. error log for xkeysnail:

image

sample desired service output from my fork of the repo

Thank you all for the useful software

florisdipt avatar Nov 28 '20 19:11 florisdipt

A similar post was made before, but yours is more detailed about the issue and a solution, so I greatly appreciate that. I think I might need to look at the commands/method that xkeysnail uses to list out your keyboard names but limit the results to actual usb keyboard interfaces only.

It would be possible to add in an additional install screen to prompt the user on which keyboard will be configured or as you suggest possibly detect which keyboard it was that initiated that keyboard press in the first place so asking would not be needed. Generally speaking knowing which device presses it isn't all that important as the layout will get set properly, but as you say - it gets confused with other devices so it needs to be set explicitly as a result. Ideally all actual keyboard input devices ought to be prompted for and accounted for - but that will have to come in a future update.

Additionally if your setup is involving both a Windows and Apple style keyboard, as mine do at times, then you can actually use the "Windows & Apple*" Keyboard Type option which will swap the Alt & Cmd key around on the Apple keyboard via a driver so that it aligns with the Windows style before xkeysnail runs (assuming I have that done correctly - I only have 1 Apple keyboard atm and it is not the latest. I have made an effort to support the latest Apple keyboards as well though.).

I also have an autodetect feature on the Windows OS side that attempts to autoswitch based on the last plugged in keyboard device, but I have not spent the time creating anything similar on the Linux side. I think with the way xkeysnail is though it may be possible to have Kinto remap 2 or more keyboards independently at the same time. Something I don't really see being easily possible on Windows.

rbreaves avatar Nov 29 '20 01:11 rbreaves

@rbreaves No problem glad to help. I threw together a quick and dirty piece of python code that allows you to get all usb devices: https://github.com/florisdipt/kinto/blob/master/devices_list.py I hope it can be of some help Although we should keep in mind non usb keyboards for instance bluetooth I have none of those so I was not able to make my example account for those.

florisdipt avatar Nov 29 '20 21:11 florisdipt

Thank you, I will definitely be taking a look at your example and may include it in a coming update and that is a good point.. I don't actually own any bluetooth keyboards and it might be beneficial to get one for testing.

rbreaves avatar Nov 29 '20 21:11 rbreaves

I actually do have a couple of bluetooth keyboards I forgot about, neither are Apple official, but enough to do some testing with.

rbreaves avatar Nov 29 '20 22:11 rbreaves

I ran in the EXACT same issue. I would be happy to help if needed. For now I simply modifier ExecStart command in xkeysnail.service

alepee avatar Dec 09 '20 21:12 alepee

@alepee That would be great if you have the time and don't mind looking at my horrible python GUI code lol. A few things may need touching but primarily 3 files. xkeysnail.service, xkeysnail_service.sh and kinto-gui.py.

Most of the work will be done in kinto-gui.py at around the FirstPage to SecondPage area as an additional Page will need to be added btwn those 2 to prompt users to select which keyboard device or devices they would like to configure. Would be mostly straight forward if it is just to allow the configuration of 1, but a little harder if 2 or 3 - but either could be supported with enough logic and functions built out to handle those manipulations of the service file.

https://github.com/rbreaves/kinto/blob/master/xkeysnail-config/gui/kinto-gui.py

I am not sure when I will have the time to really dig into this one myself - probably some time after the holidays if I am being honest with myself, but if you want to take a stab at it and send me a PR I would be pretty happy about it lol.

I am not sure but I don't think there is a terminal only method of installing Kinto as of the v1.2 release. I might revisit that decision though and re-implement a new terminal based installer - as that would allow for edge cases like these to be dealt with a little faster and not necessarily require much or any modification of the simpler GUI setup.

rbreaves avatar Dec 10 '20 02:12 rbreaves

I finally give up on using Ubuntu right now, and will stick with MacOS (even with poor FS performances with Docker) 😕

alepee avatar Jan 19 '21 09:01 alepee

@alepee Was the lack of autodetection for your specific keyboard at play or were you having other behaviors or remaps not being handled well?

If you feel there were any performance or remappings not happening I don't mind digging into it & resolving it, but I also understand having an entire ecosystem of apps and cohesiveness on the macOS side is nice. I don't run Linux as my primary atm either due to the lack of good enough MBP driver support on my specific model. I am running Windows atm - but I keep it pretty much inline with the work done for Linux.

rbreaves avatar Jan 19 '21 23:01 rbreaves

I may try again for fun later on, but regarding keyboard specific issue I had. I use a Logitech Craft keyboard, it is compatible with both Windows and MacOS mapping and Logitech Options switch it's layout based on my loaded OS. Everything is going fine with kinto (except the detection issue, which is an easy to fix one) when the keyboard is mapped with MacOS layout. But when it has switched to Windows layout, I did not find a way to send the correct signal for it to switch back.

For this to be fixed I assume I would need to spy on Logitech Options serial communication with the keyboard and find which message trigger the switch... 😅 seems not to be easy

Any suggestion?

-- EDIT

This is a totally different issue, and may be transfer to another thread

alepee avatar Jan 26 '21 13:01 alepee

@alepee I suppose grabbing the Vendor & product ID could be useful.. as that could trigger a manual config.

rbreaves avatar Jan 26 '21 14:01 rbreaves

I have this exact problem with the Logitech MX Keys on Arch Linux. For those who end up here looking for the solution I fixed it with the following steps:

  1. sudo systemctl edit --full xkeysnail.service
  2. Edit the ExecStart line to have --devices "<device name here>" in front of the --quiet parameter
  3. Save

drod3763 avatar Feb 04 '21 21:02 drod3763

Thanks @drod3763, this solves your specific issue, @florisdipt exposed it in the first place. A good fix (more a new feat) would be, as suggested by @rbreaves, to implement a better keyboard detection (for Logitech MX Keys for instance) https://github.com/rbreaves/kinto/issues/335#issuecomment-742185282

alepee avatar Feb 08 '21 07:02 alepee

If a PR gets made i'd be happy to test it with my MX keys on ZorinOS & PopOS & Windows as that are the ones i currently have setup (on bare metal). For now the fix I applied to the service has been working ever since i've set it up.

florisdipt avatar Feb 08 '21 10:02 florisdipt

I have this exact problem with the Logitech MX Keys on Arch Linux. For those who end up here looking for the solution I fixed it with the following steps:

  1. sudo systemctl edit --full xkeysnail.service
  2. Edit the ExecStart line to have --devices "<device name here>" in front of the --quiet parameter
  3. Save

Thanks so much @drod3763 ! This solved it for me.

theforager avatar May 27 '24 15:05 theforager