dockapps/cnslock/kleds.c
Doug Torrance eb6ba359cb cnslock: Complete rewrite using libdockapp.
No longer functioned as a dockapp using modern GDK 2.0, which is what cnslock
previously used.
2017-02-28 10:38:00 +00:00

31 lines
579 B
C

/*
This code is based upon some lines(actually two lines :-)
in E-Leds by Mathias Meisfjordskar<mathiasm@ifi.uio.no>
Released under GPL.
*/
#include <stdio.h>
#include <X11/XKBlib.h>
#include <libdockapp/dockapp.h>
#include "include/kleds.h"
/*
Returns the turned on leds:
Bit 0 is Capslock
Bit 1 is Numlock
Bit 2 is Scrollock
*/
int check_kleds()
{
unsigned int states;
if (XkbGetIndicatorState(DADisplay, XkbUseCoreKbd, &states) != Success)
{
perror("Error while reading Indicator status\n");
return -1;
}
return (states & 0x7);
}