PowerManagementConfiguration

Differences between revisions 1 and 40 (spanning 39 versions)
Revision 1 as of 2005-04-23 01:36:42
Size: 908
Editor: CPE-60-225-13-161
Comment: create
Revision 40 as of 2006-02-22 15:02:51
Size: 8857
Editor: host86-132-108-63
Comment: Hal now runs drops root privs and still does power management.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Power Management Configuration =  * '''Launchpad entry:''' https://launchpad.net/distros/ubuntu/+spec/power-management-configuration
 * '''Created:''' [[Date(2005-04-23T01:36:42Z)]] by MattZimmerman
 * '''Contributors:''' MatthewGarrett, OliverGrawert, MatthewPaulThomas, ThomMay, ReinhardTartler, RyanLortie, CoreyBurger, MatthiasUrlichs, MartijnVanDeStreek, DanielHolbach
 * '''Drafter:''' DanielHolbach
 * '''Assignee:''' RyanLortie
 * '''Packages:''' `gnome-power`, `gnome-session`, `gnome-applets`
Line 3: Line 8:
== Status == == Summary ==
Line 5: Line 10:
  * Created: [[Date(2005-04-23T01:36:42Z)]] by MattZimmerman[[BR]]
  * Priority: MediumPriority[[BR]]
  * People: NeedsLead, NeedsSecond[[BR]]
  * Contributors: [[BR]]
  * Interested: [[BR]]
  * Status: BrainDump, BreezyGoal, UduBof, DistroSpecification[[BR]]
  * Packages: [[BR]]
  * Depends: [[BR]]

== Introduction ==

A user interface is needed for configuring power management preferences.
To maintain simplicity, Ubuntu's power management interface allows configuration only of those options that people are likely to want to change (with other options having sane defaults, not configurable graphically), and presents only batteries for for the computer itself.
Line 20: Line 14:
== Scope and Use Cases == There should be simple, reliable, and understandable methods of:
 * shutting down the computer
 * putting the computer into a low-power-use state
 * going into a low-power-use state after some period of inactivity
 * blanking the screen, instead of using a power-sapping screensaver, when running on battery power
 * preventing data loss when the battery runs out.
Line 22: Line 21:
 * Enable suspend to RAM
 * Have system suspend to RAM when lid is closed
 * Select whether screen should be locked when lid is closed
 * Configure advanced/debugging options for ACPI infrastructure(?) (POST_VIDEO, USE_DPMS)
Currently people need to edit text files in /etc to enable suspend to RAM, and to select which services will be restarted. Also, it's currently impossible to configure how the system should behave in various situations, such as on lid close. All of these points should be configurable graphically.
Line 27: Line 23:
== Implementation Plan == == Use cases ==
Line 29: Line 25:
=== Data Preservation and Migration ===  * Michael is a harried Hong Kong businessman who has just installed Ubuntu 6.04 on his home desktop machine. He doesn't care about power management; he wants it to just work and do the right thing.
Line 31: Line 27:
=== Packages Affected ===  * Mei-Li is flying back to her home in London after a successful business trip to Hong Kong (during which she persuaded Michael to install Ubuntu). At the start of the flight, she sees she has 3 hours 20 minutes of battery left on her Think``Pad, possibly enough to finish a presentation she has to give tomorrow. As it turns out, she doesn't quite finish it; Ubuntu automatically puts the machine into hibernation when the battery reaches a critically low level. Nineteen hours later, Mei-Li arrives back at her apartment, plugs in her Think``Pad, opens it up and resumes work from where she left off.
Line 33: Line 29:
=== User Interface Requirements ===  * Candice runs a university computer lab containing 60 iMacs -- a significant use of electricity for a university on a tight budget (they upgraded from Mac OS 9 to Ubuntu partly because it was cheaper than OS X). To save power, Candice wants each computer to go to sleep if idle for half an hour, even when nobody is logged in, and she does not want students to be able to alter the power management settings.
Line 35: Line 31:
== Outstanding Issues ==  * Bob runs the IT department at Hydroponical Light Industries. He gives his salespeople laptops with Ubuntu preinstalled, but since they're salespeople and not tech wizards, Bob locks down the power settings so they can't be messed with.

 * Courtney shares her Presario with her evil twin sister, Tara. Tara likes playing practical jokes, and tries to set up a cron job to spontaneously shut down or suspend the system if Courtney is logged in. This is unsuccessful.

