Jump to content

Power Off Button


bigscott
 Share

Recommended Posts

Hi all,

 

I am so happy to find these forums. I was looking for a Mandrake forum that used a good BB like Invisionboard. (I can't make heads or tails out of MandrakeExperts thread organizations).

 

I spent hours, yeah days, trying to find a poweroff button solution that worked with linux, and thought I'd share the power off that finally worked for me, hopefully to save others some grief. (Of course, you know that all hardware, etc., is different so I can't say that this will work for everyone.)

 

What this does: When you hit the power button on your PC, it performs a clean shutdown (shuts down processes and then powers off).

 

My system: Dell Precision Workstation (desktop tower) with Pentium4, 2.4Gz Processor

 

My distro: Mandrake 9.2 download edition using 2.4.22-10mdk kernel

 

Prerequisites: acpi and acpid (Don't know why it needs both, but it appears to be necessary). I just uninstalled apm and installed both of these programs through the install software desktop link on Mandrake 9.2. NOTE: There is no need to compile or recompile the kernel to do this.

 

1. Open a Konsole and "su root"
2. "cd /etc/acpi/events"
3. "touch powerbtn"  (this makes a new file called 'powerbtn')
4. "gedit powerbtn" and insert the following 2 lines into the empty file: 
event=button[  /]power
action=sudo /sbin/halt
5. "ls /etc/acpi/events" and remove any duplicate files with a tilde (~) at the end of the file name
6.  "service acpi restart"
7. "service acpid restart"
8. You should now be able to perform a clean shutdown just by pressing the power button.

 

Kind Regards,

Scott

Edited by bigscott
Link to comment
Share on other sites

Interesting. Did you not have an /etc/acpi/power file w/ the following in it?

 

event=button/power (PWR.|PBTN)

action=/sbin/poweroff

 

Works for me but I'm desktop, so that may have something to do with it. I logout of X and from init 3 do poweroff.

Yes, I already had an file named "power" in my /etc/acpi directory that had those codes, but it didn't work. Originally I had "lid" and "power" files in that directory, and I just added a file named 'powerbtn' . Note that I added the 'sudo' so that all users on my PC could use it.

 

This is on a desktop PC too... tall tower (Dell Precision 360). This method is much quicker than logging out of X, going to runlevel 3, and then doing a poweroff. IMHO, this is the way a power button should work... doing a clean shutdown and then powering off.

 

Before, I could only get a clean shutdown by either going to a Console and doing a halt OR logging out, waiting on logout screen, telling the computer what I wanted to do, etc... you know the drill. That implementation of going through all of those screens to logout or poweroff was copied from Windows illogical way of doing things from the start menu. (It makes no sense to go to a 'Start' menu to 'Stop" something.)

 

I'm running a dual-boot system with Windows XP Professional and Linux Mandrake 9.2 with lilo as the boot manager. Windows does a clean shutdown for me by just pressing the power button, but I think this may be Dell specific. Now, both operating systems do clean shutdowns and power off with the power button.

 

Now, I am working on getting all devices to turn on and off by the power button, such as monitor, printer, modem, etc. I don't know about you, but electricity is expensive where I live.:o I have a Belkin UPS 350vA, and it has linux software that will shutdown everything (works with Mandrake), but there's no way to turn it back on, other than going under the desk and turning the UPS back on. I want to be able to turn everything ON and OFF with my PC's power button.

 

NOTE: I think the power off solution is important. Why? Most people expect a power button to "power off", and if someone else hits the power button to turn off your computer, then this clean shutdown routine could prevent damaged files. It's also convenient.

Edited by bigscott
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...