Power Switch

ME dugan at libwais.sonoma.edu
Mon Feb 14 12:34:13 PST 2000


On Mon, 14 Feb 2000, Walter Coole wrote:
> Subject: Power Switch
> 
> Does anyone know how to tell Linux to use the soft power switch on my
> newish Compaq?
> 
> What I want is: when my three-year-old pushes the switch, it does a
> clean shutdown.  Windows (bleah) knows how to do this, so the hardware
> is there.  My old HP-UX system could handle this, but I don't know if
> Linux knows this trick.

Since Linux is open source, you do have access to the kernel source code.
The following two sections deal with control-alt-delete triggers and
handling.

A big-wrench method of attack could include modifying your kernel source
to del with another key sequence (assuming the soft-keys on your keyboard
generate keyboard interrupts and are not part of an extra serial port
communications.)

starting with an examination of:
kernel/sys.c
drivers/char/keyboard.c

Something tells me that there is an easier solution than this, but I have
not had a need for it, so I never researched it.

An older document (circa 1995) on the keyboard can be found here:
http://www.win.tue.nl/math/dw/pp/aeb/linux/kbd/Linux_keyboard_driver
A more recent document on keyboard/console stuff:
http://linux.com/howto/Keyboard-and-Console-HOWTO-8.html

Another suggestion is examination of
/etc/inittab for init
If you can manage to map the pressing of a key sequence to the sending of
a signal "SIGINT" to init, then you can effectively perform a reboot.

Check out "man loadkeys": it allows you to map strings to key sequences
from the console, but I do not see anything about assigning keys to
running scripts. Perhaps map the key sequence for that key to send the
same sequence as a control-alt-delete? If this is possible, it may offer a
simple fix for you.

***
Hopefully, someone else has experience with this and can offer you
direction more orthodoxed than these suggestions.
***

Unless you can find a quick and easy solution to run a program, or
configure a running program to interpret the key-sequence/signal from the
console, I would look into modifying the keyboard driver in kernel land. 
If you know the key-code/signal generated for that key, then you may be
able to add an check for it as well as control-alt-delete when it is
pressed, and perform the same reboot. 

Maybe add a patch to the kernel for a new kernel option, and submit it to
the developers for integration into the main tree?

(A configure option to choose "y" and then enter the key sequence you want
to use, and what you want it to do.)

Sorry I couldn't help,
-ME





More information about the talk mailing list