You are not logged in.
Helluw.
Been spending a few hours now trying to figure out how to dim and light my keyboard leds based on activity. Found several utilities that does this for the screen brightness, even Gnome3 does this when the power is critical.
The problem is basically launching an event every X seconds there is no keyboard interaction or no activity on the screen, how can you achieve this?
Last edited by Foxboron (2013-10-04 20:47:48)
Offline
Have you considered cron?
You need to install "cronie" and run it via systemd with
systemctl enable cronie
sytemctl run cronieCron is a well documented program, so it may be easy to do what you want.
Now, I know there are other programs but I'm not familiar enough to recommend anything else ![]()
R.
Offline
Have you considered cron?
You need to install "cronie" and run it via systemd withsystemctl enable cronie sytemctl run cronieCron is a well documented program, so it may be easy to do what you want.
Now, I know there are other programs but I'm not familiar enough to recommend anything elseR.
Well, running the event isn't really the problem. It is detecting WHEN the event should be ran. I know about cron, but AFAIK systemd solves this part quite well. Thanks anyway ^^!
Offline
After some fiddling i have a rather hacky solution using some Python and inotify.
#!/usr/bin/env python
from subprocess import *
from queue import Queue
import threading
from time import time, sleep
timout = 1
q = Queue()
class MainThread(threading.Thread):
daemon=True
def __init__(self, q):
threading.Thread.__init__(self)
self.q = q
def run(self):
a = Popen(["inotifywait","-mrcq","/dev/input"], stdout=PIPE)
while True:
for i in a.stdout:
if self.q.empty():
self.q.put(i)
sleep(5)
def start():
t = MainThread(q)
t.start()
timr = time()
while True:
if not q.empty():
res = q.get()
call(["asus-kbd-backlight","on"])
sleep(timout)
else:
if int(time() - timr) >= timout:
call(["asus-kbd-backlight","off"])
timr = time()
sleep(0.5)
start()Last edited by Foxboron (2013-10-04 20:40:19)
Offline