Log in Page Discussion History Go to the site toolbox

Setled

From BluWiki

extern "C" {
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
}

const int CapsLock = 2, NumLock = 16, ScrollLock = 1;

void setLeds(int leds)
{
	Display *dpy = XOpenDisplay(0);
	
	XKeyboardControl values;
	values.led_mode = leds & ScrollLock ? LedModeOn : LedModeOff;
	values.led = 3;
	XChangeKeyboardControl(dpy, KBLedMode, &values);
	
	XkbLockModifiers(
		dpy,
		XkbUseCoreKbd,
		CapsLock | NumLock,
		leds & (CapsLock | NumLock)
		);
	XFlush(dpy);
}

int main()
{
	setLeds(CapsLock | NumLock | ScrollLock);
}

Site Toolbox:

Personal tools
GNU Free Documentation License 1.2
This page was last modified on 22 July 2008, at 10:52.
Disclaimers - About BluWiki