Difference between revisions of "Laptop"

From ArchWiki
Jump to: navigation, search
m (Power saving)
(hibernate on low battery level: rule for batteries which send only critical level signal)
 
(87 intermediate revisions by 32 users not shown)
Line 3: Line 3:
 
[[es:Laptop]]
 
[[es:Laptop]]
 
[[it:Laptop]]
 
[[it:Laptop]]
 +
[[ja:ノートパソコン]]
 
[[ru:Laptop]]
 
[[ru:Laptop]]
[[zh-CN:Laptop]]
+
[[zh-hans:Laptop]]
== Setting up for laptops ==
+
This '''Laptop main page''' contains links to article (sections) needed for configuring a laptop for the best experience. Setting up a laptop is in many ways the same as setting up a desktop. However, there are a few key differences. Arch Linux provides all the tools and programs necessary to take complete control of your laptop. These programs and utilities are highlighted below, with appropriate tips tutorials.
  
This page should contain links to pages needed for configuring a laptop for the best experience. Setting up a laptop is in many ways the same as setting up a desktop. However, there are a few key differences. When setting up a laptop with Arch Linux, the following points should be taken into consideration:
+
To gain an overview of the reported/achieved Linux hardware compatibility of a particular laptop model, see the results per vendor of below subpages.  
 +
{{Laptops navigation}}
 +
If there are laptop model specific instructions, the respective article is crosslinked in the first column of the vendor subpages. In case the model is not listed in the vendor table, existing instructions of similar models via the [[:Category:Laptops]] vendor subcategory may help.
  
