Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
What desktop environment/window manager are you using? –  bahamat Dec 22 '12 at 9:41
    
@bahamat: Check out this -- if you need something else, tell me, and I'll improve the script :) –  Emanuel Berg Dec 22 '12 at 22:38
    
I don't know if it is the case but with systemd I had to manually stop the PowerKey to be handled by systemd with setting HandlePowerKey=ignore in /etc/systemd/logind.conf. Hope that helps. –  Endre Szabo Jan 30 '13 at 23:04
    
@EndreSzabo: You got my hopes up, but, it seems I don't have that file at all. Are you on Ubuntu? Or did you actually install/enable anything to get that file? I'm on Debian and it seems, if indeed possible, you don't have that by default. –  Emanuel Berg Jan 31 '13 at 1:43
add comment

1 Answer 1

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.

share|improve this answer
    
Thanks! Check out my post for an edit with more information. –  Emanuel Berg Jan 31 '13 at 23:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.