- 論壇徽章:
- 0
|
該程序可以實(shí)現(xiàn)SCO OpenServer在硬件檢測完畢后自動(dòng)Numlock
lockkeys編譯方法:cc -o lockkeys lockkeys.c
實(shí)現(xiàn)步驟:
1、將lockkeys執(zhí)行程序拷貝到/etc目錄下,并賦予執(zhí)行權(quán)限;
2、把numlock.init.string中的代碼加入到/etc/inittab文件中指令行的第一行。
numlock.init.string代碼內(nèi)容:
snum::sysinit:/etc/lockkeys numlock on /dev/console 2>&1
lockkeys源代碼:
/*
* Program to control the console lock keys states
*
* Build with "cc -o lockkeys lockkeys.c"
*/
#include
#include
#include
#include
#define RDFD 0
#define CAPSLOCK 0x01
#define NUMLOCK 0x02
#define SCROLLLOCK 0x04
void main( argc, argv )
int argc;
char *argv[];
{
char c;
int function, key;
if ( argc != 3 ) {
fprintf( stderr, "Usage: lockkeys key on | off | toggle
" );
exit( 1 );
}
if ( !strcmp( argv[2], "off" ))
function=0;
else if ( !strcmp( argv[2], "on" ))
function=1;
else if ( !strcmp( argv[2], "toggle" ))
function=2;
else {
fprintf( stderr,
"lockkeys: function must be on, off, or toggle
" );
exit( 1 );
}
if ( !strcmp( argv[1], "numlock" ))
key=NUMLOCK;
else if ( !strcmp( argv[1], "capslock" ))
key=CAPSLOCK;
else if ( !strcmp( argv[1], "scrolllock" ))
key=SCROLLLOCK;
else {
fprintf( stderr,
"lockkeys: key must be numlock, capslock, or scrolllock
" );
exit( 1 );
}
if ( ioctl( RDFD, KDGETLED, &c ) != 0 ) {
perror( "lockkeys: can't get current lock state" );
exit( 2 );
}
if ( function == 0 )
c &= ~key;
else if ( function == 1 )
c |= key;
else
c ^= key;
if ( ioctl( RDFD, KDSETLED, c ) != 0 ) {
perror( "lockkeys: error setting lock state" );
exit( 2 );
}
exit( 0 );
}
注:該程序非我原創(chuàng),來自SCO網(wǎng)站,該程序不能在Xwindow中使用僅支持控制臺(tái)模式。
本文來自ChinaUnix博客,如果查看原文請點(diǎn):http://blog.chinaunix.net/u/101/showart_159.html |
|