hotcuts/hotcutdaemon.py

18 lines
600 B
Python
Raw Normal View History

2021-08-30 00:32:28 +02:00
#!/usr/bin/python3
2021-08-29 00:05:21 +02:00
from evdev import InputDevice, categorize, ecodes
2021-08-30 00:32:28 +02:00
import configparser, os
2021-08-29 00:05:21 +02:00
config = configparser.ConfigParser()
config.read('config.ini')
def sysrun(command):
2021-08-30 00:32:28 +02:00
os.system(command+ " &")
dev = InputDevice(config["DEVICE"]["path"])
2021-08-29 00:05:21 +02:00
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])