diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..27e40bf --- /dev/null +++ b/config.ini @@ -0,0 +1,3 @@ +[KEYS] +KEY_P=gnome-session-quit --power-off +KEY_F=firefox diff --git a/lastCommand b/lastCommand new file mode 100644 index 0000000..a0aba93 --- /dev/null +++ b/lastCommand @@ -0,0 +1 @@ +OK \ No newline at end of file diff --git a/rootDaemon.py b/rootDaemon.py new file mode 100644 index 0000000..51c17b3 --- /dev/null +++ b/rootDaemon.py @@ -0,0 +1,18 @@ +from evdev import InputDevice, categorize, ecodes +import configparser +config = configparser.ConfigParser() +config.read('config.ini') +def sysrun(command): + f=open("lastCommand","w") + f.write(command) + f.close() +dev = InputDevice('/dev/input/by-id/usb-dakai_PS_2+USB_Keyboard-event-kbd') +dev.grab() +for event in dev.read_loop(): + if event.type == ecodes.EV_KEY: + key = categorize(event) + if key.keystate == key.key_down: + print(key.keycode) + if key.keycode in config["KEYS"].keys(): + print("Executing "+config["KEYS"][key.keycode]) + sysrun(config["KEYS"][key.keycode]) diff --git a/userpuppet.py b/userpuppet.py new file mode 100644 index 0000000..71cc3c4 --- /dev/null +++ b/userpuppet.py @@ -0,0 +1,15 @@ +import os, time +lastCommand="" +r = open("lastCommand","r") +while True: + r.seek(0,0) + cmd = r.read() + if cmd != "OK": + print(cmd+ " &") + os.system(cmd + " &") + r.close() + r = open("lastCommand","w") + r.write("OK") + r.close() + r = open("lastCommand","r") + time.sleep(0.5)