Add files via upload

This commit is contained in:
MatMasIt 2021-08-29 00:05:21 +02:00 committed by GitHub
parent 3fd8225e41
commit 2ee22b55e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 0 deletions

3
config.ini Normal file
View File

@ -0,0 +1,3 @@
[KEYS]
KEY_P=gnome-session-quit --power-off
KEY_F=firefox

1
lastCommand Normal file
View File

@ -0,0 +1 @@
OK

18
rootDaemon.py Normal file
View File

@ -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])

15
userpuppet.py Normal file
View File

@ -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)