# ACPI commands

## cyfred

Howdy,

I have my laptop setup nicely running Gentoo and all seems to work well, except for the power management side of things. 

What I cant get to work it the ACPI command executions.

For example I have in /etc/acpi/events/default

```
event=button power.*

action=/sbin/init 0
```

Which should shutdown the PC when the power button is pressed.

The log file /var/log/acpid shows that the power button was registered as being pressed, but also shows that nothing was done.

My reckoning is that acpid hasnt got permission to execute /sbin/halt but that is the only thing I can come up with. 

Also what action should I set to have the machine enter suspend or standby modes? There is a lot on things needing S1 S3 S4 etc... but nothing on what the actual commands are. 

Someone please help   :Confused: 

----------

## fbix

My system send to this event to me:

received event "button/power PWRF 00000080 00000002"

so I've modified 

/etc/acpi/events/default:

event=button/power.*

action=/sbin/init 0

and it's worked

bix

[/quote]

----------

## cyfred

What about suspending?

What command do I use to suspend and standby the system?

I want to put the machine into either (depending which works) by pressing the power button, not shut it down.

----------

## Reformist

I would also like to know how to do this. Lol is this even possible? The mor eI work with linux on my laptop, the less I hear of a succesful power-managed system....

----------

## monkeyBox

I'd also like to know... It suprises me how hard it is to find information on this.  ACPI has been around long enough I would think it would have been fully implemented sooner. Oh well.

The basic things I'm wanting to do but can't figure out how:

CPU speed stepdown

Suspend to ram  (normal suspend)

Suspend to disk  (hibernation)

if ANYONE knows how to do ANY of these please let us know!!

----------

## Jimboberella

In my experince with linux on laptops, all the automatic power saving features have just worked. Sleep mode and all. This is on Dell and Compaq models over the past few years, with Mandrake.

----------

## monkeyBox

 *Jimboberella wrote:*   

> In my experince with linux on laptops, all the automatic power saving features have just worked. Sleep mode and all. This is on Dell and Compaq models over the past few years, with Mandrake.

 

Are you saying you know how to use the features I mentioned above (at least in gentoo anyways)? If so, could you please enlighten us?  :Smile: 

----------

## Reformist

"Just worked"? How did you enable standby? Is it set to a timer or did you run a command? If so, which command did you run?

Please be a bit more specific. I'm almost to the impression that I can just "think" my computer off and it will "just work".

Forgive my sarcasm.

----------

## Reformist

I think Jimboberella means by BIOS functions and timers. Unfortunately for me, I have no such settings in my BIOS because my BIOS is ghetto, came by default on an HP laptop. The users in this thread are looking for a specific command to put the system into standby, or hibernation. WIthout such commands ACPI is useless, and it appears there are no such commands because I'd think someone would have found them by now.

