l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
October 7: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2005 Jul 28 18:01

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Using setleds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Using setleds



Thanks Ken,

That little bit of C and info was exactly what I was looking for.....

JW
----- Original Message -----
From: "Ken Bloom" <kbloom@gmail.com>
To: "lugod's technical discussion forum" <vox-tech@lists.lugod.org>
Sent: Thursday, July 28, 2005 9:35 AM
Subject: Re: [vox-tech] Using setleds


On 7/27/05, John Wojnaroski <castle@mminternet.com> wrote:
> Hi,
>
> Is there a way to use 'setleds' inside a program?  My understanding is
that
> it only works with VTs (tty0 -- ttyxxx) and programs using input devices
> such as /dev/pts/0 will not work.
>
> Regards
> John W.

You can use setleds inside a program by simply executing it as you
would any other UNIX program, using system(3) or fork(2) and exec(2).

If you're trying to use setleds on an x display, here's a little C
program that can toggle the numlock key. I have it run in my .xsession
so that it always turns on numlock when I log in. You can also look at
http://freshmeat.net/projects/numlockx/ which is similar.

//numlock.c
//compile using:
//gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o setnumlock Numlock.c
-lX11 -lXtst#include <X11/extensions/XTest.h>
#include <X11/keysym.h>

int main(void) {
        Display* disp = XOpenDisplay( NULL );
        if( disp == NULL )
                return 1;
        XTestFakeKeyEvent( disp, XKeysymToKeycode( disp, XK_Num_Lock),
True, CurrentTime );
        XTestFakeKeyEvent( disp, XKeysymToKeycode( disp, XK_Num_Lock),
False, CurrentTime );
        XCloseDisplay( disp );
        return 0;
}

//end of source code

--Ken Bloom
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech


_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.