confused about power managment with T520 with Debian with no DE

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

confused about power managment with T520 with Debian with no DE

keitho-2
When I bought my Lenovo Thinkpad T520 a few months ago I started off by
using Debian with Gnome. Recently I switched to using a window manager
(currently i3) instead of Gnome, and often I just use the console.

Since I switched away from using a DE I have been confused as to which
power management tools I should use and how to use them, due to my
inexperience.

The only thing I really need is to enable sleep or suspend at intervals or
on demand in order to conserve battery,

I downloaded pm-utils, but I don't know how to use them. I can't figure
out what/which tools are included- there's no manpage for "pm-utils" or
"pmutils" or "pm_utils", dpkg -s pm-utils doesn't provide the names of the
tools included in the package, the Debian site doesn't list the package
contents...what am I missing here? Maybe pm-utils isn't the best option
anyway?

According to http://www.thinkwiki.org/wiki/Standby_mode I should be able
to use Fn-F3 to enable standby on demand, but that doesn't work for me.
Anyone know how I can get that to work?

Because I originally had Gnome loaded and haven't removed it I may have
some Gnome power managment programs still lurking around- but I prefer to
remove them and use X tools instead.

Thanks,
Keith Ostertag



--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Paul Seelig-3
On 02/04/2012 07:10 PM, [hidden email] wrote:
> I downloaded pm-utils, but I don't know how to use them. I can't
> figure out what/which tools are included- there's no manpage for
> "pm-utils" or "pmutils" or "pm_utils", dpkg -s pm-utils doesn't
> provide the names of the tools included in the package, the Debian
> site doesn't list the package contents...what am I missing here?
> Maybe pm-utils isn't the best option anyway?
>
Try "dpkg -L pm-utils" to list the package contents. It will also show
you where the documents are located. Like for all other packages too,
it is usually in /usr/share/doc/<package name>/. Using grep, you can
narrow your search accordingly:

[root]~ # dpkg -L pm-utils | grep doc
/usr/share/doc
/usr/share/doc/pm-utils
/usr/share/doc/pm-utils/README.debugging
/usr/share/doc/pm-utils/changelog.Debian.gz
/usr/share/doc/pm-utils/TODO.Debian
/usr/share/doc/pm-utils/README
/usr/share/doc/pm-utils/HOWTO.modules
/usr/share/doc/pm-utils/HOWTO.hooks.gz
/usr/share/doc/pm-utils/changelog.gz
/usr/share/doc/pm-utils/buildinfo.gz
/usr/share/doc/pm-utils/NEWS.gz
/usr/share/doc/pm-utils/README.distributions
/usr/share/doc/pm-utils/copyright
/usr/share/doc/pm-utils/AUTHORS
/usr/share/doc/pm-utils/TODO
[root]~ # dpkg -L pm-utils | grep bin
/usr/sbin
/usr/sbin/pm-powersave
/usr/lib/pm-utils/bin
/usr/lib/pm-utils/bin/service
/usr/lib/pm-utils/bin/pm-action
/usr/bin
/usr/bin/pm-is-supported
/usr/sbin/pm-hibernate
/usr/sbin/pm-suspend-hybrid
/usr/sbin/pm-suspend
[root]~ #

Best regards
P. *8^)
--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Claudius Hubig-8
In reply to this post by keitho-2
Hello,

[hidden email] wrote:

>When I bought my Lenovo Thinkpad T520 a few months ago I started off by
>using Debian with Gnome. Recently I switched to using a window manager
>(currently i3) instead of Gnome, and often I just use the console.
>
>Since I switched away from using a DE I have been confused as to which
>power management tools I should use and how to use them, due to my
>inexperience.
>
>The only thing I really need is to enable sleep or suspend at intervals or
>on demand in order to conserve battery,

I am using pm-suspend and pm-hibernate from the pm-utils package[1]
to send my notebook into sleep or hibernate. Fn-* key combinations
trigger an ACPI event for me (check with acpi_listen) which I am
catching via files such as:

