https://github.com/oxzi/go-xinput
Go library for limited X.Org XInput interaction
https://github.com/oxzi/go-xinput
golang xinput xorg
Last synced: about 1 year ago
JSON representation
Go library for limited X.Org XInput interaction
- Host: GitHub
- URL: https://github.com/oxzi/go-xinput
- Owner: oxzi
- License: mit
- Created: 2020-07-07T13:31:08.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-31T17:02:09.000Z (over 5 years ago)
- Last Synced: 2024-06-21T18:06:08.702Z (almost 2 years ago)
- Topics: golang, xinput, xorg
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-xinput
[](https://godoc.org/github.com/oxzi/go-xinput) 
Small [Go][golang] library for limited interaction with the [X Input Device Extension Library][xorg-xinput] (``).
This allows listing input devices and listening for events, e.g., pressing keys.
## Examples
### xinput-list
Reimplementation of [`xinput list`][xinput].
```
$ go run examples/xinput-list/main.go
Virtual core pointer id=2 [master pointer]
Virtual core keyboard id=3 [master keyboard]
Virtual core XTEST pointer id=4 [slave pointer]
Virtual core XTEST keyboard id=5 [slave keyboard]
Power Button id=6 [slave keyboard]
Video Bus id=7 [slave keyboard]
Sleep Button id=8 [slave keyboard]
Integrated Camera: Integrated C id=10 [slave keyboard]
AT Translated Set 2 keyboard id=11 [slave keyboard]
TPPS/2 IBM TrackPoint id=13 [slave pointer]
ThinkPad Extra Buttons id=14 [slave keyboard]
FiiO DigiHug USB Audio id=9 [slave keyboard]
SynPS/2 Synaptics TouchPad id=12 [slave pointer]
```
### keylogger
Show key, button, or motion events from an input device.
Compared to other Go-based Linux _keyloggers_ this does not require extended permissions.
```
# Keyboard from the list above
$ go run examples/keylogger/main.go 11
{key press 37 map[]}
{key release 37 map[]}
{key press 37 map[]}
{key press 56 map[]}
{key release 37 map[]}
{key release 56 map[]}
{key press 45 map[]}
# Mouse from the list above
$ go run examples/keylogger/main.go 13
{motion 0 map[0:2299 1:866]}
{motion 0 map[0:2300 1:865]}
{motion 0 map[0:2300 1:864]}
{motion 0 map[0:2304 1:861]}
{motion 0 map[0:2305 1:859]}
{motion 0 map[1:857]}
{motion 0 map[1:856]}
{button press 1 map[]}
{button release 1 map[]}
{motion 0 map[1:856]}
```
[golang]: https://golang.org/
[xinput]: https://gitlab.freedesktop.org/xorg/app/xinput/
[xorg-xinput]: https://www.x.org/releases/X11R7.7/doc/libXi/inputlib.html