* [[#Power management]] Power Management for laptops refers to optimizing the system to last as long as possible on a single battery charge. This can be accomplished by a variety of tweaks.
+
== Power management ==
** [[#Suspend and Hibernate]] : the operating system can be manually suspended either to memory or to disk, allowing for an (almost) complete shutdown of other hardware.
 
** Hard drive spindown : the system can be configured to automatically turn off the hard disk after a specified interval of inactivity.
 
** Screen shut off : the laptop screen can be configured to automatically turn off after a specified interval of inactivity (not just blanked with a screensaver but completely shut off).
 
** CPU frequency scaling : the processor(s) can be configured to automatically step down to a lower frequency at lower loads.
 
 
 
* [[#Screen brightness]]. How do I manage screen brightness?
 
* Network and wireless setup is described in [[Wireless Setup]].
 
* Media buttons can be configured as described in [[Extra Keyboard Keys]].
 
* [[#Touchpad]] sensitivity, acceleration, button function and scroll borders can be configured for some (Synaptics or Alps) touchpads.
 
* [[#Hard disk shock protection]]
 
 
 
All of these points are important to take into consideration when getting a laptop set up the way you like. Fortunately, Arch Linux provides all the tools and programs necessary to take complete control of your laptop. These programs and utilities are highlighted below, with appropriate tips tutorials.
 
  
== Power management ==
+
{{Note|You should read the main article [[Power management]]. Additional laptop-specific features are described below.}}
  
 
Power management is very important for anyone who wishes to make good use of their battery capacity. The following tools and programs help to increase battery life and keep your laptop cool and quiet.
 
Power management is very important for anyone who wishes to make good use of their battery capacity. The following tools and programs help to increase battery life and keep your laptop cool and quiet.
Line 29: Line 20:
 
=== Battery state ===
 
=== Battery state ===
  
Reading battery state can be done in multiple ways. Classical method is some daemon periodically polling battery level using ACPI interface. On some systems, battery sends events to [[udev]] whenever it (dis)charges by 1%, this event can be connected to some action using udev rule.
+
Reading battery state can be done in multiple ways. Classical method is some daemon periodically polling battery level using ACPI interface. On some systems, the battery sends events to [[udev]] whenever it (dis)charges by 1%, this event can be connected to some action using a udev rule.
  
 
==== ACPI ====
 
==== ACPI ====
Line 35: Line 26:
 
Battery state can be read using ACPI utilities from the terminal. ACPI command line utilities are provided via the {{Pkg|acpi}} package. See [[ACPI modules]] for more information.
 
Battery state can be read using ACPI utilities from the terminal. ACPI command line utilities are provided via the {{Pkg|acpi}} package. See [[ACPI modules]] for more information.
  
* {{AUR|batterymon-clone}} is a simple battery monitor that sits in the system tray.
+
* {{Pkg|cbatticon}} is a battery icon that sits in the system tray.
* {{Pkg|batti}} is a simple battery monitor for the system tray, similar to batterymon-clone. Unlike the latter {{ic|batti}} uses UPower, and if that is missing {{ic|DeviceKit.Power}}, for it's power information.
+
* {{AUR|batterymon-clone}} is a battery monitor that sits in the system tray, similar to batti.
 +
* {{AUR|batify}} is an udevrule file triggering plug and battery level notifications (multi-x sessions support).
 +
 
 +
==== hibernate on low battery level ====
 +
 
 +
'''If''' your battery sends events to [[udev]] whenever it (dis)charges by 1%, you can use this udev rule to automatically hibernate the system when battery level is critical, and thus prevent all unsaved work from being lost.
 +
 
 +
{{Note|Not all batteries report discharge events. Test by running {{ic|udevadm monitor --property}} while on battery and see if any events are reported. You should wait at least 1% drop. If no events are reported and {{ic|/sys/class/power_supply/BAT0/alarm}} is non-zero then the battery will likely trigger an event when {{ic|BAT0/energy_now}} drops below the alarm value, and the udev rule will work as long as the percentage math works out}}
  
==== Udev events ====
+
{{Note|This rule will be repeated whenever the condition is set. As such, when resuming from hibernate when the battery is critical, the computer will hibernate directly. Some laptops do not boot beyond a certain battery level, so the rule below could be adjusted accordingly.}}
  
{{Expansion|Describe way to check if the events are sent.}}
+
{{hc|/etc/udev/rules.d/99-lowbat.rules|<nowiki>
 +
# Suspend the system when battery level drops to 5% or lower
 +
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="/usr/bin/systemctl hibernate"
 +
</nowiki>}}
 +
Batteries can jump to a lower value instead of discharging continuously, therefore a udev string matching pattern for all capacities 0 through 5 is used.
  
If your battery sends events to [[udev]] whenever it (dis)charges by 1%, you can use this udev rule to automatically suspend the system when battery level is critical, and thus prevent all unsaved work from being lost.
+
Some batteries only report critical level signal, in such case the following rule will help
  
{{hc|/etc/udev/rules.d/lowbat.rules|<nowiki>
+
{{hc|/etc/udev/rules.d/99-lowbat.rules|<nowiki>
# Suspend the system when battery level drops to 2%
+
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{capacity_level}=="Critical", RUN+="/usr/bin/systemctl hibernate"
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="2", RUN+="/usr/bin/systemctl suspend"
 
 
</nowiki>}}
 
</nowiki>}}
  
Likewise, the rule can be customized to perform other action on different status.
+
Other rules can be added to perform different actions depending on power supply status and/or capacity.
 +
 
 +
If your system has no or missing ACPI events, use [[cron]] with the following script:
 +
 
 +
{{bc|<nowiki>
 +
#!/bin/sh
 +
acpi -b | awk -F'[,:%]' '{print $2, $3}' | {
 +
read -r status capacity
 +
 
 +
if [ "$status" = Discharging -a "$capacity" -lt 5 ]; then
 +
logger "Critical battery threshold"
 +
systemctl hibernate
 +
fi
 +
}</nowiki>
 +
}}
 +
 
 +
===== Testing events =====
 +
 
 +
One way to test udev rules is to have them create a file when they are run. For example:
 +
 
 +
{{hc|/etc/udev/rules.d/98-discharging.rules|<nowiki>
 +
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", RUN+="/usr/bin/touch /home/example/discharging"
 +
</nowiki>}}
 +
 
 +
This creates a file at {{ic|/home/example/discharging}} when the laptop charger is unplugged. You can test whether the rule worked by unplugging your laptop and looking for this file. For more advanced udev rule testing, see [[Udev#Testing rules before loading]].
  
 
=== Suspend and Hibernate ===
 
=== Suspend and Hibernate ===
Line 55: Line 80:
 
Manually suspending the operating system, either to memory (standby) or to disk (hibernate) sometimes provides the most efficient way to optimize battery life, depending on the usage pattern of the laptop.
 
Manually suspending the operating system, either to memory (standby) or to disk (hibernate) sometimes provides the most efficient way to optimize battery life, depending on the usage pattern of the laptop.
  
See the main article [[Suspend and Hibernate]].
+
See the main article [[Suspend and hibernate]].
 +
 
 +
=== Hard drive spin down problem ===
  
=== Power saving ===
+
Documented [https://bugs.launchpad.net/ubuntu/+source/acpi-support/+bug/59695 here].
  
See the main article [[Power saving]].
+
To prevent your laptop hard drive from spinning down too often, set less aggressive power management as described in [[hdparm#Power management configuration]]. Even the default values may be too aggressive.
  
==== Disk-related tweaks ====
+
=== Modify wake events ===
  
You might want to use the {{ic|noatime}} option, see [[Fstab#atime options]] for more information.
+
Events which cause the system to resume from [[w:Advanced_Configuration_and_Power_Interface#Power_states|power states]] can be regulated in {{ic|/proc/acpi/wakeup}}. Writing an entry from the ''Device'' column toggles the status from {{ic|enabled}} to {{ic|disabled}}, or vice-versa.
  
To allow the CD/DVD rom to spin down after a while using [[udisks]]:
+
For example, to disable waking from suspend (S3) on opening the lid, run:
  
  # udisks --inhibit-polling /dev/sr0
+
  # echo LID > /proc/acpi/wakeup
  
==== Hard drive spin down problem ====
+
{{Accuracy|"Permanent toggling" is not the desired behaviour considering that ''systemd-tmpfiles'' can be run repeatedly.}}
  
Documented [https://bugs.launchpad.net/ubuntu/+source/acpi-support/+bug/59695 here]
+
This change can be made permanent with {{man|5|tmpfiles.d}}:
  
To prevent your laptop hard drive from spinning down too often:
+
{{hc|/etc/tmpfiles.d/disable-lid-wakeup.conf|2=w /proc/acpi/wakeup - - - - LID}}
{{hc|/etc/udev/rules.d/75-hdparm.rules|<nowiki>
 
ACTION=="add", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", RUN+="/usr/bin/hdparm -B 254 /dev/$kernel"
 
</nowiki>}}
 
  
See {{ic|hdparm(8)}} for documentation of [[hdparm]] parameters. If you use [[pm-utils]], you might be interested in [[pm-utils#Having the HD power management level automatically set again on resume|these]] examples.
+
== Hardware support ==
  
== Screen brightness ==
+
=== Screen brightness ===
  
 
See [[Backlight]].
 
See [[Backlight]].
  
== Touchpad ==
+
=== Touchpad ===
 +
 
 +
To get your touchpad working properly, see the [[libinput]] page. [[Touchpad Synaptics]] is the older input driver, which is currently in maintenance mode and is no longer updated.
 +
 
 +
=== Fingerprint Reader ===
 +
 
 +
See [[Fingerprint-gui]], [[fprint]] and [[ThinkFinger]] (for ThinkPads).
 +
 
 +
=== Webcam ===
  
To get your touchpad working properly, see the [[Touchpad Synaptics]] page. Note that your laptop may have an ALPS touchpad (such as the DELL Inspiron 6000), and not a Synaptics touchpad. In either case, see the link above.
+
See [[Webcam setup]].
  
== Hard disk shock protection ==
+
=== Hard disk shock protection ===
  
 
There are several laptops from different vendors featuring shock protection capabilities. As manufacturers have refused to support open source development of the required software components so far, Linux support for shock protection varies considerably between different hardware implementations.
 
There are several laptops from different vendors featuring shock protection capabilities. As manufacturers have refused to support open source development of the required software components so far, Linux support for shock protection varies considerably between different hardware implementations.
  
Currently, two projects, named HDAPS and hpfall, support this kind of protection.
+
Currently, two projects, named [[HDAPS]] and [[Hpfall]] (available in the [[AUR]]), support this kind of protection. HDAPS is for IBM/Lenovo Thinkpads and hpfall for HP/Compaq laptops.
HDAPS is for IBM/Lenovo Thinkpads and hpfall for HP/Compaq laptops
+
 
 +
=== Hybrid graphics ===
  
Just Check [[HDAPS|Hard Disk Active Protection System]].
+
The laptop manufacturers developed new technologies involving two graphic cards in an single computer, enabling both high performance and power saving usages. These laptops usually use an Intel chip for display by default, so an [[Intel graphics]] driver is needed first. Then you can [[Hybrid graphics|choose methods]] to utilize the second graphics chip.
{{AUR|hpfall}} can be installed from the [[AUR]].
 
  
 
== Network time syncing ==
 
== Network time syncing ==
  
For a laptop, it may be a good idea to use [[Chrony]] as an alternative to [[NTPd]] to sync your clock over the network. Chrony is designed to work well even on systems with no permanent network connection (such as laptops), and is capable of much faster time synchronisation than standard ntp. Chrony has several advantages when used in systems running on virtual machines, such as a larger range for frequency correction to help correct quickly drifting clocks, and better response to rapid changes in the clock frequency. It also has a smaller memory footprint and no unnecessary process wakeups, improving power efficiency.
+
For a laptop, it may be a good idea to use [[Chrony]] as an alternative to [[NTPd]], [[OpenNTPD]] or [[systemd-timesyncd]] to sync your clock over the network. Chrony is designed to work well even on systems with no permanent network connection (such as laptops), and is capable of much faster time synchronisation than standard ntp. Chrony has several advantages when used in systems running on virtual machines, such as a larger range for frequency correction to help correct quickly drifting clocks, and better response to rapid changes in the clock frequency. It also has a smaller memory footprint and no unnecessary process wakeups, improving power efficiency.
  
 
== See also ==
 
== See also ==
  
 +
; General
 +
* [[CPU frequency scaling]] is a technology used primarily by notebooks which enables the OS to scale the CPU frequency up or down, depending on the current system load and/or power scheme.
 +
* [[Display Power Management Signaling]] describes how to automatically turn off the laptop screen after a specified interval of inactivity (not just blanked with a screensaver but completely shut off).
 +
* [[Wireless network configuration]] provides information about setting up wireless connection.
 +
* [[Extra keyboard keys]] describes configuration of Media keys.
 +
* [[acpid]] which is a flexible and extensible daemon for delivering ACPI events.
 +
 +
; Pages specific to certain laptop types
 +
* See [[:Category:Laptops]] and its subcategories for pages dedicated to specific models/vendors.
 +
* Battery tweaks for ThinkPads can be found in [[TLP]] and the [[tp_smapi]] article.
 +
* [[Acer Aspire One#acerhdf|acerhdf]] is a kernel module for controlling fan speed on Acer Aspire One and some Packard Bell Notebooks.
 +
 +
; External resources
 
* [http://www.linux-on-laptops.com/ http://www.linux-on-laptops.com/]
 
* [http://www.linux-on-laptops.com/ http://www.linux-on-laptops.com/]
 
* [http://www.linlap.com/ http://www.linlap.com/]
 
* [http://www.linlap.com/ http://www.linlap.com/]
* [[CPU Frequency Scaling]] is a technology used primarily by notebooks which enables the OS to scale the CPU frequency up or down, depending on the current system load and/or power scheme.
 
* [[Powertop]] is a handy utility from Intel that displays which hardware/processes are using the most power on your system, and provides instructions on how to stop or remove power-wasting services. Works great for mobile Intel CPUs; provides the current CPU state and suggestions for power saving. Also works on AMD systems, but does not provide as much information about the CPU state.
 
 
The following options are specific to certain laptop types:
 
 
* [[Asus_G1#The_Lapsus_daemon_.26_KDE_applet|Lapsus]] is a set of programs providing easy access to many features of various laptops. It currently supports most features provided by asus-laptop kernel module from ACPI4Asus project, such as additional LEDs, hotkeys, backlight control etc. It also has support for some IBM laptops features provided by IBM ThinkPad ACPI Extras Driver and NVRAM device.
 
* Battery tweaks for ThinkPads can be found in [[TLP]] and the [[tp_smapi]] article.
 

Latest revision as of 13:19, 14 April 2017

This Laptop main page contains links to article (sections) needed for configuring a laptop for the best experience. Setting up a laptop is in many ways the same as setting up a desktop. However, there are a few key differences. Arch Linux provides all the tools and programs necessary to take complete control of your laptop. These programs and utilities are highlighted below, with appropriate tips tutorials.

To gain an overview of the reported/achieved Linux hardware compatibility of a particular laptop model, see the results per vendor of below subpages.

Laptop main page
Acer - Apple - Asus - Compaq (discontinued) - Dell - Fujitsu - HP - IBM/Lenovo - Samsung - Sony - Toshiba - Other

If there are laptop model specific instructions, the respective article is crosslinked in the first column of the vendor subpages. In case the model is not listed in the vendor table, existing instructions of similar models via the Category:Laptops vendor subcategory may help.

Power management

Note: You should read the main article Power management. Additional laptop-specific features are described below.

Power management is very important for anyone who wishes to make good use of their battery capacity. The following tools and programs help to increase battery life and keep your laptop cool and quiet.

Battery state

Reading battery state can be done in multiple ways. Classical method is some daemon periodically polling battery level using ACPI interface. On some systems, the battery sends events to udev whenever it (dis)charges by 1%, this event can be connected to some action using a udev rule.

ACPI

Battery state can be read using ACPI utilities from the terminal. ACPI command line utilities are provided via the acpi package. See ACPI modules for more information.

  • cbatticon is a battery icon that sits in the system tray.
  • batterymon-cloneAUR is a battery monitor that sits in the system tray, similar to batti.
  • batifyAUR is an udevrule file triggering plug and battery level notifications (multi-x sessions support).

hibernate on low battery level

If your battery sends events to udev whenever it (dis)charges by 1%, you can use this udev rule to automatically hibernate the system when battery level is critical, and thus prevent all unsaved work from being lost.

Note: Not all batteries report discharge events. Test by running udevadm monitor --property while on battery and see if any events are reported. You should wait at least 1% drop. If no events are reported and /sys/class/power_supply/BAT0/alarm is non-zero then the battery will likely trigger an event when BAT0/energy_now drops below the alarm value, and the udev rule will work as long as the percentage math works out
Note: This rule will be repeated whenever the condition is set. As such, when resuming from hibernate when the battery is critical, the computer will hibernate directly. Some laptops do not boot beyond a certain battery level, so the rule below could be adjusted accordingly.
/etc/udev/rules.d/99-lowbat.rules
# Suspend the system when battery level drops to 5% or lower
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="/usr/bin/systemctl hibernate"

Batteries can jump to a lower value instead of discharging continuously, therefore a udev string matching pattern for all capacities 0 through 5 is used.

Some batteries only report critical level signal, in such case the following rule will help

/etc/udev/rules.d/99-lowbat.rules
ACTION=="change", SUBSYSTEM=="power_supply", ATTR{capacity_level}=="Critical", RUN+="/usr/bin/systemctl hibernate"

Other rules can be added to perform different actions depending on power supply status and/or capacity.

If your system has no or missing ACPI events, use cron with the following script:

#!/bin/sh
acpi -b | awk -F'[,:%]' '{print $2, $3}' | {
	read -r status capacity

	if [ "$status" = Discharging -a "$capacity" -lt 5 ]; then
		logger "Critical battery threshold"
		systemctl hibernate
	fi
}
Testing events

One way to test udev rules is to have them create a file when they are run. For example:

/etc/udev/rules.d/98-discharging.rules
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", RUN+="/usr/bin/touch /home/example/discharging"

This creates a file at /home/example/discharging when the laptop charger is unplugged. You can test whether the rule worked by unplugging your laptop and looking for this file. For more advanced udev rule testing, see Udev#Testing rules before loading.

Suspend and Hibernate

Manually suspending the operating system, either to memory (standby) or to disk (hibernate) sometimes provides the most efficient way to optimize battery life, depending on the usage pattern of the laptop.

See the main article Suspend and hibernate.

Hard drive spin down problem

Documented here.

To prevent your laptop hard drive from spinning down too often, set less aggressive power management as described in hdparm#Power management configuration. Even the default values may be too aggressive.

Modify wake events

Events which cause the system to resume from power states can be regulated in /proc/acpi/wakeup. Writing an entry from the Device column toggles the status from enabled to disabled, or vice-versa.

For example, to disable waking from suspend (S3) on opening the lid, run:

# echo LID > /proc/acpi/wakeup

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: "Permanent toggling" is not the desired behaviour considering that systemd-tmpfiles can be run repeatedly. (Discuss in Talk:Laptop#)

This change can be made permanent with tmpfiles.d(5):

/etc/tmpfiles.d/disable-lid-wakeup.conf
w /proc/acpi/wakeup - - - - LID

Hardware support

Screen brightness

See Backlight.

Touchpad

To get your touchpad working properly, see the libinput page. Touchpad Synaptics is the older input driver, which is currently in maintenance mode and is no longer updated.

Fingerprint Reader

See Fingerprint-gui, fprint and ThinkFinger (for ThinkPads).

Webcam

See Webcam setup.

Hard disk shock protection

There are several laptops from different vendors featuring shock protection capabilities. As manufacturers have refused to support open source development of the required software components so far, Linux support for shock protection varies considerably between different hardware implementations.

Currently, two projects, named HDAPS and Hpfall (available in the AUR), support this kind of protection. HDAPS is for IBM/Lenovo Thinkpads and hpfall for HP/Compaq laptops.

Hybrid graphics

The laptop manufacturers developed new technologies involving two graphic cards in an single computer, enabling both high performance and power saving usages. These laptops usually use an Intel chip for display by default, so an Intel graphics driver is needed first. Then you can choose methods to utilize the second graphics chip.

Network time syncing

For a laptop, it may be a good idea to use Chrony as an alternative to NTPd, OpenNTPD or systemd-timesyncd to sync your clock over the network. Chrony is designed to work well even on systems with no permanent network connection (such as laptops), and is capable of much faster time synchronisation than standard ntp. Chrony has several advantages when used in systems running on virtual machines, such as a larger range for frequency correction to help correct quickly drifting clocks, and better response to rapid changes in the clock frequency. It also has a smaller memory footprint and no unnecessary process wakeups, improving power efficiency.

See also

General
  • CPU frequency scaling is a technology used primarily by notebooks which enables the OS to scale the CPU frequency up or down, depending on the current system load and/or power scheme.
  • Display Power Management Signaling describes how to automatically turn off the laptop screen after a specified interval of inactivity (not just blanked with a screensaver but completely shut off).
  • Wireless network configuration provides information about setting up wireless connection.
  • Extra keyboard keys describes configuration of Media keys.
  • acpid which is a flexible and extensible daemon for delivering ACPI events.
Pages specific to certain laptop types
  • See Category:Laptops and its subcategories for pages dedicated to specific models/vendors.
  • Battery tweaks for ThinkPads can be found in TLP and the tp_smapi article.
  • acerhdf is a kernel module for controlling fan speed on Acer Aspire One and some Packard Bell Notebooks.
External resources