0 17:59 0 ares: ~ # cat /etc/acpi/events/fnf3-suspend
event=ibm/hotkey HKEY 00000080 00001003
action=/etc/acpi/suspend.sh
0 20:01 0 ares: ~ # cat /etc/acpi/suspend.sh
#!/bin/bash
 . /etc/acpi/common

# lots of snipped stuff I am too lazy to put into
# /etc/pm/sleep.d

pm-suspend --quirk-vbe-post

The event= argument can be read via acpi_listen and pressing the
corresponding button.

I am also using cpufreqd and thinkfan to control CPU and fan speed
according to my needs, but you didn’t seem to want this :)

Best regards,

Claudius

[1] You might not know about dpkg -L <packagename> which lists all
the files contained in a package. Additionally, at least my bash/man
knows about all the man pages upon tab completion, so that

$ man pm-<TAB>

prints out a nice list of possible completions.
--
To be or not to be, that is the bottom line.
Please use GPG: ECB0C2C7 4A4C4046 446ADF86 C08112E5 D72CDBA4
http://chubig.net/ http://nightfall.org


--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

keitho-2
In reply to this post by Paul Seelig-3
Thank you much! I wasn't aware of the dpkg -L option. A great tool I will
use much in the future. (I know that for some packages the -s option will
list programs included but I guess that depends on the
developer/maintainer...)

Any idea about enabling the Fn-F3 button? most of my other Fn buttons seem
to work...

Keith

> On 02/04/2012 07:10 PM, [hidden email] wrote:
>> I downloaded pm-utils, but I don't know how to use them. I can't
>> figure out what/which tools are included- there's no manpage for
>> "pm-utils" or "pmutils" or "pm_utils", dpkg -s pm-utils doesn't
>> provide the names of the tools included in the package, the Debian
>> site doesn't list the package contents...what am I missing here?
>> Maybe pm-utils isn't the best option anyway?
>>
> Try "dpkg -L pm-utils" to list the package contents. It will also show
> you where the documents are located. Like for all other packages too,
> it is usually in /usr/share/doc/<package name>/. Using grep, you can
> narrow your search accordingly:
>
> [root]~ # dpkg -L pm-utils | grep doc
> /usr/share/doc
> /usr/share/doc/pm-utils
> /usr/share/doc/pm-utils/README.debugging
> /usr/share/doc/pm-utils/changelog.Debian.gz
> /usr/share/doc/pm-utils/TODO.Debian
> /usr/share/doc/pm-utils/README
> /usr/share/doc/pm-utils/HOWTO.modules
> /usr/share/doc/pm-utils/HOWTO.hooks.gz
> /usr/share/doc/pm-utils/changelog.gz
> /usr/share/doc/pm-utils/buildinfo.gz
> /usr/share/doc/pm-utils/NEWS.gz
> /usr/share/doc/pm-utils/README.distributions
> /usr/share/doc/pm-utils/copyright
> /usr/share/doc/pm-utils/AUTHORS
> /usr/share/doc/pm-utils/TODO
> [root]~ # dpkg -L pm-utils | grep bin
> /usr/sbin
> /usr/sbin/pm-powersave
> /usr/lib/pm-utils/bin
> /usr/lib/pm-utils/bin/service
> /usr/lib/pm-utils/bin/pm-action
> /usr/bin
> /usr/bin/pm-is-supported
> /usr/sbin/pm-hibernate
> /usr/sbin/pm-suspend-hybrid
> /usr/sbin/pm-suspend
> [root]~ #
>
> Best regards
> P. *8^)
>


--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

keitho-2
In reply to this post by Paul Seelig-3
OK, so thanks to Paul I found out that I can use pm-suspend to put my T520
to sleep from the command line as root. And after doing so I can resume
from sleep with the Fn-F3 button.

pm-suspend says only root can invoke it. How to make it so I can do it
with my regular login?

In addition, it would be much easier if I could invoke it with the Fn-F3
button. This used to work under Gnome. In fact, since I moved away from
Gnome the laptop no longer goes into sleep mode when I close the lid.

Can someone teach me how to enable the Fn-F3 button to invoke sleep, and
how to configure the system so that closing the lid puts the laptop to
sleep?

