奇科電腦 回奇科電腦首頁奇科電腦LPI課程資訊奇科電腦Embedded課程資訊奇科電腦Cisco課程資訊奇科電腦Programming課程資訊奇科電腦Smartphone App課程資訊
Tech Tips8  How to make init receive fixed keyboard combination to implement commands?

Author: Ben|Date: 2007/06/07|Back to Tech Tips

If we want to make init receive fixed keyboard combination to implement commands, the following procedures interprets how to find out keyboard files and commands in system:

1. Find out related RPM, e.g. kbd-1.12-19.el5 in CentOS5
2. Understand kbrequest behavior in /etc/inittab
3. Change keyboard corresponding content
4. Run ‘loadkeys –d’ to start changed content

Every system has corresponding keyboard files including the definition and code of each keyboard. In CentOS5 they are saved in /lib/kbd/keymaps/i386.

We can use loadkeys to know the default keyboard configuration of current system.

Next, there is an action named as kbrequest in /etc/inittab which can capture KeyboardSingnal to implement command. Thus, we can add the following line in /etc/inittab:
kb::kbrequest:/sbin/shutdown -t3 -r now

Then change the file ‘defkeymap.map.gz’. Add the following contents in Insert key definition:
keycode 110 = Insert
altgr control keycode 110 = KeyboardSignal
control alt keycode 110 = KeyboardSignal

So Alt+Ctrl+Ins will send KeyboardSingnal
At last, restart init by running ‘init q’ and then mount new added keyboard combination by running ‘loadkeys –d’. The whole configuration completes!


Best Browse: 1024x768 Copyright 2010 GeeGo Systems, Ltd.
service@geego.com.tw|DL: 0800-296-296|3F., No.60, Zhulun St., Zhongshan Dist., Taipei City 104, Taiwan (R.O.C.)|02-2711-6373