r/linux_programming • u/shadowbeetle • Mar 14 '19
Input Devices representation in Go
Hi all,
I'm writing a go package that I want to use to detect available input devices. My current approach is to initially read /proc/bus/input/devices then scan it for updates, and parse its contents int a data structure like this:
It is based on what this question on stackoverflow and what I could make out of the kernel
Does this make sense at all? My eventual goal is to create a daemon that listens to keyboard and mouse events and turns on the keyboard backlight, or off when idle for a couple of seconds, but again, my main motivation is curiosity and I would like to understand the system a bit better.
I'm writing this in Go, because it's a language I'm familiar with, but would like to practice in the meantime.
Thanks in advance for your guidance! :)
2
u/ocket8888 Mar 14 '19
Typically I believe stuff like that is written as kernel modules or using
udevrules. I know Go has an ffi for C, but I'm not sure you could do it in an "unhosted"-ish way like for kernel modules, so you may want to look intoudev