Thanks,
Keith Ostertag


--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Jochen Spieker
In reply to this post by keitho-2
[hidden email]:
>
> Since I switched away from using a DE I have been confused as to which
> power management tools I should use and how to use them, due to my
> inexperience.
>
> The only thing I really need is to enable sleep or suspend at intervals or
> on demand in order to conserve battery,

I am using the awesome WM and have xfce4-power-manager in my
~/.xsession. You can configure actions for various events (idle timeout,
lid closing, low battery, button presses) easily through the GUI
preferences, but apart from the tray icon you don't even notice it is
running.

J.
--
I will not admit to failure even when I know I am terribly mistaken and
have offended others.
[Agree]   [Disagree]
                 <http://www.slowlydownward.com/NODATA/data_enter2.html>

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Paul Seelig-3
In reply to this post by keitho-2
On 02/04/2012 08:51 PM, [hidden email] wrote:
> Thank you much! I wasn't aware of the dpkg -L option. A great tool I will
> use much in the future. (I know that for some packages the -s option will
>
You would be surprised by the possibilities available via dpkg and
apt-get if you'd come around reading their respective man pages. Even
the man page for man might hold some very unexpected surprises and
lessons in selfeducation. Been there, done that - and it helps a lot! ;)
--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Tom Roche
In reply to this post by keitho-2

[hidden email] Sat, 4 Feb 2012 12:17:33 -0800
> pm-suspend says only root can invoke it. How to make it so I can do
> it with my regular login?

If supported by your distro, consider `sudo` and `sudoers`. See, e.g.,

https://help.ubuntu.com/community/Sudoers#Shutting_Down_From_The_Console_Without_A_Password

and s/shutdown/pm-suspend/g

HTH, Tom Roche <[hidden email]>
--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Joerg Bruehe-2
In reply to this post by keitho-2
Hi Keith!


[hidden email] wrote:
> [[...]]
>
> pm-suspend says only root can invoke it. How to make it so I can do it
> with my regular login?

1) The official way: use "sudo".

This requires that your regular login is listed as one of the accounts
who may do that, and you will be asked to enter your own password.

You can get of the password question by configuring your account in the
"/etc/sudoers" file with the "NOPASSWD" setting.
I do that on all my machines.

Relevant man pages: sudo, sudoers, visudo


2) The hack: use the "setuid" bit.

I have done this with the "/sbin/shutdown" command, it is owned by root:

  joerg@trift-6core:~$ ls -ld /sbin/shutdown
  -rwsr-xr-x 1 root root 23608 12. Aug 2008  /sbin/shutdown
     ^
Note the "s" where you normally would see an "x".
Anybody can call this program (see the final "x"), but when it starts it
will assume the "effective UID" of its owner, "root". Now, it will do
its actions.

Again, I typically do this on all my machines. By this setting, I make
it possible to enter this command after some long-running action, and my
machine will shut down eventually without me being present:

  /do/some/thing --long --hours ; /sbin/shutdown -h now

Assuming "pm-suspend" only checks its effective UID, this should work
the same way.

Note that this setting includes a risk: Any user of the machine, local
or remote, with the least privileges can now shut it down (suspend it).

Relevant man page: chmod


>
> In addition, it would be much easier if I could invoke it with the Fn-F3
> button. This used to work under Gnome. In fact, since I moved away from
> Gnome the laptop no longer goes into sleep mode when I close the lid.
>
> Can someone teach me how to enable the Fn-F3 button to invoke sleep, and
> how to configure the system so that closing the lid puts the laptop to
> sleep?

AIUI, there should be ways to configure any of these buttons so that its
press will trigger some configured action, but I never looked into this.
Most probably, the details depend on the window manager you are using now.
I have no specific idea about text mode for this.


HTH and regards,
Joerg

--
Joerg Bruehe  - persoenliche Aeusserung / speaking only for himself
mailto:[hidden email]
--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Jochen Spieker
Joerg Bruehe:
>
> 2) The hack: use the "setuid" bit.

That doesn't work for pm-suspend. On my system, it's a symlink pointing
to /usr/lib/pm-utils/bin/pm-action which is a shell script. The kernel
ignores the SUID for scripts.