Or maybe I (we're) just blind.

----------

## Reformist

Ok, it's quite obvious the level of ACPI functionality is either non-existant, or mystical and hidden, even to the developers.

I've found from this thread (6 months ago)

https://forums.gentoo.org/viewtopic.php?t=4526&highlight=standby

That none of them have any idea how to do any kind of standby or software suspend (hibernation).

The very idea of software suspend (hibernation) is new and beta, and currently under development. I would have thought more progress in terms of the maturity of something like this would have been made, but you never can tell it seems...

https://forums.gentoo.org/viewtopic.php?t=29159&highlight=software+suspend

http://www.darav.de/gentoo/swsusp.html

http://fchabaud.free.fr/English/default.php3?COUNT=3&FILE0=Tricks&FILE1=Laptop&FILE2=Swsusp

----------

## Ian Goldby

Ok, for documentation have a look at:http://acpi.sourceforge.net/

http://acpi.sourceforge.net/documentation/sleep.html

http://acpi.sourceforge.net/documentation/processor.html

I assume from this that 

```
$ cat S0 > /proc/acpi/sleep
```

 should suspend the system, and so on.

I haven't tried any of this yet. I'm just compiling my kernel to enable APCI instead of APM, since APM seems to be incompatible with xfree4.3.0, causing it to freeze on resuming from a suspend.

----------

## Ian Goldby

Ok, that should have been 

```
# echo -n 1 > /proc/acpi/sleep
```

 Well, it sort of worked, though not in any useful sense. The next prompt didn't appear, and the power light started to flash. But the CPU fan didn't stop, and it woke up again just with a move of the mouse. Not very useful, really.

One warning: 

```
# echo -n 5 > /proc/acpi/sleep
```

 caused an immediate power-off without going through the proper shutdown procedure. Don't do this at home, kids. Also, when I tried to set the alarm (cat xxxx > /proc/acpi/alarm) I got a complete freeze. Don't do that either, unless you like rescuing corrupted filesystems.

----------

## Ian Goldby

According to this 

```
# echo -n 3 > state
```

 executed in the /proc/acpi/fan/FAN directory should turn the fan off. Doesn't work for me.

----------

## Reformist

Greaty job iangoldby, this is some much needed information! Now we know how to execute a few power commands, and when they work, well, it will be easy to write a front end.

None of the sleep states worked for me (by executing echo -n x > /proc/acpi/sleep, where x is 1-5) except the 5th stage, which you tried, which gave me a hard reboot. "Soft restart" indeed. They say that mode corresponds to the windows' shutdown command; I'd say it needs some work.

Anyway, good info to know. If any of the states work for anyone, or if there is progress... post!

----------

## Reformist

Also, for those interested, the doc links that iangoldby posted also contain information on how to "step down" your cpu, to consume less power. Not sure if it actually works, but it is supported and looks very cool. I didn't try this out, because sleep modes are the most neccessary for me, and CPU stepping is only useful to me if it is done automatically while the system is detected as being idle.

----------

## CodeHacker84

I have followed the links that iangoldboy has posted, and I am currently reading the ACPI 2.0 standard.  It seems to me that there is a misconception on the S5 power state at this point, because according to the ACPI 2.0 standard, section 2.4; the Sleep 5 state is defined to be a state where the system saves nothing and does a "soft power off," meaning that it is a state similar to flipping a power switch, but it can be controlled electronically.  The Sleep 4 state is where one would want to be for a typical "Hibernate" command, where all system information is saved to disk, and one of the higher sleep states would be for a "Sleep" command.

P.S.  Sorry for the lengthy post, but this also helps me clarify my understanding of all this information that I've absorbed in the past 24 hours.

----------

## Ian Goldby

I had a go with the CPU throttling, and it made X very choppy indeed, so I guess it was working  :Wink: 

(I've given up on APCI for now and have gone back to APM, but I still can't get it to restore after a sleep when KDE is running. I think I will have to resign myself to booting the PC every time I want to use it.)

Ian

----------

## zumo

I think I may have found a hibernate program.  I will try it out when I have time, but hopefully you all will try it out in parallel   :Wink:  Linkage below:

http://sourceforge.net/projects/swsusp

----------

## Ian Goldby

There's a good thread on swsusp here.

I thought 1 minute 19 seconds to restore from suspend versus 1 minute 56 seconds to boot from scratch was distinctly unimpressive, and rather defeats the point.

----------

## CodeHacker84

Yes, the latency between the suspended state and the working state suggests to me that the suspend command is using a higher sleep state (S4) than, IMHO, it should (S2).  I think that the purpose of a suspend should be to reduce power consumption to low levels, but that restores should be rather quick.   Perhaps the developers should make a distinction somewhere between a high sleep state (S4) and a low sleep state (S2), not unlike *GASP* WinBlows' "hibernate" and "sleep" commands.

[EDIT] Oh, perhaps someone can find a way to just "dump" all the contents of memory to disk and then merely restore from the "dump."  Of course, I suppose that all the other things that need to be saved (such as /proc) increase the latency to the point where almost any hibernate command is pointless, like iangoldby said.

----------

## Ian Goldby

I may be talking nonsense here, but doesn't swsusp just store the entire state of the PC to disk and then completely power-off? Then when you power back on later, it goes through a customised boot process that restores the PC to where it last was.

That's very different to APM/APCI suspend/hibernate functions, where removing all power will cause you to lose the state of the machine.

----------

