#!/usr/bin/python import fcntl, os, string, time, random # variable fra /linux/kd.h KDSETLED = 0x4B32 # /* set led state [lights, not flags] */ LED_SCR = 0x01 #/* scroll lock led */ LED_CAP = 0x04 #/* caps lock led */ LED_NUM = 0x02 #/* num lock led */ tty = string.strip(os.popen('tty').read()) f = open(tty) try: while 1: for status in [LED_NUM, LED_CAP, LED_SCR]: """ if status == LED_NUM: pass elif status == LED_CAP: status = LED_NUM|LED_CAP elif status == LED_SCR: status = LED_NUM|LED_CAP|LED_SCR else: status = 0 i = random.randint(0,2) if i==0: status = LED_NUM elif i == 1: status = LED_CAP elif i == 2: status = LED_SCR """ fcntl.ioctl(f.fileno(), KDSETLED, status) time.sleep(.1) except KeyboardInterrupt: fcntl.ioctl(f.fileno(), 0x4B32, 0x00) os.system('reset') except IOError: print "Sorry, need to speak to a tty! Try a ctrl-alt-F1 or something.."