How to invoke system shutdown on clicking the power button?

Booting, installing, newbie
Post Reply
Message
Author
georgeeeejacob
Posts: 3
Joined: Mon 10 Sep 2007, 10:25

How to invoke system shutdown on clicking the power button?

#1 Post by georgeeeejacob »

I am looking for an option of shutting down linux through power button itself.ie, on clicking power button, the system should go for shutdown if it is in on condition.Can someone help me out of this?

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

maybe not possible

#2 Post by mcewanw »

Looks like you have no takers on this one, sorry. I haven't heard of such a method. It may not be possible, but maybe someone knows better.

My feeling is that the power button isn't a keyboard key as such and so cannot be read by the operating system. Rather, it is part of the underlying hardware design. Hence you can accidentally switch off the computer without doing a proper shutdown. The pressing of keyboard keys on the other hand are seen by the OS; the combination Ctrl-alt-delete, for example is generally set up (in the Linux config file /etc/inittab) to cause a proper controlled shutdown.

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#3 Post by Pizzasgood »

It ought to be possible. It works that way in Windows. Sure, Windows is a little different, but it doesn't have any super powers. If Windows is aware of the power button, than it's at least possible to make Linux aware of it. Whether the code to do that has been written yet is another story. But I imagine it has.

And that would be a good feature in case someone used to Windows tries turning it off with the power button and gets annoyed at it not working (or accidentally does a hard shutdown).
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#4 Post by trapster »

Try Here.
I'm not sure if the modules mentioned have been "compiled" into the kernel, but the rest seems straightforward enough :)

Oh, our /acpi is in /proc....not /etc/acpi like the article mentions. (at least in my 216 frugal install)
AND...if you want to open /proc, don't use Rox. It locks right up every time I try. (I use xfe instead)
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#5 Post by Pizzasgood »

You can skip /proc and go right to /proc/acpi like this:
rox /proc/acpi
That way it won't lock up. I usually just use the commandline when I'm dealing with /proc though.

Oh, and if you follow those directions, replace /sbin/poweroff with /usr/X11R7/bin/wmpoweroff or you might have issues.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

its good to be wrong!

#6 Post by mcewanw »

I love being wrong, then I learn something new! :-)

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

#7 Post by HairyWill »

georgeeejacob,
in another thread you have said you are getting an error about missing /proc/acpi/event

Puppy does have acpi but doesn't always load it.
Check to see if you have the directory /proc/acpi if you don't then acpi hasn't loaded
try using the kernel parameter
puppy acpi=on
or
puppy acpi=force
at the pause when you boot

<edit>for completeness I'm including a link to blackadder's instructions
http://www.murga-linux.com/puppy/viewto ... 015#141015
and the acpid.pup
http://www.murga-linux.com/puppy/viewto ... 4102#94102
</edit>
Last edited by HairyWill on Tue 18 Sep 2007, 05:51, edited 1 time in total.
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

georgeeejacob
Posts: 38
Joined: Fri 06 Jul 2007, 11:48

#8 Post by georgeeejacob »

thanx for ur reply...that was really a good piece of information..Now, am able to giv modprobe button and acpid commands..on dmesg command am getting 3 buttons like
PWRF
PWRB
SLPB
what to do now?i tried editing etc/acpi/events/power script to
event button[ /]power
action=/usr/X11R7/bin/wmpoweroff

Still its not working.
can u help me pls??

Bruce B

#9 Post by Bruce B »

I'm surprised this has been such a topic.

Without looking into my own BIOS setup, I think it has a shutdown option for instant or delayed.

I think it would be about the same thing as saying:

Pull the plug right now

or

Wait a few seconds and then pull the plug

----------------------

Meaning that all that happens is the power gets cut. But the delay gives any ongoing disk writes a better chance of finishing?

Do it seem to ya all this is a reasonable theory of how my hardware shutdown is working?

----------------------

georgeeejacob
Posts: 38
Joined: Fri 06 Jul 2007, 11:48

#10 Post by georgeeejacob »

got my power button shutdown working.there was a small change in the script

event=button[ /]power
action=/usr/X11R7/bin/wmpoweroff

this is the scriipt that worked fine for me...

Bruce B

#11 Post by Bruce B »

georgeeejacob wrote:got my power button shutdown working.there was a small change in the script

event=button[ /]power
action=/usr/X11R7/bin/wmpoweroff

this is the scriipt that worked fine for me...
At the strong risk of asking a really dumb question. How do you know it works, by watching the screen text as it goes through an orderly shutdown? Or some other way?

User avatar
HairyWill
Posts: 2928
Joined: Fri 26 May 2006, 23:29
Location: Southampton, UK

#12 Post by HairyWill »

Bruce B wrote:At the strong risk of asking a really dumb question. How do you know it works, by watching the screen text as it goes through an orderly shutdown? Or some other way?
This made me chuckle, though I presume if it doesn't work properly then X won't start next boot.

I can confirm the the button event works I've set mine to start ROX.
Slightly stupid
press < 1 second does nothing
1 < press < 4 seconds starts ROX
(hold that button too long) press > 4 seconds presumably does a hard reset, I haven't tested it yet.
Will
contribute: [url=http://www.puppylinux.org]community website[/url], [url=http://tinyurl.com/6c3nm6]screenshots[/url], [url=http://tinyurl.com/6j2gbz]puplets[/url], [url=http://tinyurl.com/57gykn]wiki[/url], [url=http://tinyurl.com/5dgr83]rss[/url]

georgeeejacob
Posts: 38
Joined: Fri 06 Jul 2007, 11:48

#13 Post by georgeeejacob »

Bruce, i didt get u, actually...u want me to make it clear or what??

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#14 Post by Pizzasgood »

He means, how do you distinguish between pressing the button and it executing the wmpoweroff script, and pressing the button and it just cutting the power.

If it cut the power, there wouldn't be any text. It would just go off. Unless you have a very fast computer, so that shutting down via wmpoweroff makes it appear to instantly power off, it would be pretty easy to tell....
I can confirm the the button event works I've set mine to start ROX.
Slightly stupid
press < 1 second does nothing
1 < press < 4 seconds starts ROX
That's pretty cool. You could use it as an extra button, especially for actions you might regret (like powering off! :lol: ) Seriously though, you could make it into a "panic" button, that would do a quick rm -r /*, or you could set it to Xlock, so pushing it would "lock down" the system. All kinds of possibilities. If you had a missile launcher mounted on your roof and controlled through your PC, you could even set it to the fire sequence. Just don't let someone else use that computer, or they might try turning it off with devastating results....
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

Post Reply