== Design ==

=== Panel menu ===

attachment:power-menu.jpg

There is a power menu on the the panel (either applet or notification icon), which shows the charge only of the primary battery (we make no attempt to deal with wireless mouse batteries, for example), or a power adapter icon if the battery is fully charged. The first three items in the menu configure how the menu title itself appears, with the first two of these sneakily doubling as more explicit status indicators for the battery:
 * "Time (''x''h ''y''m remaining)", or "Time (''x''h ''y''m to charge)", or if fully charged, just "Time"
 * "Percentage (''z'' %)"

The final item in the menu opens the Power Management preferences.

(RyanLortie is currently working on this patch for `battstat-applet`.)

=== Shutdown confirmation alert ===

Pressing the power button on the computer puts up the shutdown alert immediately. '''''Implementation note:''' gnome logout dialog does it slow but gnome-screensaver can do it quickly. find out why.''

attachment:shutdown.jpg

All buttons in the alert can be activated with a single keypress (no need to hold down Alt):
 * Enter for "Shut Down"
 * Escape for "Cancel"
 * S for "Sleep"
 * R for "Restart".

=== Power Management preferences ===

attachment:power-applet.jpg

The "When:" menu contains items "Using Battery" and "Plugged In". If no battery is detected, the menu is unavailable, but the text "Plugged In" still appears active. '''''Implementation note:''' If this is not possible, "Plugged In" should be presented as plain text instead of a menu.'' '''''Translator note:''' The text inside and outside the menu can be distributed differently as appropriate for other languages. For analogy, varieties of English outside North America would understand a "When running on:" menu containing items "Battery" and "Mains Power".''

'''''Translator note:''' Translate the word "idle" to encompass, as much as practical, the meanings of not receiving input, and not displaying a movie or unattended presentation.''

If suspend is unsupported, the "Put the computer to sleep when it is idle:" slider is hidden. The "When the lid is closed:" radiobuttons are still visible, though the "Put the computer to sleep" radiobutton is unavailable, so that people do not lose data by mistakenly thinking that their laptop ever goes to sleep.

As the "Put the computer to sleep when it is idle:" slider is moved, the "Put the display to sleep when the computer is idle:" slider tick marks are updated to reflect the possible values (it does not make sense to put the display to sleep when the entire computer is already asleep).

The "Require password when waking from sleep" checkbox is off by default if Ubuntu is set up to log in to an account automatically, and on by default otherwise. It is independent of the operation of the screensaver.

The "When the lid is closed:" section appears only if the computer is a laptop. The selection defaults to "Put the computer to sleep" if the laptop is known to be safe for suspending, and to "Just turn off the display" otherwise.

The "Non-admin accounts use:" section appears only if the current account is that of a sudoer. The "Copy These Settings" button copies the current settings for use by all non-admin accounts. The button is unavailable if the current settings are already those used by all non-admin accounts.

== Implementation ==

For Ubuntu, gnome-power-manager will be used. With a small amount of work, this should be suitable for Xubuntu - KDE already has a runtime configuration system.

A small amount of work is required for this to be possible:
 * Investigation into providing policy when no user is logged in, and changing to system policy when the user logs in/out (RichardHughes is working on this upstream)

=== Further details ===

dbus has had the at_console policy patched to check that the user is at the foreground console. This requires libpam-foreground to be part of the default pam session.

That way only the 'active' user can do power management stuff. It doesn't address the issue of preventing certain users from messing with power settings but it's ok (the best you could do is prevent any power management stuff from occuring when a certain user is logged in).

attachment:diagram.png