J.
--
There is no justice in road accidents.
[Agree]   [Disagree]
                 <http://www.slowlydownward.com/NODATA/data_enter2.html>

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Joerg Bruehe-2
Hi everybody!


Jochen Spieker wrote:
> Joerg Bruehe:
>> 2) The hack: use the "setuid" bit.
>
> That doesn't work for pm-suspend. On my system, it's a symlink pointing
> to /usr/lib/pm-utils/bin/pm-action which is a shell script. The kernel
> ignores the SUID for scripts.

It definitely does ignore them.

Sorry, I didn't check "pm-suspend", so I stand corrected.


The setuid bit approach could still be used by writing a tiny C program
that does nothing but execute the script, having it owned by root, and
using the setuid bit for it - but this is a road which not everybody
will use.


Regards,
Joerg

--
Joerg Bruehe  - persoenliche Aeusserung / speaking only for himself
mailto:[hidden email]
--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

keitho-2
In reply to this post by keitho-2
Thanks to all who have responded. Unfortunately I still haven't resolved
the issue.

Jochen Spieker suggested I try xfce4-power-manager. I have tried that, and
it only partly works. It will turn off the monitor after a set time, but I
can't get it to put the computer into suspend mode (sleep, AKA suspend to
RAM) at all. Some of the options are greyed out (unavailable): the only
option I get for "When laptop is closed" is "nothing" or "lock screen".
Both the suspend and hibernate options under "Set computer inactivity
sleep mode" are greyed out as well. I wonder if the fact that I still have
gnome stuff loaded interfers with it? And of course it wouldn't help when
I am using console only (no X).

Tom Roche gave a link to a great tutorial for configuring the sudoers file
which I learned from  :-) (https://help.ubuntu.com/community/Sudoers)

Claudius Hubig gave some examples of capturing the acpi event to invoke a
shell script. I haven't been able to duplicate this.

When I run acpi_listen and press the FnF4 (sleep) button I get:
$acpi_listen
^@^@button/sleep SBTN 00000080 00000000 K

I then created a script:
$ cat /etc/acpi/suspend.sh
#!/bin/bash
pm-suspend

and the shell script:
$cat /etc/acpi/events/fnf4-suspend
event=^@button/sleep SBTN 00000080 00000000 K
action=^@/etc/acpi/suspend.sh

This produces no output of any noticeable kind when I subsequently press
the FnF4 button (after of course marking the scripts executable and
rebooting).I also tried sustituting "3D" for the "^@" with no change.

Perhaps I have the form of the command wrong?

Also, funny, when I try bash completion with man pm-<TAB> I only get a
beep... though bash completion generally works for me.

This is weird- under Gnome it worked just fine.... but I don't want to go
back to Gnome. I _can_ now invoke pm-suspend or pm-hibernate manually, but
I sure would like to get into sleep/suspend mode by closing the lid, or at
least by pressing the FnF4 button...

My system:
Lenovo Thinkpad T520
Intel i5-2410 with onboard graphics (i915) only
Intel SSD drive, 4GB RAM
Debian, using i3wm

Thanks for any further help you can provide.
Keith Ostertag

--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Marius Gedminas-4
In reply to this post by keitho-2
On Sat, Feb 04, 2012 at 12:17:33PM -0800, [hidden email] wrote:
> OK, so thanks to Paul I found out that I can use pm-suspend to put my T520
> to sleep from the command line as root. And after doing so I can resume
> from sleep with the Fn-F3 button.
>
> pm-suspend says only root can invoke it. How to make it so I can do it
> with my regular login?

You could use GNOME, you know ;)

Sudo or Fn-F3 (once you set it up) are alternative answers.  As is KDE.

> In addition, it would be much easier if I could invoke it with the Fn-F3
> button. This used to work under Gnome. In fact, since I moved away from
> Gnome the laptop no longer goes into sleep mode when I close the lid.
>
> Can someone teach me how to enable the Fn-F3 button to invoke sleep, and
> how to configure the system so that closing the lid puts the laptop to
> sleep?

