karpathy / ulogme

Automatically collect and visualize usage statistics in Ubuntu/OSX environments.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use of xinput under linux could remove sudo requirement

hexylena opened this issue · comments

More of an FYI/feature request.

I don't know if xinput is available under OSX (judging by the issue reports, that's the primary user base), but under linux xinput allows you to capture key presses without requiring root.

$ xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Video Bus                                 id=8    [slave  keyboard (3)]
    ↳ Sleep Button                              id=9    [slave  keyboard (3)]
    ↳ HP HD Webcam                              id=10   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=11   [slave  keyboard (3)]
    ↳ HP Wireless hotkeys                       id=13   [slave  keyboard (3)]
    ↳ HP WMI hotkeys                            id=14   [slave  keyboard (3)]

$ xinput test 11 # AT Translated Set 2 keyboard, can move to other screens/windows.
key release 36 
key press   65 
key release 65 
key press   38 
key press   39 
key press   46 

In addition to Docker, showkey is also causing problems on my debian jessie laptop. Probably an old version - but it seems to mess up the keyboard whenever i try to use the text consoles. (I have to magic-sysctl the keyboard back to raw to get control back).