== Future work ==

 * Find a less bad way of expressing the relationship between computer sleep and display sleep.
 * Find a less confusing way of allowing lockdown of non-admin accounts.
 * Allow configuration of UPS devices.
RichardHughes: g-p-m already detects UPS's using HAL. At the moment only APC UPS's are supported, but it's pretty trivial to convert a NUT plugin to a HAL addon for other makes. g-p-m treats them like external batteries, doing the usual (hibernate/shutdown etc) when they get critical, with warnings when they get low. What else would you want to configure, other than the time before shutting down?

== Outstanding issues ==

 * How do we cater for the part of Candice's use case where she wants to configure what happens while nobody is logged in?
RichardHughes: I was proposing using the root user preferences, i.e. safe defaults.

== Proposes ==

 * NicolòChieffo: a way to switch between different power configurations (for laptops) should be a good feature too. Last month I made a simple script using zenity, to support this (it's called power4gear because my laptop has a hotkey called power4gear). to let you know what I'm talking about I'll give you the [http://bugzilla.ubuntu.com/show_bug.cgi?id=17652 link] (there is also a screenshot in the .tar.gz). Let me know
----
CategorySpec

Summary

To maintain simplicity, Ubuntu's power management interface allows configuration only of those options that people are likely to want to change (with other options having sane defaults, not configurable graphically), and presents only batteries for for the computer itself.

Rationale

There should be simple, reliable, and understandable methods of:

  • shutting down the computer
  • putting the computer into a low-power-use state
  • going into a low-power-use state after some period of inactivity
  • blanking the screen, instead of using a power-sapping screensaver, when running on battery power
  • preventing data loss when the battery runs out.

Currently people need to edit text files in /etc to enable suspend to RAM, and to select which services will be restarted. Also, it's currently impossible to configure how the system should behave in various situations, such as on lid close. All of these points should be configurable graphically.

Use cases

  • Michael is a harried Hong Kong businessman who has just installed Ubuntu 6.04 on his home desktop machine. He doesn't care about power management; he wants it to just work and do the right thing.
  • Mei-Li is flying back to her home in London after a successful business trip to Hong Kong (during which she persuaded Michael to install Ubuntu). At the start of the flight, she sees she has 3 hours 20 minutes of battery left on her ThinkPad, possibly enough to finish a presentation she has to give tomorrow. As it turns out, she doesn't quite finish it; Ubuntu automatically puts the machine into hibernation when the battery reaches a critically low level. Nineteen hours later, Mei-Li arrives back at her apartment, plugs in her ThinkPad, opens it up and resumes work from where she left off.

  • Candice runs a university computer lab containing 60 iMacs -- a significant use of electricity for a university on a tight budget (they upgraded from Mac OS 9 to Ubuntu partly because it was cheaper than OS X). To save power, Candice wants each computer to go to sleep if idle for half an hour, even when nobody is logged in, and she does not want students to be able to alter the power management settings.
  • Bob runs the IT department at Hydroponical Light Industries. He gives his salespeople laptops with Ubuntu preinstalled, but since they're salespeople and not tech wizards, Bob locks down the power settings so they can't be messed with.
  • Courtney shares her Presario with her evil twin sister, Tara. Tara likes playing practical jokes, and tries to set up a cron job to spontaneously shut down or suspend the system if Courtney is logged in. This is unsuccessful.

Design

Panel menu

attachment:power-menu.jpg

There is a power menu on the the panel (either applet or notification icon), which shows the charge only of the primary battery (we make no attempt to deal with wireless mouse batteries, for example), or a power adapter icon if the battery is fully charged. The first three items in the menu configure how the menu title itself appears, with the first two of these sneakily doubling as more explicit status indicators for the battery:

  • "Time (xh ym remaining)", or "Time (xh ym to charge)", or if fully charged, just "Time"

  • "Percentage (z %)"

The final item in the menu opens the Power Management preferences.

(RyanLortie is currently working on this patch for battstat-applet.)

Shutdown confirmation alert

Pressing the power button on the computer puts up the shutdown alert immediately. Implementation note: gnome logout dialog does it slow but gnome-screensaver can do it quickly. find out why.

attachment:shutdown.jpg

All buttons in the alert can be activated with a single keypress (no need to hold down Alt):

  • Enter for "Shut Down"
  • Escape for "Cancel"
  • S for "Sleep"
  • R for "Restart".

Power Management preferences

attachment:power-applet.jpg

The "When:" menu contains items "Using Battery" and "Plugged In". If no battery is detected, the menu is unavailable, but the text "Plugged In" still appears active. Implementation note: If this is not possible, "Plugged In" should be presented as plain text instead of a menu. Translator note: The text inside and outside the menu can be distributed differently as appropriate for other languages. For analogy, varieties of English outside North America would understand a "When running on:" menu containing items "Battery" and "Mains Power".

Translator note: Translate the word "idle" to encompass, as much as practical, the meanings of not receiving input, and not displaying a movie or unattended presentation.

If suspend is unsupported, the "Put the computer to sleep when it is idle:" slider is hidden. The "When the lid is closed:" radiobuttons are still visible, though the "Put the computer to sleep" radiobutton is unavailable, so that people do not lose data by mistakenly thinking that their laptop ever goes to sleep.

As the "Put the computer to sleep when it is idle:" slider is moved, the "Put the display to sleep when the computer is idle:" slider tick marks are updated to reflect the possible values (it does not make sense to put the display to sleep when the entire computer is already asleep).

The "Require password when waking from sleep" checkbox is off by default if Ubuntu is set up to log in to an account automatically, and on by default otherwise. It is independent of the operation of the screensaver.

The "When the lid is closed:" section appears only if the computer is a laptop. The selection defaults to "Put the computer to sleep" if the laptop is known to be safe for suspending, and to "Just turn off the display" otherwise.

The "Non-admin accounts use:" section appears only if the current account is that of a sudoer. The "Copy These Settings" button copies the current settings for use by all non-admin accounts. The button is unavailable if the current settings are already those used by all non-admin accounts.

Implementation

For Ubuntu, gnome-power-manager will be used. With a small amount of work, this should be suitable for Xubuntu - KDE already has a runtime configuration system.

A small amount of work is required for this to be possible:

  • Investigation into providing policy when no user is logged in, and changing to system policy when the user logs in/out (RichardHughes is working on this upstream)

Further details

dbus has had the at_console policy patched to check that the user is at the foreground console. This requires libpam-foreground to be part of the default pam session.

That way only the 'active' user can do power management stuff. It doesn't address the issue of preventing certain users from messing with power settings but it's ok (the best you could do is prevent any power management stuff from occuring when a certain user is logged in).

attachment:diagram.png

Future work

  • Find a less bad way of expressing the relationship between computer sleep and display sleep.
  • Find a less confusing way of allowing lockdown of non-admin accounts.
  • Allow configuration of UPS devices.

RichardHughes: g-p-m already detects UPS's using HAL. At the moment only APC UPS's are supported, but it's pretty trivial to convert a NUT plugin to a HAL addon for other makes. g-p-m treats them like external batteries, doing the usual (hibernate/shutdown etc) when they get critical, with warnings when they get low. What else would you want to configure, other than the time before shutting down?

Outstanding issues

  • How do we cater for the part of Candice's use case where she wants to configure what happens while nobody is logged in?

RichardHughes: I was proposing using the root user preferences, i.e. safe defaults.

Proposes

  • NicolòChieffo: a way to switch between different power configurations (for laptops) should be a good feature too. Last month I made a simple script using zenity, to support this (it's called power4gear because my laptop has a hotkey called power4gear). to let you know what I'm talking about I'll give you the [http://bugzilla.ubuntu.com/show_bug.cgi?id=17652 link] (there is also a screenshot in the .tar.gz). Let me know


CategorySpec

PowerManagementConfiguration (last edited 2008-08-06 16:31:02 by localhost)