#!/usr/bin/python
from subprocess import Popen, PIPE
import time
import re
tmx = int(round(time.time()*1000))
def run(command):
process = Popen(command, stdout=PIPE, shell=True)
while True:
line = process.stdout.readline().rstrip()
if not line:
break
yield line
if __name__ == "__main__":
for line in run("dmesg -wH"):
tmn = int(round(time.time()*1000));
if (tmn-tmx>1000):
#print(line)
x = re.search("remote: Wrong custom code is 0x(.+)$",line).group(1)
print("Keycode: "+x)
Tinggal ditambah/dimodif sedikit saja, sehingga script tersebut bisa dijadikan daemon, dan menjalankan file/script/aplikasi lain jika tombol X ditekan.
Semoga bermanfaat,
No comments:
Post a Comment