hotcuts/hotcutdaemon.py

18 lines
645 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()
2021-08-30 00:43:45 +02:00
config.read(os.path.dirname(os.path.realpath(__file__))+'/config.ini')
2021-08-29 00:05:21 +02:00
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])