Have Sun keyboard moon key (116) not shut down the computer

acpikeyboardkeyboard shortcutsshutdown

On my Sun keyboard, the top-rightmost key (with a moon image, right above the keypad) shuts down my computer. I'd like it not to, as I hit it by mistake now and then.

In /etc/default/keyboard, I only have

XKBMODEL="inspiron"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="compose:lwin,terminate:ctrl_alt_bksp"

With showkey, for this key, I get

kb mode was UNICODE
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
keycode  28 release
keycode 116 press
keycode 116 release
caught signal 1, cleaning up...

So the key is identified as 116 by showkey.

EDIT (in response to Mr. Szabo below)

So, there are two keys involved here: The key I describe above (on my Sun keyboard), and the power button on my laptop hull. However, the computer seems to interpret those keys equivalently.

I'd like the button on my laptop to work as as power button, as then, I can turn off my computer without having to type the super user password after shutdown.

However, I don't like the keyboard key to work this way, as it is next to the volume control, and above the numpad; it is easy to hit it by mistake.

I do have acpid – but the empty files power and powerbtn in /etc/acpid/events/ did not have any affect; as for the script you mention, I don't have it.

But, by renaming /etc/rc2.d/S15acpid so it won't run (i.e., lowercasing the initial S), neither key will reboot the computer. And I guess that's a fall forward as I prefer typing the super user keyword to accidentally shutting down my computer.

Best Answer

I suppose you have acpid installed, in this case you should place a (an even empty) file at /etc/acpi/events/powerbtn as the default handler checks if this file exists and if it is, it will not initiate a shutdown on its own.

From /etc/acpid/powerbtn-acpi-support.sh:

if [ -f /etc/acpi/events/powerbtn -o -f /etc/acpi/events/powerbtn.dpkg-bak ] ; then 
    logger Acpi-support not handling power button, acpid handler exists at /etc/acpi/events/powerbtn or /etc/acpi/events/powerbtn.dpkg-bak.
    exit 0
fi

Just to be totally sure, you can also comment out the line #31 having:

    /sbin/shutdown -h -P now "Power button pressed"

in the very same file.

Related Question