Author |
Message |
georgeeeejacob
Joined: 10 Sep 2007 Posts: 3
|
Posted: Wed 12 Sep 2007, 03:10 Post subject:
How to invoke system shutdown on clicking the power button? |
|
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?
|
Back to top
|
|
 |
mcewanw
Joined: 16 Aug 2007 Posts: 3200
|
Posted: Wed 12 Sep 2007, 06:28 Post subject:
maybe not possible |
|
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.
|
Back to top
|
|
 |
Pizzasgood

Joined: 04 May 2005 Posts: 6266 Location: Knoxville, TN, USA
|
Posted: Wed 12 Sep 2007, 17:03 Post subject:
|
|
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).
_________________ 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

|
Back to top
|
|
 |
trapster

Joined: 28 Nov 2005 Posts: 2118 Location: Maine, USA
|
Posted: Wed 12 Sep 2007, 17:19 Post subject:
|
|
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
|
Back to top
|
|
 |
Pizzasgood

Joined: 04 May 2005 Posts: 6266 Location: Knoxville, TN, USA
|
Posted: Wed 12 Sep 2007, 17:33 Post subject:
|
|
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.
_________________ 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

|
Back to top
|
|
 |
mcewanw
Joined: 16 Aug 2007 Posts: 3200
|
Posted: Wed 12 Sep 2007, 22:34 Post subject:
its good to be wrong! |
|
I love being wrong, then I learn something new!
|
Back to top
|
|
 |
HairyWill

Joined: 26 May 2006 Posts: 2946 Location: Southampton, UK
|
Posted: Mon 17 Sep 2007, 06:47 Post subject:
|
|
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/viewtopic.php?p=141015#141015
and the acpid.pup
http://www.murga-linux.com/puppy/viewtopic.php?p=94102#94102
</edit>
_________________ Will
contribute: community website, screenshots, puplets, wiki, rss
Last edited by HairyWill on Tue 18 Sep 2007, 01:51; edited 1 time in total
|
Back to top
|
|
 |
georgeeejacob
Joined: 06 Jul 2007 Posts: 38
|
Posted: Tue 18 Sep 2007, 00:26 Post subject:
|
|
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??
|
Back to top
|
|
 |
Bruce B
Joined: 18 May 2005 Posts: 11488 Location: The Peoples Republic of California
|
Posted: Tue 18 Sep 2007, 03:47 Post subject:
|
|
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?
----------------------
|
Back to top
|
|
 |
georgeeejacob
Joined: 06 Jul 2007 Posts: 38
|
Posted: Tue 18 Sep 2007, 04:05 Post subject:
|
|
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...
|
Back to top
|
|
 |
Bruce B
Joined: 18 May 2005 Posts: 11488 Location: The Peoples Republic of California
|
Posted: Tue 18 Sep 2007, 05:14 Post subject:
|
|
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?
|
Back to top
|
|
 |
HairyWill

Joined: 26 May 2006 Posts: 2946 Location: Southampton, UK
|
Posted: Tue 18 Sep 2007, 06:16 Post subject:
|
|
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: community website, screenshots, puplets, wiki, rss
|
Back to top
|
|
 |
georgeeejacob
Joined: 06 Jul 2007 Posts: 38
|
Posted: Wed 19 Sep 2007, 00:43 Post subject:
|
|
Bruce, i didt get u, actually...u want me to make it clear or what??
|
Back to top
|
|
 |
Pizzasgood

Joined: 04 May 2005 Posts: 6266 Location: Knoxville, TN, USA
|
Posted: Wed 19 Sep 2007, 21:26 Post subject:
|
|
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....
Quote: | 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! ) 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....
_________________ 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

|
Back to top
|
|
 |
|