Commits

Jakub Wilk  committed 256423c

examples/sensors-alert: allow choosing which LED to use.

  • Participants
  • Parent commits 7b2fb0a

Comments (0)

Files changed (1)

File examples/sensors-alert

     event_device = glob.glob('/dev/input/by-path/*-event-kbd')[0]
     ledkit = keyboardleds.LedKit(event_device)
     drop_privileges()
-    led = ledkit.caps_lock
+    led = getattr(ledkit, options.led.replace('-', '_'))
     temperature_re = re.compile('^ +temp[0-9]+_input: ([0-9.]+)$')
     try:
         while True:
         led.reset()
 
 def parse_args():
+    led_names = list(t + '-lock' for t in ('caps', 'num', 'scroll'))
     class default:
         temperature_limit = 75.0
         bogus_temperature_limit = 200.0
         default=default.bogus_temperature_limit,
         help='temperatures above this limit will be consider bogus, and thus ignored (default: {0:.0f} deg C)'.format(default.bogus_temperature_limit),
     )
+    ap.add_argument('--led', choices=led_names, default=led_names[0],
+        help='keyboard LED to use',
+    )
     ap.add_argument('--poll-period', metavar='<time>', type=float,
         default=default.poll_period,
         help='how often to poll sensors (default: {0:.1f} s)'.format(default.poll_period),