Ubuntu: Questions and Answers (2014)
Power Management
Questions
Q: How can I tell Ubuntu to do nothing when I close my laptop lid?
Tags: power-management (Next Q)
I would like closing the laptop lid to be a no-op. How can I do that?
Tags: power-management (Next Q)
User: badp
Answer by tasos-koutoumanos
For 13.10 or newer:
To make Ubuntu do nothing when laptop lid is closed:
1. Open the /etc/systemd/logind.conf file in a text editor as root, for example,
2. sudo -H gedit /etc/systemd/logind.conf
2. Add a line HandleLidSwitch=ignore (make sure it's not commented out!),
3. Restart the systemd daemon with this command:
4. sudo restart systemd-logind
See also: Ubuntu Server 13.10 now goes to sleep when closing laptop lid
Answer by sid
For 11.04 and earlier:
Do nothing when laptop lid is closed (helpful when an external monitor is connected):
· Alt + F2 and enter this: gconf-editor
· apps > gnome-power-manager > buttons
· Set lid_ac and lid_battery to nothing
OR
1.When on AC Power, do nothing when laptop lid is closed:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_ac nothing
2.When on Battery Power, do nothing when laptop lid is closed:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_battery nothing
Blank screen when laptop lid is closed (preferable when no external monitor is connected):
· System > Preferences > Power Management
· On AC Power (On Battery Power) > Actions
· When laptop lid is closed: Blank screen
OR
1.When on AC Power, blank screen when laptop lid is closed:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_ac blank
2.When on Battery Power, blank screen when laptop lid is closed:
gconftool-2 -t string -s /apps/gnome-power-manager/buttons/lid_battery blank
Answer by jorge-castro
For 11.10 and newer:
You can select "Do Nothing" in the power settings. Open the dash (super key), search for "power" and then select the correct option in the dropdown. Note that closing the lid will actually turn off the screen though plus any external monitors:
If you move the mouse then any connected monitors will power back up with the laptop closed. This will then become the primary monitor.
Tags: power-management (Next Q)
Q: How to control fan speed?
Tags: power-management (Next Q)
How can I control fan speed? On windows there is wonderful program called speedfan.
Tags: power-management (Next Q)
User: grizzly
Answer by grizzly
Note before starting:
This functionality depends on both your hardware and software. If your hardware doesn't support fan speed controls, or doesn't show them to the OS, it is very likely that you could not use this solution. If it does, but the software (aka kernel) doesn't know how to control it, you are without luck.
1. Install the lm-sensors and fancontrol packages.
2. Configure lm-sensors
1. In terminal type sudo sensors-detect and answer YES to all YES/no questions.
2. At the end of sensors-detect, a list of modules that need to be loaded will be displayed. Type "yes" to have sensors-detect insert those modules into /etc/modules, or edit /etc/modules yourself.
3. Run sudo service module-init-tools restart. This will read the changes you made to /etc/modules in step 3, and insert the new modules into the kernel.
§ Note: If you're running Ubuntu 13.04 or higher, this 3rd step command should be replaced by sudo service kmod start.
3. Configure fancontrol
1. In terminal type sudo pwmconfig . This script will stop each fan for 5 seconds to find out which fans can be controlled by which PWM handle. After script loops through all fans, you can configure which fan corresponds to which temperature.
2. In my case I set interval to 2 seconds.
4. Set up fancontrol service
1. Run sudo service fancontrol start. This will also make the fancontrol service run automatically at system startup.
In my case for CPU I used:
Settings for hwmon0/device/pwm2:
Depends on hwmon0/device/temp2_input
Controls hwmon0/device/fan2_input
MINTEMP=40
MAXTEMP=60
MINSTART=150
MINSTOP=0
MINPWM=0
MAXPWM=255
Tags: power-management (Next Q)
Q: How do I modify the options for the power button?
Tags: power-management (Next Q)
When I press the power button a dialog opens, but I want to shutdown the system without receiving "Do you really really want to shutdown?". How can I choose a direct shutdown action on a pressed power button?
I had the same problem with the 11.04 version, but I don't remember the solution and yesterday I upgraded to Ubuntu 11.10.
Tags: power-management (Next Q)
User: nan
Answer by bruno-pereira
Lid Close Action
To set up the Laptop Lid Close Action you have to install Advanced Setting (or the Gnome Tweak Tool). It is in the USC (Ubuntu Software Center) under either tweak or Advanced Settings. If installed press the super button and type in tweak or advanced and choose the Advanced Settings. When it opens choose the shell tab;
Press the arrows and choose you desired on both on AC and on battery;
Default buttons behavior
Install dconf-tools:
sudo apt-get install dconf-tools
Press alt+f2 and open dconf-editor (or in a terminal type dconf-editor)
Navigate to org.gnome.settings-daemon.plugins.power and set your default button-power action there:
On some systems you will also need to mark the item suppress-logout-restart-shutdown.
Answer by david-lópez
I'm afraid that the first answers didn't work for me, I think that the 'graphical solutions' only work for the upper right indicator, not for the power button. rulet solution works for me, I think I can improve it and make the prompt completely disappear. Instead of creating a new file you can use existing /etc/acpi/events/powerbtn file
1.- sudo gedit /etc/acpi/events/powerbtn
2.- Add # to comment line: #action=/etc/acpi/powerbtn.sh
3.- Add a new line: action=/sbin/poweroff
4.- Save file
5.- Open a console and type: sudo acpid restart
That works for me AND the prompt has gone, just like in ubuntu 11.04. Wish this helps.
Answer by phord
This is the quick, simple answer I needed:
gsettings set org.gnome.settings-daemon.plugins.power button-power 'hibernate'
If you want to see your settings first, try this:
gsettings list-recursively org.gnome.settings-daemon.plugins.power
Tags: power-management (Next Q)
Q: How to enable hibernation?
Tags: power-management (Next Q)
In Ubuntu 12.04 and newer, hibernation has been disabled by default in policykit. How can I enable this back?
Tags: power-management (Next Q)
User: dima
Answer by dima
If this answer does not work in Ubuntu 13.10, see here for an alternative answer
You can follow official documentation here. Hibernation was disabled on 12.04 for machines that are not certified with Ubuntu.
In order to enable hibernation you need to test whether it works correctly by running sudo pm-hibernate in a terminal. The system will try to hibernate. If you are able to start the system again then you are more or less safe to add an override.
To do so, start editing:
sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Fill it with this:
[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
Save by pressing Ctrl-O then enter and then exit nano by pressing Ctrl-X.
Restart and hibernation is back!
Or run killall unity-panel-service to just reset the menu.
Some users will then need to run sudo update-grub to get the hibernate option to be available in the power menu. Some users may also have to at least log out then log in to get it to appear in the (upper right) power menu.
Answer by nacs
Additionally, for those who want to disable the suspend button (for various reasons), proceed analogously...
Choose any file name, but this is one is verbose/convention:
sudoedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.disable-suspend.pkla
Fill it with this:
[Disable suspend by default]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultActive=no
Ctrl+O, Enter, Ctrl+X
No need to restart, it should be gone as soon as you go into the shutdown menu.
Answer by mreq
One more thing:
When you want to add the hibernation option to XFCE's panel, you have to right-click your name (topright) and select properties.
After that a screen pops up:
Make sure, you check Hibernate like I did.
Tags: power-management (Next Q)
Q: How to prevent my screen from either dimming or the screen-lock starting when watching YouTube?
Tags: power-management
My screen brightness used to dim after a few seconds to preserve battery. This is default in Ubuntu 12.04. However when watching video it should not dim.
This works correctly when I watch videos using native applications like VLC. With in-browser video, however, the screen is not prevented from dimming. This is very annoying as you have to move your cursor every 10 seconds or so.
I used to use Mac OSX where I had the same dimming settings and Flash videos were taken into account correctly.
Anyone an idea how you can make YouTube prevent your screen from dimming?
Tags: power-management
User: steven-roose
Answer by njallam
HOWTO: Disable screen saver while Flash is running
Run the following command in terminal:
mkdir -p ~/bin
Open gedit, or your preferred text editor and type this:
Skip code block
#!/bin/bash
# Cleanup any bad state we left behind if the user exited while flash was
# running
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true
we_turned_it_off=0
while true; do
sleep 60
flash_on=0
for pid in `pgrep firefox` ; do
if grep libflashplayer /proc/$pid/maps > /dev/null ; then
flash_on=1
fi
ss_on=`gconftool-2 -g /apps/gnome-screensaver/idle_activation_enabled`
if [ "$flash_on" = "1" ] && [ "$ss_on" = "true" ]; then
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled \
--type bool false
we_turned_it_off=1
elif [ "$flash_on" = "0" ] && [ "$ss_on" = "false" ] \
&& [ "$we_turned_it_off" = "1" ]; then
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled \
--type bool true
we_turned_it_off=0
fi
done
done
Save this file as "~/bin/flash_saver.sh"
Go back into terminal and run:
chmod +x ~/bin/flash_saver.sh
To run this, go into terminal and type:
~/bin/flash_saver.sh
If you prefer, you can set this script to run at logon by doing the following:
1. Run the program "Startup Applications"
2. Click "Add"
3. Under name type "FlashMonitor" or something you will recognise
4. Under command type "~/bin/flash_saver.sh"
5. Under comment (if you want) type a brief description. E.g. "Stops screen turning off when Flash is running"
Source: HOWTO: Disable screen saver while Flash is running - ubuntuforums
Answer by salem
EDIT
This probably will not work if you are using an Ubuntu version newer than 12.04 (have tried in 13.04 and 13.10 and it just does not work at all). It seems the main developer is not working anymore in this project, so the chances of it being fixed are not good.
In my system (Ubuntu 11.10) i use Caffeine. You can try if it works in Xubuntu too. It adds a notification area icon where you can enable/disable screensaver for some programs. To install Caffeine, do the following:
sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeine
Then execute in a terminal:
caffeine -p &
You can then choose the programs that should disable the screensaver:
vlc for VLC, mplayer for Movie Player, etc.
Hope it helps.
Tags: power-management
Q: How can I tell Ubuntu to do nothing when I close my laptop lid?
Q: How to control fan speed?
Q: How do I modify the options for the power button?
Q: How to enable hibernation?
Q: How to prevent my screen from either dimming or the screen-lock starting when watching YouTube?
Q: Is there a power saving application similar to Jupiter?