Page 1 of 1

Prevent Power Button from Shutting Down System

Posted: 26 Nov 2012, 08:19
by cttan
Hi ,

I have changed the power setting to "Do Nothing" when the power button is pressed. See picture.
http://postimage.org/image/ay5425svh/

But the system still shutdown. Then I commented out the power line in /etc/acpi/acpi_handler.sh
Now it is not shutting down the system but prompting me with a dialog to shutdown system or reboot or ...

Code: Select all

#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@

case "$1" in
  button)
    case "$2" in
      power) echo "not possible to halt!!!" #/sbin/init 0
         ;;
      *) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac
Anybody have any clue that I can prevent the system from shutting down if the power button is pressed?

Re: Prevent Power Button from Shutting Down System

Posted: 26 Nov 2012, 09:39
by fanthom
hi cttan,

you have to blacklist 'button' kernel driver:

Code: Select all

echo -en "Prevent system from going down:\nblacklist button" >/etc/modprobe.d/button.conf
Cheers

Re: Prevent Power Button from Shutting Down System

Posted: 27 Nov 2012, 13:07
by cttan
Hi fanthom,
Thank you for the quick and precise answer! :good:

Edit : 5 Dec 2012
Sorry for late reply. But the solution only work in text command line only mode.
In KDE, it is still prompting me with a dialog to shutdown system or reboot or ...

Re: Prevent Power Button from Shutting Down System

Posted: 05 Jan 2017, 18:38
by markdown
fanthom wrote:hi cttan,

you have to blacklist 'button' kernel driver:

Code: Select all

echo -en "Prevent system from going down:\nblacklist button" >/etc/modprobe.d/button.conf
Cheers
Sorry to bump an old thread(figured it's still better than to start a new one).

How can this be achieved on 3.2.2? My family and I use Porteus exclusively on copy2ram mode and even accidentally grazing the power button, immediately starts the gentle shutdown(so any open files will be abruptly closed without saving).

Getting the power menu window when the power button is pressed would be excellent, but if not, at least disabling the power button so shutdowns need to be selected from the main menu would be the next best thing.

Thanks.

Re: Prevent Power Button from Shutting Down System

Posted: 05 Jan 2017, 22:20
by brokenman
There is an acpi handler file at /etc/acpi/acpi_handler.sh

Try changing the /sbin/init 0 line to something else.

Re: Prevent Power Button from Shutting Down System

Posted: 06 Jan 2017, 08:13
by markdown
brokenman wrote:There is an acpi handler file at /etc/acpi/acpi_handler.sh

Try changing the /sbin/init 0 line to something else.
Elegant fix. Thanks mate.

Is there a recommended runlevel though? I've set it as runlevel 1, and pressing the power button as the guest user successfully triggers the power menu in GUI mode. In text mode, the button does nothing so the poweroff command needs to be invoked, which unfortunately can't be done by the guest user(without su). It's not a big deal though, since I rarely use the text mode. Thanks, and great work on 3.2.2.