Prevent Power Button from Shutting Down System

Non release banter
cttan
Shogun
Shogun
Posts: 333
Joined: 26 Jan 2011, 16:15
Distribution: Porteus 3.2 and 4.0 64bit KDE
Location: Malaysia

Prevent Power Button from Shutting Down System

Post#1 by cttan » 26 Nov 2012, 08:19

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?
Last edited by cttan on 04 Dec 2012, 21:58, edited 2 times in total.

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: Prevent Power Button from Shutting Down System

Post#2 by fanthom » 26 Nov 2012, 09:39

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
Please add [Solved] to your thread title if the solution was found.

cttan
Shogun
Shogun
Posts: 333
Joined: 26 Jan 2011, 16:15
Distribution: Porteus 3.2 and 4.0 64bit KDE
Location: Malaysia

Re: Prevent Power Button from Shutting Down System

Post#3 by cttan » 27 Nov 2012, 13:07

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 ...

markdown
White ninja
White ninja
Posts: 8
Joined: 03 Jan 2017, 11:52
Distribution: porteus
Location: marktown

Re: Prevent Power Button from Shutting Down System

Post#4 by markdown » 05 Jan 2017, 18:38

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.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Prevent Power Button from Shutting Down System

Post#5 by brokenman » 05 Jan 2017, 22:20

There is an acpi handler file at /etc/acpi/acpi_handler.sh

Try changing the /sbin/init 0 line to something else.
How do i become super user?
Wear your underpants on the outside and put on a cape.

markdown
White ninja
White ninja
Posts: 8
Joined: 03 Jan 2017, 11:52
Distribution: porteus
Location: marktown

Re: Prevent Power Button from Shutting Down System

Post#6 by markdown » 06 Jan 2017, 08:13

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.

Post Reply