Skip to content

Instantly share code, notes, and snippets.

@tushar-rishav
Created October 22, 2015 10:32
Show Gist options
  • Save tushar-rishav/480aa4ada8ad513d032f to your computer and use it in GitHub Desktop.
Save tushar-rishav/480aa4ada8ad513d032f to your computer and use it in GitHub Desktop.
Read keyboard system files
import os
DEF_INP = "/dev/input/"
DEF_BUS = "/proc/bus/input/devices"
def read_device():
fd = os.popen("grep -E 'Handlers|EV=' " + DEF_BUS + " | grep -B1 'EV=120013' | grep -Eo 'event[0-9]+'")
events = list(fd.read().split("\n"))[:-1]
fd.close()
return events
print(DEF_INP + read_device()[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment