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

feat: add --watch option for support hot-plugging keyboards #22

Merged
merged 3 commits into from
Jun 4, 2018
Merged

feat: add --watch option for support hot-plugging keyboards #22

merged 3 commits into from
Jun 4, 2018

Conversation

tangxinfa
Copy link
Contributor

Use inotify to watch new keyboard devices

@Lenbok
Copy link
Contributor

Lenbok commented Jun 1, 2018

I'm excited for this, thanks!

I gave this a test but it didn't quite work. Here's what I get when I start it up, then unplug and re-plug my keyboard: (I'm using Ubuntu 18.04, if that helps)

$ sudo xkeysnail --watch ~/.xkeysnail.py

██╗  ██╗██╗  ██╗███████╗██╗   ██╗
╚██╗██╔╝██║ ██╔╝██╔════╝╚██╗ ██╔╝
 ╚███╔╝ █████╔╝ █████╗   ╚████╔╝
 ██╔██╗ ██╔═██╗ ██╔══╝    ╚██╔╝
██╔╝ ██╗██║  ██╗███████╗   ██║
╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝   ╚═╝
  ███████╗███╗   ██╗ █████╗ ██╗██╗
  ██╔════╝████╗  ██║██╔══██╗██║██║
  ███████╗██╔██╗ ██║███████║██║██║
  ╚════██║██║╚██╗██║██╔══██║██║██║
  ███████║██║ ╚████║██║  ██║██║███████╗
  ╚══════╝╚═╝  ╚═══╝╚═╝  ╚═╝╚═╝╚══════╝
                             v0.1.0

No keyboard devices specified via (--devices) option.
xkeysnail picks up keyboard-ish devices from the list below:

---------------------------------------------------------------------------------------------
Device               Name                                Phys
---------------------------------------------------------------------------------------------
/dev/input/event0    Power Button                        PNP0C0C/button/input0
/dev/input/event1    Power Button                        LNXPWRBN/button/input0
/dev/input/event2    Microsoft Microsoft® 2.4GHz Transceiver v9.0 usb-0000:00:1d.0-1.7/input0
/dev/input/event3    Microsoft Microsoft® 2.4GHz Transceiver v9.0 usb-0000:00:1d.0-1.7/input1
/dev/input/event4    Microsoft Microsoft® 2.4GHz Transceiver v9.0 usb-0000:00:1d.0-1.7/input2
/dev/input/event5    Eee PC WMI hotkeys                  eeepc-wmi/input0
/dev/input/event6    HDA Intel PCH Front Mic             ALSA
/dev/input/event7    HDA Intel PCH Rear Mic              ALSA
/dev/input/event8    HDA Intel PCH Line                  ALSA
/dev/input/event9    HDA Intel PCH Line Out Front        ALSA
/dev/input/event10   HDA Intel PCH Line Out Surround     ALSA
/dev/input/event11   HDA Intel PCH Line Out CLFE         ALSA
/dev/input/event12   HDA Intel PCH Line Out Side         ALSA
/dev/input/event13   HDA Intel PCH Front Headphone       ALSA
/dev/input/event14   HDA NVidia HDMI/DP,pcm=3            ALSA
/dev/input/event15   HDA NVidia HDMI/DP,pcm=7            ALSA
/dev/input/event16   HDA NVidia HDMI/DP,pcm=8            ALSA
/dev/input/event17   HDA NVidia HDMI/DP,pcm=9            ALSA
/dev/input/event19   Falbatech The Redox Keyboard        usb-0000:00:1d.0-1.6.1.1/input0
/dev/input/event20   Falbatech The Redox Keyboard        usb-0000:00:1d.0-1.6.1.1/input1
/dev/input/event21   Falbatech The Redox Keyboard        usb-0000:00:1d.0-1.6.1.1/input2
/dev/input/event18   py-evdev-uinput                     py-evdev-uinput

Okay, now enable remapping on the following device(s):

---------------------------------------------------------------------------------------------
Device               Name                                Phys
---------------------------------------------------------------------------------------------
/dev/input/event2    Microsoft Microsoft® 2.4GHz Transceiver v9.0 usb-0000:00:1d.0-1.7/input0
/dev/input/event4    Microsoft Microsoft® 2.4GHz Transceiver v9.0 usb-0000:00:1d.0-1.7/input2
/dev/input/event19   Falbatech The Redox Keyboard        usb-0000:00:1d.0-1.6.1.1/input0

Watching keyboard devices plug in
Device removed: Falbatech The Redox Keyboard
Okay, now enable remapping on the following new device(s):

----------------------------------------------------------------------------------------
Device               Name                                Phys
----------------------------------------------------------------------------------------
/dev/input/event19   Falbatech The Redox Keyboard        usb-0000:00:1d.0-1.6.1.1/input0

Okay, now enable remapping on the following new device(s):

Traceback (most recent call last):
  File "/usr/local/bin/xkeysnail", line 6, in <module>
    cli_main()
  File "/usr/local/lib/python3.6/dist-packages/xkeysnail/__init__.py", line 50, in cli_main
    loop(args.devices, args.watch)
  File "/usr/local/lib/python3.6/dist-packages/xkeysnail/input.py", line 125, in loop
    print_device_list(new_devices)
  File "/usr/local/lib/python3.6/dist-packages/xkeysnail/input.py", line 38, in print_device_list
    print('-' * len(max(device_lines, key=len)))
ValueError: max() arg is an empty sequence

@tangxinfa
Copy link
Contributor Author

@Lenbok I fixed the problem, please try again, thanks

@Lenbok
Copy link
Contributor

Lenbok commented Jun 2, 2018

Great, it's now working perfectly in my testing!

@mooz mooz merged commit 2338ac7 into mooz:master Jun 4, 2018
@mooz
Copy link
Owner

mooz commented Jun 4, 2018

Wow, this is great! Thanks!

@tangxinfa tangxinfa deleted the feat-hot-plugging branch August 4, 2018 07:15
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

Successfully merging this pull request may close these issues.

3 participants