Install acpid.  I think the default configuration should make everything
you want work (suspend on Fn-F3 and lid events), but if not, read the
documentation and tweak the files under /etc/acpi/.

Marius Gedminas
--
If it weren't for the last minute, nothing would ever get done.

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: confused about power managment with T520 with Debian with no DE

Claudius Hubig-8
In reply to this post by keitho-2
[hidden email] wrote:
>When I run acpi_listen and press the FnF4 (sleep) button I get:
>$acpi_listen
>^@^@button/sleep SBTN 00000080 00000000 K
>
>I then created a script:
>$ cat /etc/acpi/suspend.sh
>#!/bin/bash
>pm-suspend

You might want the shell script to do ‘something visible’ for
testing, for example create a temporary file or something (just so
you know it was actually called).

>and the shell script:
>$cat /etc/acpi/events/fnf4-suspend
>event=^@button/sleep SBTN 00000080 00000000 K
>action=^@/etc/acpi/suspend.sh

Uhm. Try without the ^@ and maybe also without the "K". My
acpi_listen output is slightly different, though:

0 09:55 0 ares: ~ # acpi_listen
ibm/hotkey HKEY 00000080 00001009

Did you try, for example:

cat /etc/acpi/events/fnf4-suspend
event=button/sleep SBTN 00000080 00000000
action=/etc/acpi/suspend.sh

You do not need to reboot, restarting the acpid (/etc/init.d/acpid
restart) should work just fne.

>Also, funny, when I try bash completion with man pm-<TAB> I only get a
>beep... though bash completion generally works for me.

But pm-utils is installed and also sports the appropriate man pages?

Btw, closing the lid should also trigger an ACPI event which you can
catch, if you like to :)

Best regards,

Claudius
--
BOFH excuse #41:

interrupt configuration error
Please use GPG: ECB0C2C7 4A4C4046 446ADF86 C08112E5 D72CDBA4
http://chubig.net/ http://nightfall.org


--
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad
Reply | Threaded
Open this post in threaded view
|

Re: Re: confused about power managment with T520 with Debian with no DE

Marius Gedminas-4
In reply to this post by keitho-2
On Sun, Feb 05, 2012 at 02:55:23PM -0800, [hidden email] wrote:

> Claudius Hubig gave some examples of capturing the acpi event to invoke a
> shell script. I haven't been able to duplicate this.
>
> When I run acpi_listen and press the FnF4 (sleep) button I get:
> $acpi_listen
> ^@^@button/sleep SBTN 00000080 00000000 K
>
> I then created a script:
> $ cat /etc/acpi/suspend.sh
> #!/bin/bash
> pm-suspend
>
> and the shell script:
> $cat /etc/acpi/events/fnf4-suspend
> event=^@button/sleep SBTN 00000080 00000000 K
> action=^@/etc/acpi/suspend.sh
There are weird NUL characters here?!

On my Ubuntu laptop (this is why I use Ubuntu, BTW: almost everything
works out of the box with no headachey configuration required, usually)
/etc/acpi/events/sleepbtn has

  event=button[ /]sleep
  action=/etc/acpi/sleep.sh

without the "SBNT 0000..." bit at the end.

> This produces no output of any noticeable kind when I subsequently press
> the FnF4 button (after of course marking the scripts executable and
> rebooting).I also tried sustituting "3D" for the "^@" with no change.

Rebooting should not be required.  Maybe an /etc/init.d/acpid restart,
at most.

Drop the ^@ gunk, it's what prevents your acpi config from working.
I've no idea why acpi_listen prints it; this smells like a bug to me.

> Also, funny, when I try bash completion with man pm-<TAB> I only get a
> beep... though bash completion generally works for me.

Is /usr/sbin in your PATH?

Marius Gedminas
--
UEFI stands for "Unified Extensible Firmware Interface", where "Firmware" is an
ancient African word meaning "Why do something right when you can do it so
wrong that children will weep and brave adults will cower before you", and
"UEI" is Celtic for "We missed DOS so we burned it into your ROMs".
        -- Matthew Garrett

signature.asc (205 bytes) Download Attachment