-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwait_for_evdev.py
executable file
·44 lines (31 loc) · 1.14 KB
/
wait_for_evdev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# Copyright Skullspace, 2014
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
# http://www.gnu.org/prep/maintain/html_node/License-Notices-for-Other-Files.html
# @author Mark Jenkins <[email protected]>
# Instructions
# everything except step 2) as root here
# (unless you want to master udev...)
# 1) Install https://pythonhosted.org/evdev/install.html
# $ easy_install evdev
# (or if you're like me, easy_install --prefix=/opt/python-evdev with
# PYTHONPATH set as needed)
# 2) use xinput to disable any keyboards, mice or pedals that are for buzing,
# not for using with X
# 3) figure out which ev numbers from /dev/input/event? you want to work with
# by using cat
# 4) call this program with the device node
from sys import argv
from evdev import InputDevice
from buzz import buzz
def main():
dev = InputDevice(argv[1])
buzz_id = int(argv[2])
for event in dev.read_loop():
buzz(buzz_id)
if __name__ == "__main__":
main()