This document addresses programmers and packagers and is intended to support packaging of TLP for Linux distributions.
If you just want to install and use TLP, please continue reading here.
TLP's source code is available on GitHub. The repository holds the following branches:
Obtain the current development version with
Checkout a release version with
Download release tarballs here.
The current changelog for the development version is here.
1. Install the package
2. Checkout the master branch (see above).
3. Populate debian/ with
4. Edit debian/changelog to your needs (optional).
5. Build binary packages with
TLP consists – aside from manpages and docs – solely of POSIX compatible shell scripts (i.e. without bash extensions) and perl scripts.
TLP is installed as two packages:
File | Package | Target directory or file | Purpose |
---|---|---|---|
49tlp | tlp | /usr/share/pm-utils/sleep.d/ | Script invoked by pm-utils upon suspend and resume, calls tlp resume/suspend. Replaces 49bay and 49wwan. |
de.linrunner.tlp.metainfo.xml | tlp | /usr/share/metainfo | AppStream metadata |
default | tlp | /etc/default/tlp | TLP settings file for both tlp and tlp-rdw |
thinkpad-radiosw | tlp | /etc/acpi/events/ | [until 0.8] Catch ThinkPad wireless radio switch (the slide switch, not the Fn+F5 key!) event. Prerequisite: kernel with CONFIG_ACPI_PROC_EVENT=y |
thinkpad-radiosw.sh | tlp | /etc/acpi/ | [until 0.8] Script to handle ThinkPad wireless radio switch event |
tlp | tlp | /usr/sbin/ | TLP main program |
tlp.bash_completion | tlp | /usr/share/bash-completion/completions/tlp | bash completion rules |
tlp-functions | tlp | /usr/share/tlp-pm/ | TLP main function library |
tlp.init | tlp | /etc/init.d/tlp | SysV init script to be invoked upon system start/shutdown: calls tlp init start/stop to apply power save settings, switch radio devices and set the battery thresholds. |
tlp-nop | tlp | /usr/share/tlp-pm/ | Dummy script – delivers rc=0. |
tlp-pcilist | tlp | /usr/bin/ | Report runtime pm settings for PCIe devices; called by tlp-stat Note: install to /usr/sbin/ if lspci is in /usr/sbin/ |
tlp-rf | tlp | /usr/bin/bluetooth, wifi, wwan |
Script to turn radio devices on and off (soft links to the same file) |
tlp-rf-func | tlp | /usr/share/tlp-pm/ | Function library for the radio devices |
tlp.rules | tlp | /lib/udev/rules.d/85-tlp.rules | Added usb devices: call tlp-usb-udev |
tlp-run-on | tlp | /usr/bin/run-on-bat, run-on-ac |
Start commands conditionally depending on the power source (soft links to the same file) |
tlp.service | tlp | /lib/systemd/system/ | Service to be invoked upon system start/shutdown by systemd: calls tlp init start/stop to apply power save settings, switch radio devices and set the battery thresholds. |
tlp-sleep.service | tlp | /lib/systemd/system/ | Service to be invoked by systemd upon suspend and resume: calls tlp resume/suspend to apply settings. |
tlp-stat | tlp | /usr/bin/ | Status report with all effective settings |
tlp-usb-udev | tlp | /lib/udev/ | Handle added usb devices: enable usb autosuspend |
tlp-usblist | tlp | /usr/bin/ | Report usb settings; called by tlp-stat |
tlp.upstart | tlp | n/a | Upstart script (currently not used) |
tpacpi-bat | tlp | /usr/sbin/ | ACPI calls for advanced battery functions of Sandy Bridge and newer ThinkPad models (X220, T420, et al.). Script written by Elliot Wolk. |
man/* | tlp | distribution dependent | Manpages – installation and target directory are distribution specific and therefore not included in the Makefile. |
tlp-rdw.rules | tlp-rdw | /lib/udev/rules.d/85-tlp-rdw.rules | Dock/undock events: call tlp-rdw-udev |
tlp-rdw-udev | tlp-rdw | /lib/udev/ | Handle dock/undock events |
tlp-rdw-nm | tlp-rdw | /etc/NetworkManager/dispatcher.d/ | Network manager hook for ifup/ifdown events |
Makefile | n/a | n/a | Installation of scripts and config file to their respective target dirs; see section Makefile below |
changelog | tlp | distribution dependent | Changelog for TLP – the target directory is distribution specific and therefore it is not installed by the Makefile. |
README | tlp | distribution dependent | README file for TLP – the target directory is distribution specific and therefore it is not installed by the Makefile. |
AUTHORS | n/a | distribution dependent | List of developers / contributors |
COPYING | n/a | distribution dependent | Copyright information: – the target directory is distribution specific and therefore it is not installed by the Makefile – Installation of this file (or inclusion in a distribution specific template) is mandatory |
LICENSE | n/a | distribution dependent | GPL v2 license text |
Table 1: Contents of the source archive
Target | Purpose |
---|---|
install-tlp | Install files for package tlp |
install-rdw | Install files for package tlp-rdw |
install | Install files for tlp and tlp-rdw |
install-man | Install manpages |
uninstall-tlp | Uninstall files for package tlp |
uninstall-rdw | Uninstall files for package tlp-rdw |
uninstall | Uninstall files for tlp and tlp-rdw |
uninstall-man | Uninstall manpages |
checkbashisms | Check all shell scripts |
Table 2: Makefile targets
The Makefile accepts the parameters below. Default values apply when a parameter is not given.
Parameter | Default value | Values / Purpose |
---|---|---|
DESTDIR | (empty) | Prefix for all install directories |
TLP_BIN | /usr/bin | Install directory |
TLP_SBIN | /usr/sbin | Install directory |
TLP_TLIB | [until 0.9] /usr/share/tlp-pm [from 1.0] /usr/share/tlp | Install directory for TLP's function libs |
TLP_ULIB | /lib/udev | Install directory for udev scripts |
TLP_CONF | /etc/default/tlp | Install directory for TLP's configuration |
TLP_RUN | /run/tlp | [from 1.1] Directory for runtime data (volatile) |
TLP_MAN | /usr/share/man | [from 0.9] Install directory for manpages |
TLP_META | /usr/share/metainfo | [from 1.1] Install directory for AppStream metadata |
TLP_ACPI | /etc/acpi | [until 0.8] Install directory for ACPI scripts |
TLP_NMDSP | /etc/NetworkManager/dispatcher.d | Install directory for NM scripts |
TLP_SHCPL | /usr/share/bash-completion/completions | [from 0.8] Install directory for bash completion rules |
TLP_NO_BASHCOMP | 0 | 1=do not install tlp.bash_completion |
TLP_NO_INIT | 0 | 1=do not install tlp.init |
TLP_NO_PMUTILS | 0 | 1=do not install 49tlp, tlp-nop |
TLP_NO_TPACPI | 0 | 1=do not install tpacpi-bat |
TLP_SYSD | /lib/systemd/system | [from 0.6] Install directory for systemd units |
TLP_SYSV | /etc/init.d | [from 1.0] Install directory for sysvinit script |
TLP_WITH_SYSTEMD | 0 | [from 0.6] 1=install systemd unit files |
Table 3: Makefile parameters
TLP depends on (or conficts with) the tools described below. They should be implemented as package dependencies.
optional
Kernel module needed for advanced battery functions of Sandy Bridge and newer ThinkPads models (X220, T420, et al.). Do not implement via direct package dependency.
optional
Used to disable wake on lan.
mandatory
Needed for hard disk advanced power management and to show information in tlp-stat.
mandatory
Needed for wifi power save, replaces deprecated iwconfig (see wireless-tools below).
conflicts
There can only be one power management tool.
optional
Used to show distribution/release in tlp-stat.
mandatory
Provides lspci used to show PCI(e) devices in tlp-stat.
conflicts or mandatory
pm-utils provides it's own set of power management scripts in /usr/lib/pm-utils/power.d/ that compete with TLP's functionality. Depending on the target distribution there are two ways to deal with this:
Important: see the Architecure section for details.
mandatory
Needed for switching radio devices on and off.
optional
Used to show hard disk drive SMART data in tlp-stat (smartctl).
optional
Kernel modules needed to implement battery functions on ThinkPads. The implementation of the package depends considerably on the target distribution and therein on the kernel variant. It is therefore not useful to suffice the dependecy via a direct package dependency.
mandatory
Provides lsusb used to show USB devices in tlp-stat.
mandatory
Provides dmesg for ALPM warnings in tlp-stat.
deprecated
Needed for wifi power save (iwconfig); only if iw and rfkill (see above) are not available.
optional
Linux kernel version specific tool contained in the kernel tree (tools/power/x86). Needed to set performance versus energy savings policy for the CPU.
Hint: Ubuntu provides it via the metapackage linux-tools, the Debian package of the same name however does not contain it. Your mileage with other distributions may vary.
mandatory
Provides libraries tlp-functions and tlp-rf-func.
mandatory
Used to hook ifup/ifdown events and to determine corresponding interface type lan/wifi/wwan.
The sources contain the unit tlp.service, which calls tlp init start/stop upon system startup/shutdown. Use the TLP_WITH_SYSTEMD Makefile switch to install it.
The package install process must link the sysvinit script tlp.init i.e. /etc/init.d/tlp to the necessary runlevels by means of the target distribution.
In case the target distribution does support neither systemd nor sysvinit, you have to program a script that calls tlp accordingly:
The parameter after init is checked by tlp.
There is no TLP daemon. TLP is event based and depends on other system daemons.
The call architecture is as follows:
udevd: detects by an udev rule in tlp.rules when the power supply is plugged or unplugged and calls tlp auto upon each change.
There are two possible variants to satisfy different distributions' requirements:
As already mentioned in the pm-utils section above, it is necessary to mask pm-utils' scripts located in /usr/lib/pm-utils/power.d/. To achieve this, an empty script with identical name is put in /etc/pm/power.d/. For transparency this is done with symlinks to /usr/share/tlp-pm/tlp-nop.
Important: the symlinks must be removed when uninstalling the tlp package.
# Mask conflicting pm-utils hooks if [ -d /usr/lib/pm-utils/power.d ] && [ -d /etc/pm/power.d ]; then for i in 95hdparm-apm disable_wol hal-cd-polling intel-audio-powersave harddrive \ laptop-mode journal-commit pci_devices pcie_aspm readahead sata_alpm \ if [ -x /usr/lib/pm-utils/power.d/$i ]; then # Executable hook in /usr/lib/pm-utils/power.d/ exists if [ -f /etc/pm/power.d/$i ]; then # Exclude symlinks to tlp-nop if ! readlink /etc/pm/power.d/$i | egrep -q 'tlp-nop$' ; then # Move aside superseding hook of same name in /etc/pm/power.d/ mv -n /etc/pm/power.d/$i /etc/pm/power.d/$i.tlp-save fi fi # Make a soft link to tlp-nop in /etc/pm/power.d/ # to disable corresponding hook /usr/lib/pm-utils/power.d/ ln -sf /usr/share/tlp-pm/tlp-nop /etc/pm/power.d/$i fi done fi # Mask conflicting upstart jobs (Package rfkill in Ubuntu) for i in /etc/init/rfkill-*.conf; do if [ -f "$i" ] –– [ ! -f "${i%.conf}.override" ]; then # Do this only when no .override exists echo "manual" > ${i%.conf}.override fi done # Mask conflicting systemd services for i in $(ls /lib/systemd/system 2> /dev/null | egrep "systemd-rfkill"); do systemctl mask $i 2> /dev/null || true done
# Unmask pm-utils hooks for i in 95hdparm-apm disable_wol hal-cd-polling intel-audio-powersave harddrive \ laptop-mode journal-commit pci_devices pcie_aspm readahead sata_alpm \ sched-powersave usb_bluetooth wireless xfs_buffer; do if readlink /etc/pm/power.d/$i | egrep -q 'tlp-nop$' ; then rm /etc/pm/power.d/$i fi done # Unmask conflicting upstart jobs (Package rfkill in Ubuntu) for i in /etc/init/rfkill-*.override; do [ ! -f "$i" ] || rm -f $i done # Unmask conflicting systemd services for i in $(ls /lib/systemd/system 2> /dev/null | egrep "systemd-rfkill"); do systemctl unmask $i 2> /dev/null || true done ;;
Installed packages should be tested with trace mode enabled:
See Trace Mode.
© 2016, linrunner. Licensed under the CC BY-NC-SA.