├── usr ├── share │ ├── laptop-mode-tools │ │ ├── module-helpers │ │ │ ├── pm-freeze │ │ │ ├── pm-suspend │ │ │ ├── pm-hibernate │ │ │ ├── pm-helper │ │ │ └── lm-polling-daemon │ │ ├── locale │ │ │ └── zh_CN.qm │ │ └── modules │ │ │ ├── nouveau │ │ │ ├── eee-superhe │ │ │ ├── exec-commands │ │ │ ├── lcd-brightness │ │ │ ├── nmi-watchdog │ │ │ ├── battery-level-polling │ │ │ ├── sched-mc-power-savings │ │ │ ├── sched-smt-power-savings │ │ │ ├── ac97-powersave │ │ │ ├── pcie-aspm │ │ │ ├── radeon-dpm │ │ │ ├── terminal-blanking │ │ │ ├── vgaswitcheroo │ │ │ ├── kbd-backlight │ │ │ ├── video-out │ │ │ ├── intel_pstate │ │ │ ├── bluetooth │ │ │ ├── hal-polling │ │ │ ├── syslog-conf │ │ │ ├── intel-hda-powersave │ │ │ ├── cpuhotplug │ │ │ ├── dpms-standby │ │ │ ├── intel-sata-powermgmt │ │ │ ├── configuration-file-control │ │ │ ├── wireless-iwl-power │ │ │ ├── ethernet │ │ │ ├── wireless-power │ │ │ ├── start-stop-programs │ │ │ ├── wireless-ipw-power │ │ │ ├── cpufreq │ │ │ ├── runtime-pm │ │ │ └── hdparm │ └── polkit-1 │ │ └── actions │ │ └── org.linux.lmt.gui.policy ├── sbin │ ├── lm-syslog-setup │ └── lm-profiler └── lib │ └── pm-utils │ └── sleep.d │ └── 01laptop-mode ├── etc ├── acpi │ ├── events │ │ ├── lm_lid │ │ ├── lm_battery │ │ └── lm_ac_adapter │ └── actions │ │ ├── lm_ac_adapter.sh │ │ ├── lm_lid.sh │ │ └── lm_battery.sh ├── systemd │ ├── laptop-mode.conf.tmpfiles │ ├── laptop-mode.timer │ ├── laptop-mode.service │ └── lmt-poll.service ├── rules │ ├── 99-laptop-mode.rules │ └── lmt-udev ├── laptop-mode │ ├── conf.d │ │ ├── radeon-dpm.conf │ │ ├── ac97-powersave.conf │ │ ├── wireless-power.conf │ │ ├── nmi-watchdog.conf │ │ ├── sched-smt-power-savings.conf │ │ ├── eee-superhe.conf │ │ ├── sched-mc-power-savings.conf │ │ ├── wireless-ipw-power.conf │ │ ├── battery-level-polling.conf │ │ ├── bluetooth.conf │ │ ├── nouveau.conf │ │ ├── pcie-aspm.conf │ │ ├── video-out.conf │ │ ├── wireless-iwl-power.conf │ │ ├── vgaswitcheroo.conf │ │ ├── intel-hda-powersave.conf │ │ ├── hal-polling.conf │ │ ├── intel-sata-powermgmt.conf │ │ ├── cpuhotplug.conf │ │ ├── intel_pstate.conf │ │ ├── terminal-blanking.conf │ │ ├── dpms-standby.conf │ │ ├── auto-hibernate.conf │ │ ├── kbd-backlight.conf │ │ ├── start-stop-programs.conf │ │ ├── ethernet.conf │ │ ├── lcd-brightness.conf │ │ ├── runtime-pm.conf │ │ ├── exec-commands.conf │ │ ├── cpufreq.conf │ │ └── configuration-file-control.conf │ ├── lm-profiler.conf │ └── laptop-mode.conf ├── power │ ├── event.d │ │ └── laptop-mode │ └── scripts.d │ │ └── laptop-mode ├── apm │ └── event.d │ │ └── laptop-mode └── init.d │ └── laptop-mode ├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ └── laptop-mode-tools-bug-report.md ├── gui ├── lmt-config-gui ├── lmt-config-gui-pkexec ├── laptop-mode-tools.desktop └── laptop-mode-tools.svg ├── README.Board-Specific ├── Makefile ├── release-checklist ├── .gitignore ├── Documentation └── readme-debugging.txt ├── man ├── lm-syslog-setup.8 ├── laptop_mode.8 ├── lm-profiler.8 └── lm-profiler.conf.8 ├── README.md └── laptop-mode-tools.spec /usr/share/laptop-mode-tools/module-helpers/pm-freeze: -------------------------------------------------------------------------------- 1 | pm-helper -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/module-helpers/pm-suspend: -------------------------------------------------------------------------------- 1 | pm-helper -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/module-helpers/pm-hibernate: -------------------------------------------------------------------------------- 1 | pm-helper -------------------------------------------------------------------------------- /etc/acpi/events/lm_lid: -------------------------------------------------------------------------------- 1 | event=button[ /]lid 2 | action=/etc/acpi/actions/lm_lid.sh %e 3 | -------------------------------------------------------------------------------- /etc/acpi/events/lm_battery: -------------------------------------------------------------------------------- 1 | event=battery.* 2 | action=/etc/acpi/actions/lm_battery.sh %e 3 | -------------------------------------------------------------------------------- /etc/acpi/events/lm_ac_adapter: -------------------------------------------------------------------------------- 1 | event=ac_adapter.* 2 | action=/etc/acpi/actions/lm_ac_adapter.sh 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [rickysarraf] 4 | -------------------------------------------------------------------------------- /etc/systemd/laptop-mode.conf.tmpfiles: -------------------------------------------------------------------------------- 1 | # systemd tmpfiles for Laptop Mode Tools 2 | 3 | D /run/laptop-mode-tools 4 | F /run/laptop-mode-tools/enabled 5 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/locale/zh_CN.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickysarraf/laptop-mode-tools/HEAD/usr/share/laptop-mode-tools/locale/zh_CN.qm -------------------------------------------------------------------------------- /etc/acpi/actions/lm_ac_adapter.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | test -f /lib/udev/lmt-udev || exit 0 4 | 5 | # ac on/offline event handler 6 | /lib/udev/lmt-udev 7 | -------------------------------------------------------------------------------- /gui/lmt-config-gui: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Needed for annoying QT MIT bug 4 | export QT_X11_NO_MITSHM=1 5 | 6 | python3 /usr/share/laptop-mode-tools/lmt.py 7 | -------------------------------------------------------------------------------- /etc/acpi/actions/lm_lid.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | test -f /lib/udev/lmt-udev || exit 0 4 | 5 | # lid button pressed/released event handler 6 | /lib/udev/lmt-udev 7 | -------------------------------------------------------------------------------- /gui/lmt-config-gui-pkexec: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PKEXEC=`which pkexec`; 4 | 5 | if [ -x $PKEXEC ]; then 6 | echo "Exec with pkexec" 7 | $PKEXEC /usr/sbin/lmt-config-gui 8 | fi 9 | -------------------------------------------------------------------------------- /etc/acpi/actions/lm_battery.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | test -f /lib/udev/lmt-udev || exit 0 4 | 5 | # Automatically disable laptop mode when the battery almost runs out, 6 | # and re-enable it when it 7 | /lib/udev/lmt-udev 8 | -------------------------------------------------------------------------------- /README.Board-Specific: -------------------------------------------------------------------------------- 1 | # Configuration files that are put here will override the default ones 2 | # Users can copy the default configuration files here and adapt it to their system hardware 3 | # 4 | # Configuration files are read if their names end in .conf. Eg. laptop-mode.conf 5 | -------------------------------------------------------------------------------- /etc/systemd/laptop-mode.timer: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Runs Laptop Mode Tools - Polling Service, every 150 seconds 3 | 4 | 5 | [Timer] 6 | # Let's run every 150 secs, to poll the battery 7 | OnUnitActiveSec=150s 8 | OnActiveSec=150s 9 | Unit=lmt-poll.service 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /gui/laptop-mode-tools.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=Laptop Mode Tools Configuration 4 | GenericName=Laptop Mode Tools Configuration 5 | Icon=laptop-mode-tools 6 | Exec=/usr/sbin/lmt-config-gui-pkexec 7 | Categories=System; 8 | Comment=Enable/disable Laptop Mode Tools settings 9 | Keywords=Preferences; 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | @echo "Please specify a make target: install, clean, version." 4 | 5 | clean: 6 | rm -f `find . -name \*~` 7 | 8 | # Get the version from usr/sbin/laptop_mode. 9 | VERSION :=$(shell cat usr/sbin/laptop_mode | grep "LMTVERSION=" | sed 's/LMTVERSION=//g') 10 | 11 | version: 12 | @echo $(VERSION) 13 | 14 | install: 15 | ./install.sh 16 | -------------------------------------------------------------------------------- /etc/rules/99-laptop-mode.rules: -------------------------------------------------------------------------------- 1 | ACTION=="change", SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_NAME}=="|AC|ACAD|ADP*", RUN+="lmt-udev auto" 2 | ACTION=="add|remove", SUBSYSTEM=="machinecheck", RUN+="lmt-udev auto" 3 | ACTION=="add", SUBSYSTEM=="usb", RUN+="lmt-udev force" 4 | 5 | # Run a particular module only 6 | #ACTION=="add", SUBSYSTEM=="usb", RUN+="lmt-udev force modules=runtime-pm devices=%k" 7 | -------------------------------------------------------------------------------- /usr/sbin/lm-syslog-setup: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | if [ ! -f /etc/laptop-mode/laptop-mode.conf -o ! -f /usr/sbin/laptop_mode ] ; then 6 | echo Laptop mode does not seem to be installed. 7 | exit 1 8 | fi 9 | 10 | echo "lm-syslog-setup is no longer supported. Please use the module" 11 | echo "configuration-file-control, which provides similar funcionality. It is" 12 | echo "configured using the file:" 13 | echo " /etc/laptop-mode/conf.d/configuration-file-control.conf." 14 | 15 | -------------------------------------------------------------------------------- /release-checklist: -------------------------------------------------------------------------------- 1 | * Update version in usr/sbin/laptop_mode 2 | * Put release date in Documentation/revision-history. Eg: git log 1.67...HEAD --pretty=format:'%s' --reverse, 3 | or use alias 'mychlog' from the .gitconfig 4 | * Update laptop-mode-tools.spec 5 | * Tag the release 6 | * Create git tarball using 'git archive --format=tar --prefix=laptop-mode-tools_N.NN/ GIT_VERSION_TAG | gzip > laptop-mode-tools_N.NN.tar.gz 7 | * Create RPM Packages 8 | * Update Github page 9 | * Send Release Announcement 10 | -------------------------------------------------------------------------------- /usr/lib/pm-utils/sleep.d/01laptop-mode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # 01laptop-mode: Re-apply laptop mode tools settings 4 | 5 | if [ -f /etc/pm/sleep.d/99laptop-mode ]; then 6 | continue 7 | else 8 | case "$1" in 9 | hibernate|suspend) 10 | # Stopping is not required. 11 | ;; 12 | thaw|resume) 13 | # Make laptop mode tools forcibly re-apply the hardware settings 14 | # that laptop mode tools applies. 15 | if [ -e /usr/sbin/laptop_mode ] ; then 16 | /usr/sbin/laptop_mode auto force 17 | fi 18 | ;; 19 | *) exit $NA 20 | ;; 21 | esac 22 | fi 23 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/module-helpers/pm-helper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | MEM=0; 5 | DISK=0; 6 | 7 | target=`basename $0 | cut -d '-' -f2` 8 | 9 | 10 | case "$target" in 11 | suspend) MEM=1 ;; 12 | hibernate) DISK=1 ;; 13 | freeze) FREEZE=1 ;; 14 | *) echo "Unrecognized command" 15 | exit 1 ;; 16 | esac 17 | 18 | # Sync buffers first. 19 | sync; 20 | 21 | # Freezer on preference 22 | if [ x$MEM = x1 ]; then 23 | echo "mem" > /sys/power/state 24 | elif [ x$DISK = x1 ]; then 25 | echo "disk" > /sys/power/state 26 | elif [ x$FREEZE = x1 ]; then 27 | echo "freeze" > /sys/power/state 28 | else 29 | ## Nothing to do. 30 | echo ; 31 | fi 32 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/nouveau: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | if [ x$CONTROL_NOUVEAU = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_NOUVEAU = xauto ]; then 4 | if [ -f $NOUVEAU_CONTROL_FILE ]; then 5 | if [ $ON_AC -eq 1 ]; then 6 | if [ $ACTIVATE -eq 1 ]; then 7 | NOUVEAU_VALUE="$LM_AC_NOUVEAU" 8 | else 9 | NOUVEAU_VALUE="$NOLM_AC_NOUVEAU" 10 | fi 11 | else 12 | NOUVEAU_VALUE="$BATT_NOUVEAU" 13 | fi 14 | 15 | echo $NOUVEAU_VALUE > $NOUVEAU_CONTROL_FILE 16 | else 17 | log "VERBOSE" "Control file $NOUVEAU_CONTROL_FILE unavailable" 18 | fi 19 | else 20 | log "VERBOSE" "Module nouveau is disabled" 21 | fi 22 | 23 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This is the laptop mode tools polling daemon. It is used by the module 4 | # battery-level-polling to periodically let laptop mode tools run and check 5 | # the battery levels. 6 | 7 | 8 | # Poll every 2.5 minutes. That ought to give a good balance between 9 | # polling too often (which costs power) and polling too little (which 10 | # risks data loss). 11 | INTERVAL=150 12 | 13 | if [ -d /run/systemd/system ]; then 14 | echo "systemd detected. Battery polling is supported through lmt-poll timer"; 15 | return 0; 16 | fi 17 | 18 | while :; do 19 | sleep $INTERVAL 20 | 21 | /usr/sbin/laptop_mode auto 22 | done 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Python 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | *.so 6 | 7 | # Distribution / packaging 8 | .Python 9 | build/ 10 | develop-eggs/ 11 | dist/ 12 | downloads/ 13 | eggs/ 14 | .eggs/ 15 | lib/ 16 | lib64/ 17 | parts/ 18 | sdist/ 19 | var/ 20 | wheels/ 21 | *.egg-info/ 22 | .installed.cfg 23 | *.egg 24 | 25 | # Installer logs 26 | pip-log.txt 27 | pip-delete-this-directory.txt 28 | 29 | # Unit test / coverage reports 30 | htmlcov/ 31 | .tox/ 32 | .coverage 33 | .coverage.* 34 | .cache 35 | nosetests.xml 36 | coverage.xml 37 | *.cover 38 | .pytest_cache/ 39 | 40 | # PyCharm 41 | .idea/ 42 | 43 | # VS Code 44 | .vscode/ 45 | 46 | # Vim 47 | *.swp 48 | *.swo 49 | *~ 50 | 51 | # Mac 52 | .DS_Store 53 | -------------------------------------------------------------------------------- /etc/systemd/laptop-mode.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Laptop Mode Tools 3 | Documentation=man:laptop_mode(8) man:laptop-mode.conf(8) 4 | Documentation=http://github.com/rickysarraf/laptop-mode-tools 5 | 6 | [Service] 7 | Type=oneshot 8 | RemainAfterExit=yes 9 | ExecStartPre=/bin/rm -f /var/run/laptop-mode-tools/enabled 10 | ExecStartPre=/bin/rm -f /var/run/laptop-mode-tools/state 11 | ExecStart=/usr/sbin/laptop_mode init force 12 | ExecStop=/usr/sbin/laptop_mode init stop 13 | ExecStopPost=/bin/rm -f /var/run/laptop-mode-tools/enabled 14 | ExecStopPost=/bin/rm -f /var/run/laptop-mode-tools/state 15 | ExecReload=/usr/sbin/laptop_mode auto 16 | StandardOutput=journal 17 | StandardError=journal 18 | TasksMax=infinity 19 | 20 | [Install] 21 | WantedBy=multi-user.target 22 | -------------------------------------------------------------------------------- /etc/systemd/lmt-poll.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Laptop Mode Tools - Battery Polling Service 3 | Documentation=man:laptop_mode(8) man:laptop-mode.conf(8) 4 | Documentation=http://github.com/rickysarraf/laptop-mode-tools 5 | 6 | [Service] 7 | Type=oneshot 8 | RemainAfterExit=yes 9 | Environment=CONTROL_BATTERY_LEVEL_POLLING=1 10 | EnvironmentFile=-/etc/laptop-mode/conf.d/battery-level-polling.conf 11 | ExecStart=-/bin/sh -c '[ x"$CONTROL_BATTERY_LEVEL_POLLING" = "x1" ] && /lib/udev/lmt-udev auto || echo "laptop-mode: Battery polling disabled"' 12 | ExecReload=-/bin/sh -c '[ x"$CONTROL_BATTERY_LEVEL_POLLING" = "x1" ] && /lib/udev/lmt-udev auto || echo "laptop-mode: Battery polling disabled"' 13 | StandardOutput=journal 14 | StandardError=journal 15 | 16 | [Install] 17 | WantedBy=multi-user.target 18 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/eee-superhe: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | if [ x$SUPERHE_CONTROL_FILE = x ]; then 4 | SUPERHE_CONTROL_FILE=/sys/devices/platform/eeepc/cpufv 5 | log "VERBOSE" "Control file is $SUPERHE_CONTROL_FILE" 6 | fi 7 | 8 | if [ x$CONTROL_SUPERHE = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_SUPERHE = xauto ]; then 9 | if [ $ON_AC -eq 1 ]; then 10 | if [ $ACTIVATE -eq 1 ]; then 11 | SUPERHE_VALUE="$LM_AC_SUPERHE" 12 | else 13 | SUPERHE_VALUE="$NOLM_AC_SUPERHE" 14 | fi 15 | else 16 | SUPERHE_VALUE="$BATT_SUPERHE" 17 | fi 18 | 19 | if [ -e $SUPERHE_CONTROL_FILE ]; then 20 | echo $SUPERHE_VALUE > $SUPERHE_CONTROL_FILE 21 | log "VERBOSE" "SuperHe triggered with value $SUPERHE_VALUE" 22 | else 23 | log "VERBOSE" "Platform does not support SuperHe" 24 | fi 25 | fi 26 | 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/laptop-mode-tools-bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Laptop Mode Tools Bug Report 3 | about: Laptop Mode Tools Bug Report 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Important Information:** 27 | - Distribution 28 | - Linux Kernel 29 | - Laptop Mode Tools version 30 | - Desktop Environment, if any 31 | - Relevant System Logs 32 | - Laptop Mode Tools verbose logs 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/radeon-dpm.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module radeon-dpm. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # Radeon VGA Adapter Power Saving 9 | # ------------------------------- 10 | # 11 | #__COMMENT Enable this setting to save some power on your Radeon VGA card 12 | #__This only works with the radeon driver - and supported cards. 13 | #__With kernel-version >= 3.12 DPM is enabled by default, at 3.11 you can add 14 | #__radeon.dpm=1 to the kenrel command line and enable it manually. 15 | # 16 | ############################################################################### 17 | 18 | # Enable debug mode for this module 19 | # Set to 1 if you want to debug this module 20 | DEBUG=0 21 | 22 | # Set to 0 to disable. 23 | CONTROL_RADEON_DPM="auto" 24 | 25 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/exec-commands: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: Execute specific commands for power saving. 4 | # 5 | 6 | if [ x$CONTROL_EXEC_COMMANDS = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_EXEC_COMMANDS = xauto ]; then 7 | if [ $ON_AC -eq 1 ]; then 8 | if [ "$ACTIVATE" -eq 1 ]; then 9 | COMMAND_TYPE=LM_AC_EXEC_COMMAND 10 | else 11 | COMMAND_TYPE=NOLM_AC_EXEC_COMMAND 12 | fi 13 | else 14 | COMMAND_TYPE=BATT_EXEC_COMMAND 15 | fi 16 | 17 | # Handle Command Execution 18 | COUNTER=0 19 | while true; 20 | do 21 | COMMAND=\${${COMMAND_TYPE}_${COUNTER}} 22 | COMMAND=$(eval echo $COMMAND) 23 | 24 | if [ $COUNTER -ge 10 ]; then 25 | break; 26 | fi 27 | 28 | log "VERBOSE" "Executing comand $COMMAND" 29 | log "VERBOSE" $(eval $COMMAND) 30 | 31 | COUNTER=`expr $COUNTER + 1` 32 | done 33 | else 34 | log "VERBOSE" "Module exec-commands is disabled" 35 | fi 36 | -------------------------------------------------------------------------------- /etc/power/event.d/laptop-mode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # name : laptop-mode 4 | # author : Matthias Grimm 5 | # description : toggle laptop mode in kernel and adjust 6 | # memory management buffer flush timeouts 7 | # requirements: laptop-mode support in kernel 8 | # laptopmode.sh somewhere on your system 9 | # limitations : none 10 | # 11 | # --- end of public part -- don't change below this line --- 12 | 13 | set -e 14 | LMODE=/lib/udev/lmt-udev 15 | 16 | [ -x $LMODE ] || exit 0 17 | 18 | if [ -w /proc/sys/vm/laptop_mode ]; then 19 | case "$1" in 20 | powersave) 21 | $LMODE "start" 22 | echo "3 " $LMODE "start" 23 | ;; 24 | custom) 25 | $LMODE "auto" 26 | ;; 27 | performance) 28 | $LMODE "stop" 29 | ;; 30 | esac 31 | elif [ -x logger ]; then 32 | logger -p daemon.error -t laptop-mode "Laptop-mode support missing in kernel." 33 | fi 34 | 35 | 36 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/lcd-brightness: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: control LCD brightness 4 | # 5 | 6 | # Control LCD brightness 7 | if [ x$CONTROL_BRIGHTNESS = x1 ] ; then 8 | if [ $ON_AC -eq 1 ]; then 9 | if [ "$ACTIVATE" -eq 1 ]; then 10 | BRIGHTNESS_COMMAND="$LM_AC_BRIGHTNESS_COMMAND" 11 | else 12 | BRIGHTNESS_COMMAND="$NOLM_AC_BRIGHTNESS_COMMAND" 13 | fi 14 | else 15 | BRIGHTNESS_COMMAND="$BATT_BRIGHTNESS_COMMAND" 16 | fi 17 | 18 | log "VERBOSE" "Set LCD brightness using command $BRIGHTNESS_COMMAND \> $BRIGHTNESS_OUTPUT." 19 | $BRIGHTNESS_COMMAND > $BRIGHTNESS_OUTPUT; 20 | if [ $? -eq 0 ]; then 21 | log "MSG" "LCD Brightness Command succeeded." 22 | else 23 | log "ERR" "The configured LCD brightness command of the lcd-brightness module failed." 24 | log "ERR" "Please check your configuration in /etc/laptop-mode/conf.d/lcd-brightness.conf." 25 | log "ERR" "Command failed." 26 | fi 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /usr/share/polkit-1/actions/org.linux.lmt.gui.policy: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | Authentication is required to run Laptop Mode Tools Config 9 | package-x-generic 10 | 11 | auth_admin 12 | auth_admin 13 | auth_admin 14 | 15 | /usr/sbin/lmt-config-gui-pkexec 16 | /usr/sbin/lmt-config-gui 17 | true 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/ac97-powersave.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module ac97-powersave. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # AC97 power saving settings 10 | # --------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically set the 13 | #__COMMENT powersave mode of AC97 audio chipsets. This setting does not hurt, so 14 | #__COMMENT there are no AC vs. battery settings: if CONTROL_AC97_POWER is set to 1, 15 | #__COMMENT the powersave mode is always enabled. 16 | #__COMMENT Set to 0 to disable. 17 | # 18 | ############################################################################### 19 | 20 | # Control AC97 audio chipset power? 21 | CONTROL_AC97_POWER="auto" 22 | 23 | # Enable debug mode for this module 24 | # Set to 1 if you want to debug this module 25 | DEBUG=0 26 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/nmi-watchdog: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: NMI Watchdog timer power savings 4 | # 5 | 6 | if [ x$CONTROL_NMI_WATCHDOG = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_NMI_WATCHDOG = xauto ]; then 7 | if [ $ON_AC -eq 1 ]; then 8 | log "VERBOSE" "On AC power: setting NMI Watchdog Timer to 1" 9 | if [ -w /proc/sys/kernel/nmi_watchdog ]; then 10 | echo 1 > /proc/sys/kernel/nmi_watchdog 11 | log "VERBOSE" "NMI Watchdog timer enabled" 12 | else 13 | log "VERBOSE" "NMI Watchdog timer is not available" 14 | fi 15 | else 16 | log "VERBOSE" "On battery: setting NMI Watchdog timer to 0" 17 | if [ -w /proc/sys/kernel/nmi_watchdog ]; then 18 | echo 0 > /proc/sys/kernel/nmi_watchdog 19 | log "VERBOSE" "NMI Watchdog timer disabled" 20 | else 21 | log "VERBOSE" "NMI Watchdog timer is not available" 22 | fi 23 | 24 | fi 25 | else 26 | log "VERBOSE" "NMI Watchdog timer power savings module is disabled" 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/wireless-power.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module wireless-power. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Generic wireless power saving mode settings 10 | # ------------------------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically set the 13 | #__COMMENT power saving mode of wireless interfaces which support power saving using 14 | #__COMMENT the iwconfig power on/off setting. 15 | # 16 | ############################################################################### 17 | 18 | # Enable debug mode for this module 19 | # Set to 1 if you want to debug this module 20 | DEBUG=0 21 | 22 | # Control generic wireless interface power saving mode? 23 | CONTROL_WIRELESS_POWER_SAVING="auto" 24 | 25 | WIRELESS_AC_POWER_SAVING=0 26 | WIRELESS_BATT_POWER_SAVING=1 27 | -------------------------------------------------------------------------------- /etc/power/scripts.d/laptop-mode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # name : laptop-mode 4 | # author : Matthias Grimm 5 | # description : toggle laptop mode in kernel and adjust 6 | # memory management buffer flush timeouts 7 | # requirements: laptop-mode support in kernel 8 | # laptopmode.sh somewhere on your system 9 | # limitations : none 10 | # 11 | # --- end of public part -- don't change below this line --- 12 | 13 | set -e 14 | LMODE=/lib/udev/lmt-udev 15 | 16 | [ -x $LMODE ] || exit 0 17 | 18 | if [ -w /proc/sys/vm/laptop_mode ]; then 19 | case "$1" in 20 | powersave) 21 | $LMODE "start" 22 | echo "3 " $LMODE "start" 23 | ;; 24 | custom) 25 | $LMODE "auto" 26 | ;; 27 | performance) 28 | $LMODE "stop" 29 | ;; 30 | resume) 31 | $LMODE "auto" "force" 32 | ;; 33 | esac 34 | elif [ -x logger ]; then 35 | logger -p daemon.error -t laptop-mode "Laptop-mode support missing in kernel." 36 | fi 37 | 38 | 39 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/nmi-watchdog.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module nmi-watchdog 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # NMI Watchdog Timer enable/disable switch 10 | # -------------------------------------------------------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically configure the 13 | #__COMMENT NMI Watchdog timer to save power while running on battery mode. 14 | #__COMMENT 15 | #__COMMENT Enabling this module cut down one hw-pmu counter 16 | # 17 | ############################################################################### 18 | 19 | # Enable debug mode for this module 20 | # Set to 1 if you want to debug this module 21 | DEBUG=0 22 | 23 | 24 | # Control multi-core power-saving tunables for the process scheduler? 25 | # Set to 0 to disable 26 | CONTROL_NMI_WATCHDOG="auto" 27 | 28 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/sched-smt-power-savings.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module sched-smt-power-savings 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # SMT multi-threaded power-saving tunables for the process scheduler 10 | # -------------------------------------------------------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically configure the 13 | #__COMMENT Linux scheduler to save power on SMT processors while running on 14 | #__COMMENT battery mode. 15 | # 16 | ############################################################################### 17 | 18 | # Enable debug mode for this module 19 | # Set to 1 if you want to debug this module 20 | DEBUG=0 21 | 22 | 23 | # Control multi-core power-saving tunables for the process scheduler? 24 | # Set to 0 to disable 25 | CONTROL_SCHED_SMT_POWER_SAVINGS="auto" 26 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/eee-superhe.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module eee-superhe 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ################################################################################ 8 | # EEE SuperHE power saving settings 9 | # ---------------------------------- 10 | # 11 | #__COMMENT Enable this setting if you have an eeepc laptop 12 | # 13 | ################################################################################ 14 | 15 | 16 | # Enable debug mode for this module 17 | # Set to 1 if you want to debug this module 18 | DEBUG=0 19 | 20 | # Control FSB speed. Requires eeepc_laptop kernel module loaded. 21 | # Set to 0 to disable. 22 | # 23 | CONTROL_SUPERHE="auto" 24 | 25 | # 2 is powersave 26 | # 1 is normal 27 | # 0 is performance 28 | 29 | BATT_SUPERHE=2 30 | LM_AC_SUPERHE=0 31 | NOLM_AC_SUPERHE=0 32 | 33 | # If your system has the control file located at another point 34 | # configure it here 35 | # SUPERHE_CONTROL_FILE= 36 | 37 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/sched-mc-power-savings.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module sched-mc-power-savings 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Multi-core, multi-threaded power-saving tunables for the process scheduler 10 | # -------------------------------------------------------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically configure the 13 | #__COMMENT Linux scheduler to save power on multi-core processors while running on 14 | #__COMMENT battery mode. 15 | # 16 | ############################################################################### 17 | 18 | # Enable debug mode for this module 19 | # Set to 1 if you want to debug this module 20 | DEBUG=0 21 | 22 | 23 | # Control multi-core power-saving tunables for the process scheduler? 24 | # Set to 0 to disable 25 | CONTROL_SCHED_MC_POWER_SAVINGS="auto" 26 | 27 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/battery-level-polling: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: Battery level polling. 4 | # 5 | 6 | if [ x$CONTROL_BATTERY_LEVEL_POLLING = x1 ] ; then 7 | log "VERBOSE" "Battery level polling is enabled." 8 | 9 | if [ x$BLACKLIST_IN_FLOCK = x1 ]; then 10 | log "VERBOSE" "Battery polling daemon blacklisted in flock" 11 | else 12 | if [ x$ON_AC = x1 ] ; then 13 | log "VERBOSE" "On AC, stopping the polling daemon." 14 | 15 | # In AC mode we disable the polling daemon. 16 | killall -gq lm-polling-daemon 17 | $FLOCK -u 7; 18 | else 19 | if ! pidof -x lm-polling-daemon ; then 20 | log "VERBOSE" "On battery and there was no polling daemon yet, starting the polling daemon." 21 | 22 | # If there is no polling daemon, we start one. 23 | #/usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon < /dev/null > /dev/null 2> /dev/null & 24 | /usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon & 25 | fi 26 | fi 27 | fi 28 | else 29 | log "VERBOSE" "Battery level polling is disabled." 30 | fi 31 | 32 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/wireless-ipw-power.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module wireless-ipw-power. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # IWP Wireless Power settings 10 | # --------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically set the 13 | #__COMMENT powersave mode of Intel IPW3945, IPW2200 and IPW2100 wireless adapters. 14 | # 15 | ############################################################################### 16 | 17 | # Enable debug mode for this module 18 | # Set to 1 if you want to debug this module 19 | DEBUG=0 20 | 21 | # Control Intel IPW wireless power? 22 | # Set to 0 to disable 23 | CONTROL_IPW_POWER="auto" 24 | 25 | # Levels passed to "iwpriv set_power" for the IPW3945 and IPW2100 wireless 26 | # chipsets. The allowed values are different for each chipset. 27 | IPW3945_AC_POWER=6 28 | IPW3945_BATT_POWER=7 29 | 30 | IPW2100_AC_POWER=0 31 | IPW2100_BATT_POWER=5 32 | 33 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/sched-mc-power-savings: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: Scheduler tunables for multi-socket/multi-core systems. 4 | # 5 | 6 | if [ x$CONTROL_SCHED_MC_POWER_SAVINGS = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_SCHED_MC_POWER_SAVINGS = xauto ]; then 7 | if [ $ON_AC -eq 1 ]; then 8 | log "VERBOSE" "On AC power: setting scheduler power saving to 0." 9 | if [ -w /sys/devices/system/cpu/sched_mc_power_savings ]; then 10 | echo 0 > /sys/devices/system/cpu/sched_mc_power_savings 11 | log "VERBOSE" "Scheduler power save mode disabled." 12 | else 13 | log "VERBOSE" "Scheduler power saving is not available." 14 | fi 15 | else 16 | log "VERBOSE" "On battery: setting scheduler power saving to 1." 17 | if [ -w /sys/devices/system/cpu/sched_mc_power_savings ]; then 18 | echo 2 > /sys/devices/system/cpu/sched_mc_power_savings 19 | log "VERBOSE" "Scheduler power save mode enabled." 20 | else 21 | log "VERBOSE" "Scheduler power saving is not available." 22 | fi 23 | 24 | fi 25 | else 26 | log "VERBOSE" "Scheduler power setting is disabled." 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/battery-level-polling.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module battery-level-polling. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # Battery level polling settings 9 | # ------------------------------ 10 | # 11 | #__COMMENT This module allows laptop mode to react to battery level changes, even if the 12 | #__COMMENT battery does not send out frequent ACPI events for such battery level changes. 13 | #__COMMENT 14 | #__COMMENT Note that this does NOT make ACPI-only features work on non-ACPI hardware. 15 | ############################################################################### 16 | 17 | # Enable debug mode for this module 18 | # Set to 1 if you want to debug this module 19 | DEBUG=0 20 | 21 | # 22 | # Enable this setting to enable battery level polling. 23 | # 24 | CONTROL_BATTERY_LEVEL_POLLING=0 25 | 26 | # Blacklist this module's execution in flock 27 | # This is a workaround to ensure that batter-polling-daemon does not acquire the lock 28 | BLACKLIST_IN_FLOCK=1 29 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/sched-smt-power-savings: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: Scheduler tunables for multi-socket SMT systems. 4 | # 5 | 6 | if [ x$CONTROL_SCHED_SMT_POWER_SAVINGS = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_SCHED_SMT_POWER_SAVINGS = xauto ]; then 7 | if [ $ON_AC -eq 1 ]; then 8 | log "VERBOSE" "On AC power: setting scheduler power saving to 0." 9 | if [ -w /sys/devices/system/cpu/sched_smt_power_savings ]; then 10 | echo 0 > /sys/devices/system/cpu/sched_smt_power_savings 11 | log "VERBOSE" "Scheduler SMT power save mode disabled." 12 | else 13 | log "VERBOSE" "Scheduler SMT power saving is not available." 14 | fi 15 | else 16 | log "VERBOSE" "On battery: setting scheduler power saving to 1." 17 | if [ -w /sys/devices/system/cpu/sched_smt_power_savings ]; then 18 | echo 2 > /sys/devices/system/cpu/sched_smt_power_savings 19 | log "VERBOSE" "Scheduler SMT power save mode enabled." 20 | else 21 | log "VERBOSE" "Scheduler SMT power saving is not available." 22 | fi 23 | 24 | fi 25 | else 26 | log "VERBOSE" "Scheduler power setting is disabled." 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/bluetooth.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module bluetooth. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Bluetooth settings 10 | # ------------------ 11 | # 12 | #__COMMENT If you enable this module, laptop mode tools will enable/disable bluetooth 13 | #__COMMENT depending on the power status of your laptop. Bluetooth uses a considerable 14 | #__COMMENT amount of power (comparable to wireless networking), and disabling it is 15 | #__COMMENT therefore a good idea when you are looking to improve your battery life. 16 | # 17 | ############################################################################### 18 | 19 | # Enable debug mode for this module 20 | # Set to 1 if you want to debug this module 21 | DEBUG=0 22 | 23 | # Control bluetooth? 24 | CONTROL_BLUETOOTH=0 25 | 26 | # Enable bluetooth on battery 27 | BATT_ENABLE_BLUETOOTH=0 28 | 29 | # Enable bluetooth on AC 30 | AC_ENABLE_BLUETOOTH=1 31 | 32 | # Bluetooth interfaces to enable/disable 33 | BLUETOOTH_INTERFACES="hci0" 34 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/ac97-powersave: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: Intel AC97 integrated audio power saving mode. 4 | # 5 | 6 | if [ x$CONTROL_AC97_POWER = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_AC97_POWER = xauto ]; then 7 | if [ -w /sys/module/snd_ac97_codec/parameters/power_save ]; then 8 | echo 1 > /sys/module/snd_ac97_codec/parameters/power_save 9 | log "VERBOSE" "AC97 power save mode enabled." 10 | if [ -c /dev/dsp ]; then 11 | # This can fail if the audio device is busy. 12 | # Since this failure is non-fatal (worst case is that the timer changes 13 | # don't get activated), we don't bother if it was successful or not 14 | #(exec 2>/dev/null; echo 1 > /dev/dsp;) 15 | # Better way 16 | echo 1 2>/dev/null >/dev/dsp 17 | log "VERBOSE" "Initialize timer change by close/open /dev/dsp" 18 | fi 19 | else 20 | log "VERBOSE" "AC97 power saving is not available. Perhaps CONFIG_SND_AC97_POWER_SAVE option" 21 | log "VERBOSE" "is not set in the kernel config, or the snd_ac97_codec module is not loaded." 22 | fi 23 | else 24 | log "VERBOSE" "AC97 audio power setting is disabled." 25 | fi 26 | 27 | -------------------------------------------------------------------------------- /Documentation/readme-debugging.txt: -------------------------------------------------------------------------------- 1 | When you suspect a problem with the way power management is reflecting on your machine 2 | please enable the following laptop-mode-tools options to extract more information as to 3 | what might be causing the problem 4 | 5 | 6 | VERBOSE_OUTPUT=1 7 | # 8 | # Set this to 1 if you want to see a lot of information when you start/stop 9 | # laptop_mode. 10 | # 11 | 12 | LOG_TO_SYSLOG=1 13 | # Set this to 1 if you want to log messages to syslog. All of laptop-mode-tools messages 14 | get logged into syslog. This helps further in debugging the problem. 15 | 16 | 17 | 18 | DEBUG=1 19 | # Run in shell debug mode 20 | # Enable this if you would like to execute the entire laptop-mode-tools program 21 | # in shell debug mode. Warning: This will create a lot of text output. 22 | # 23 | # This shell debug mode output will be listed on the terminal where laptop-mode-tools' 24 | # init script it called. 25 | 26 | # If you are debugging an individual module, perhaps you would want to enable 27 | # each module specific debug mode (available in module conf files) 28 | 29 | # Further details and documentation about more of the options of laptop-mode-tools is 30 | # available in the man page 31 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/pcie-aspm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: PCIe Active State Power Management 4 | # 5 | 6 | if [ x$CONTROL_PCIE_ASPM = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_PCIE_ASPM = xauto ]; then 7 | if [ $ON_AC -eq 1 ]; then 8 | if [ $ACTIVATE -eq 1 ]; then 9 | PCIE_ASPM_POLICY=$LM_AC_PCIE_ASPM_POLICY 10 | else 11 | PCIE_ASPM_POLICY=$NOLM_AC_PCIE_ASPM_POLICY 12 | fi 13 | else 14 | PCIE_ASPM_POLICY=$BATT_PCIE_ASPM_POLICY 15 | fi 16 | 17 | if [ -z $PCIE_ASPM_POLICY ]; then 18 | if [ $ON_AC -eq 1 ]; then 19 | PCIE_ASPM_POLICY="default" 20 | else 21 | PCIE_ASPM_POLICY="powersave" 22 | fi 23 | fi 24 | 25 | log "VERBOSE" "PCIe ASPM will be set to $PCIE_ASPM_POLICY" 26 | 27 | if [ -f /sys/module/pcie_aspm/parameters/policy ]; then 28 | echo $PCIE_ASPM_POLICY > /sys/module/pcie_aspm/parameters/policy 2>/dev/null 29 | if [ $? -eq 0 ]; then 30 | log "VERBOSE" "PCIe ASPM set to $PCIE_ASPM_POLICY" 31 | else 32 | log "VERBOSE" "PCIe ASPM tweaking is prohibited by the kernel" 33 | fi 34 | else 35 | log "VERBOSE" "PCIe ASPM is not available" 36 | fi 37 | else 38 | log "VERBOSE" "PCIe ASPM power savings module is disabled" 39 | fi 40 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/radeon-dpm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Laptop mode tools module to handle the DPM Profiles of a GPU (radeon driver only) 3 | # 4 | 5 | if [ x$CONTROL_RADEON_DPM = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_RADEON_DPM = xauto ]; then 6 | for CARD in /sys/class/drm/card?; do 7 | RADEON_DPM_STATE=${CARD}/device/power_dpm_state 8 | RADEON_DPM_PERFORMANCE_LEVEL=${CARD}/device/power_dpm_force_performance_level 9 | if [ -w $RADEON_DPM_STATE -a -w $RADEON_DPM_PERFORMANCE_LEVEL ]; then 10 | if [ $ON_AC -eq 1 ]; then 11 | if [ "$ACTIVATE" -eq 1 ]; then 12 | log "VERBOSE" "Radeon power saving enabled on ${CARD}." 13 | echo battery > $RADEON_DPM_STATE 14 | echo auto > $RADEON_DPM_PERFORMANCE_LEVEL 15 | else 16 | log "VERBOSE" "Radeon power saving disabled on ${CARD}." 17 | echo performance > $RADEON_DPM_STATE 18 | echo auto > $RADEON_DPM_PERFORMANCE_LEVEL 19 | fi 20 | else 21 | log "VERBOSE" "Radeon power saving enabled on ${CARD}." 22 | echo battery > $RADEON_DPM_STATE 23 | echo low > $RADEON_DPM_PERFORMANCE_LEVEL 24 | fi 25 | else 26 | log "VERBOSE" "Radeon Power Saving is not available on ${CARD}." 27 | fi 28 | done 29 | fi 30 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/nouveau.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module nouveau 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ################################################################################ 8 | # Nouveau nvidia card power saving settings 9 | # ---------------------------------- 10 | # 11 | #__COMMENT Enable this setting if you have an nvidia card with nouveau driver 12 | # 13 | ################################################################################ 14 | 15 | 16 | # Enable debug mode for this module 17 | # Set to 1 if you want to debug this module 18 | DEBUG=0 19 | 20 | # Requires nouveau kernel module loaded. 21 | # Requires debugfs mounted 22 | # Set to 0 to disable. 23 | # 24 | CONTROL_NOUVEAU="auto" 25 | 26 | # If your system has the control file located at another point 27 | # configure it here 28 | NOUVEAU_CONTROL_FILE="/sys/kernel/debug/dri/1/pstate" 29 | 30 | # Reported defaults from user reports 31 | # Actuals can always be found from /sys/kernel/debug/dri/1/pstate 32 | # 33 | # 07 is powersave 34 | # 0f is normal 35 | # AUTO is for set maximum 36 | 37 | BATT_NOUVEAU="07" 38 | LM_AC_NOUVEAU="0f" 39 | NOLM_AC_NOUVEAU="AUTO" 40 | 41 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/pcie-aspm.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module pcie-aspm 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # PCIe Activate State Power Management enable/disable switch 9 | # -------------------------------------------------------------------------- 10 | # 11 | #__COMMENT If you enable this setting, laptop mode tools will automatically configure 12 | #__COMMENT PCIe ASPM to save power while running on battery mode. 13 | #__COMMENT 14 | #__COMMENT This laptop mode module may require that the following kernel option is 15 | #__COMMENT enabled: 16 | #__COMMENT 17 | #__COMMENT pcie_aspm=force 18 | # 19 | ############################################################################### 20 | 21 | # Enable debug mode for this module 22 | # Set to 1 if you want to debug this module 23 | DEBUG=0 24 | 25 | # Control PCIe ASPM tunables? 26 | # Set to 0 to disable 27 | CONTROL_PCIE_ASPM="auto" 28 | 29 | # Policy of PCIe ASPM 30 | # Options: default performance powersave powersupersave 31 | BATT_PCIE_ASPM_POLICY="powersave" 32 | LM_AC_PCIE_ASPM_POLICY="default" 33 | NOLM_AC_PCIE_ASPM_POLICY="default" 34 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/video-out.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module video-out. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Video output control settings 10 | # ----------------------------- 11 | # 12 | #__COMMENT It is not always possible for video hardware to detect if displays are 13 | #__COMMENT actually connected to VGA out and/or TV out ports. However, an enabled video 14 | #__COMMENT output port draws power, even if no display is connected. This module allows 15 | #__COMMENT you to force display outputs off depending on the power mode. 16 | # 17 | ############################################################################### 18 | 19 | # Enable debug mode for this module 20 | # Set to 1 if you want to debug this module 21 | DEBUG=0 22 | 23 | # Control video output settings? 24 | CONTROL_VIDEO_OUTPUTS=0 25 | 26 | # Display types to disable in various modes. Run "xrandr" to check which outputs 27 | # are available. Make sure that you do not list your primary display here! 28 | BATT_DISABLE_VIDEO_OUTPUTS="TMDS VGA" 29 | LM_AC_DISABLE_VIDEO_OUTPUTS="TMDS VGA" 30 | NOLM_AC_DISABLE_VIDEO_OUTPUTS="" 31 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/terminal-blanking: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: virtual terminal blanking 4 | # 5 | 6 | # Set terminal blanking/powerdown timeouts 7 | if [ x$CONTROL_TERMINAL = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_TERMINAL = xauto ]; then 8 | if [ $ON_AC -eq 1 ]; then 9 | if [ "$ACTIVATE" -eq 1 ]; then 10 | BLANK_MINUTES="$LM_AC_TERMINAL_BLANK_MINUTES" 11 | POWERDOWN_MINUTES="$LM_AC_TERMINAL_POWERDOWN_MINUTES" 12 | else 13 | BLANK_MINUTES="$NOLM_AC_TERMINAL_BLANK_MINUTES" 14 | POWERDOWN_MINUTES="$NOLM_AC_TERMINAL_POWERDOWN_MINUTES" 15 | fi 16 | else 17 | BLANK_MINUTES="$BATT_TERMINAL_BLANK_MINUTES" 18 | POWERDOWN_MINUTES="$BATT_TERMINAL_POWERDOWN_MINUTES" 19 | fi 20 | log "VERBOSE" "Set terminal blanking timeout to $BLANK_MINUTES min, powerdown timeout to $POWERDOWN_MINUTES min." 21 | for THISTERMINAL in $TERMINALS ; do 22 | if [ -e $THISTERMINAL ] ; then 23 | log "VERBOSE" "Terminal $THISTERMINAL found, adjusting." 24 | TERM=linux setterm -blank "$BLANK_MINUTES" -powerdown "$POWERDOWN_MINUTES" > $THISTERMINAL 25 | else 26 | log "VERBOSE" "Terminal $THISTERMINAL does not exist." 27 | fi 28 | done 29 | else 30 | log "VERBOSE" "CONTROL_TERMINAL is disabled, skipping..." 31 | fi 32 | 33 | -------------------------------------------------------------------------------- /man/lm-syslog-setup.8: -------------------------------------------------------------------------------- 1 | .TH "LM-SYSLOG-SETUP" "8" 2 | .SH "NAME" 3 | .I /usr/sbin/lm-syslog-setup 4 | \- configure laptop mode tools to switch syslog.conf based on power state 5 | .SH "SYNOPSIS" 6 | .B /usr/sbin/lm-syslog-setup 7 | .SH "DESCRIPTION" 8 | This manual page documents briefly the 9 | .I /usr/sbin/lm-syslog-setup 10 | command. lm-syslog-setup was a command to set up the necessary things to enable 11 | laptop mode to switch between different configuration files 12 | based on the power state. This feature and this command has been deprecated 13 | in favor of the configuration-file-control module, which is configured in the 14 | .I /etc/laptop-mode/conf.d/configuration-file-control.conf 15 | configuration file. This new module does not require any manual setup. 16 | Existing configurations using the old feature are still supported, however, 17 | new usages of the old feature are not allowed, and lm-syslog-setup 18 | has been disabled accordingly. 19 | .SH "SEE ALSO" 20 | .PP 21 | laptop-mode.conf(8). 22 | .SH "AUTHOR" 23 | This manual page was written by Bart Samwel (bart@samwel.tk) 24 | Permission is granted to copy, distribute and/or modify this 25 | document under the terms of the GNU General Public License, Version 2 any 26 | later version published by the Free Software Foundation. 27 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/wireless-iwl-power.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module wireless-iwl-power. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # IWL Wireless Power settings 10 | # --------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically set 13 | #__COMMENT the powersave mode of Intel wireless adapters supported by the 14 | #__COMMENT iwlagn driver (including 4965, 5100, 5300, 5350, 5150, 1000, and 15 | #__COMMENT 6000). 16 | #__COMMENT 17 | #__COMMENT Please ensure proper Power Savings feature is enabled in your device 18 | #__COMMENT driver. 19 | # 20 | ############################################################################### 21 | 22 | # Enable debug mode for this module 23 | # Set to 1 if you want to debug this module 24 | DEBUG=0 25 | 26 | # Control Intel IWL wireless power? 27 | # Set to 0 to disable 28 | CONTROL_IWL_POWER="auto" 29 | 30 | # Levels passed to "/sys/class/net/*/device/power_level" for the iwlwifi 31 | # wireless chipsets. The allowed values are: 32 | # 0 = most power usage 33 | # ... 34 | # 5 = least power usage 35 | IWL_AC_POWER=0 36 | IWL_BATT_POWER=3 37 | 38 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/vgaswitcheroo.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module vgaswitcheroo 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # vgaswitcheroo control settings 10 | # ----------------------------- 11 | # 12 | #__COMMENT vga_switcheroo is the Linux subsystem for laptop hybrid graphics. 13 | #__COMMENT For hybrid graphics machines, the discrete graphics chip usually is 14 | #__COMMENT idle most of the time. 15 | #__COMMENT Enable this module to switch off the unused graphics card, when not in use 16 | #__COMMENT Note: You need to ensure debugfs is enabled/mounted on your system 17 | # 18 | ############################################################################### 19 | 20 | # Enable debug mode for this module 21 | # Set to 1 if you want to debug this module 22 | DEBUG=0 23 | 24 | # Control video output settings? 25 | CONTROL_VGASWITCHEROO=0 26 | 27 | # Modes of operation for Hybrid Graphics 28 | # The default settings will switch off discrete graphics, when on battery 29 | # and not in use 30 | BATT_ENABLE_VGASWITCHEROO=1 31 | LM_AC_ENABLE_VGASWITCHEROO=0 32 | NOLM_AC_ENABLE_VGASWITCHEROO=0 33 | VGASWITCHEROO_FILE="/sys/kernel/debug/vgaswitcheroo/switch" 34 | -------------------------------------------------------------------------------- /etc/apm/event.d/laptop-mode: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This file is part of laptop-mode-tools. 4 | # 5 | # Adaptation for laptop mode is Copyright (c) 2004 Bart Samwel 6 | # Copyright (c) 2000-2002 Massachusetts Institute of Technology 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or (at 11 | # your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | # General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 21 | # 02111-1307, USA. 22 | 23 | set -e 24 | 25 | LMODE=/lib/udev/lmt-udev 26 | 27 | [ -x "${LMODE}" ] || exit 0 28 | 29 | if [ "${1}" = "start" ]; then 30 | ${LMODE} auto 31 | elif [ "${1}" = "resume" ] && [ "${2}" != "standby" ]; then 32 | ${LMODE} auto 33 | elif [ "${1},${2}" = "change,power" ]; then 34 | ${LMODE} auto 35 | elif [ "${1}" = "stop" ]; then 36 | ${LMODE} stop 37 | 38 | fi 39 | exit 0 40 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/intel-hda-powersave.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module intel-hda-powersave. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Intel HDA power saving settings 10 | # ------------------------------- 11 | # 12 | #__COMMENT Enable this setting to save some power with your Intel HDA Audio Chipset 13 | #__COMMENT device. 14 | # 15 | ############################################################################### 16 | 17 | # Enable debug mode for this module 18 | # Set to 1 if you want to debug this module 19 | DEBUG=0 20 | 21 | # Control INTEL HDA audio chipset power? 22 | # Set to 0 to disable 23 | CONTROL_INTEL_HDA_POWER="auto" 24 | 25 | # Handle power savings for Intel HDA under specific circumstances 26 | BATT_INTEL_HDA_POWERSAVE=1 27 | LM_AC_INTEL_HDA_POWERSAVE=0 28 | NOLM_AC_INTEL_HDA_POWERSAVE=0 29 | 30 | # Number of seconds to wait before you want the device to time out 31 | INTEL_HDA_DEVICE_TIMEOUT=2 32 | 33 | # Disable controller on Device timeout 34 | # This saves more power 35 | # However you might want to disable this if you get annoyed by the 36 | # "click" sound when the device wakes up again 37 | # 38 | # Set this to 1 to enable power savings for the controller also 39 | INTEL_HDA_DEVICE_CONTROLLER=1 40 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/vgaswitcheroo: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: vgaswitcheroo for hybrid graphics 4 | # 5 | 6 | 7 | if [ x$CONTROL_VGASWITCHEROO = x1 ] ; then 8 | if [ $ON_AC -eq 1 ]; then 9 | if [ "$ACTIVATE" -eq 1 ]; then 10 | VGASWITCHEROO_TRIGGER="$LM_AC_ENABLE_VGASWITCHEROO" 11 | else 12 | VGASWITCHEROO_TRIGGER="$NOLM_AC_ENABLE_VGASWITCHEROO" 13 | fi 14 | else 15 | VGASWITCHEROO_TRIGGER="$BATT_ENABLE_VGASWITCHEROO" 16 | fi 17 | 18 | # Invert settings' values 19 | if [ $VGASWITCHEROO_TRIGGER -eq 0 ]; then 20 | VGASWITCHEROO_TRIGGER="ON" 21 | else 22 | VGASWITCHEROO_TRIGGER="OFF" 23 | fi 24 | 25 | if [ -f $VGASWITCHEROO_FILE ] ; then 26 | log "VERBOSE" "Found vgaswitcheroo interface $VGASWITCHEROO_FILE" 27 | log "VERBOSE" "Trigger vgaswitcheroo with value: $VGASWITCHEROO_TRIGGER" 28 | echo $VGASWITCHEROO_TRIGGER > $VGASWITCHEROO_FILE && \ 29 | log "VERBOSE" "Successfully triggered vgaswitcheroo with value: $VGASWITCHEROO_TRIGGER" || \ 30 | log "VERBOSE" "Failed to trigger vgaswitcheroo with value: $VGASWITCHEROO_TRIGGER" 31 | else 32 | log "VERBOSE" "Cannot find vgaswitcheroo inteface. Is debugfs enabled?" 33 | fi 34 | else 35 | log "VERBOSE" "vgaswitcheroo module is disabled" 36 | fi 37 | 38 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/kbd-backlight: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: control Keyboard Backlight 4 | # 5 | 6 | # Control Keyboard Backlight 7 | if [ x$CONTROL_KBDLIGHT = x1 ] ; then 8 | if [ $ON_AC -eq 1 ]; then 9 | if [ "$ACTIVATE" -eq 1 ]; then 10 | BRIGHTNESS_COMMAND="$LM_AC_KBDLIGHT_COMMAND" 11 | else 12 | BRIGHTNESS_COMMAND="$NOLM_AC_KBDLIGHT_COMMAND" 13 | fi 14 | else 15 | BRIGHTNESS_COMMAND="$BATT_KBDLIGHT_COMMAND" 16 | fi 17 | if [ -f /var/run/laptop-mode-tools/state-kbdlight-command ] ; then 18 | OLD_BRIGHTNESS_COMMAND="$( cat /var/run/laptop-mode-tools/state-kbdlight-command )" 19 | fi 20 | 21 | if [ "$FORCE" -ne 0 -o "$BRIGHTNESS_COMMAND" != "$OLD_BRIGHTNESS_COMMAND" ] ; then 22 | log "VERBOSE" "Set Keyboard Backlight using command $BRIGHTNESS_COMMAND \> $KBD_BRIGHTNESS_OUTPUT." 23 | if ( $BRIGHTNESS_COMMAND > $KBD_BRIGHTNESS_OUTPUT ) ; then 24 | log "VERBOSE" "Command succeeded." 25 | else 26 | log "ERR" "The configured Keyboard Backlight command of the kbd-backlight module failed." 27 | log "ERR" "Please check your configuration in /etc/laptop-mode/conf.d/kbd-backlight.conf." 28 | log "ERR" "Command failed." 29 | fi 30 | echo -n $BRIGHTNESS_COMMAND > /var/run/laptop-mode-tools/state-kbdlight-command 31 | else 32 | log "VERBOSE" "Not setting Keyboard Backlight -- command was the same as last time." 33 | fi 34 | fi 35 | 36 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/video-out: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: selectively disable video outputs 4 | # 5 | 6 | do_xrandr () { 7 | w -hs | while read -r USER TTY DISPLAY REMAINDER; do 8 | if [ "${DISPLAY#:}" != "$DISPLAY" ] ; then 9 | # It's an X display. 10 | if su $USER -c "xrandr --output $1 --$2" | grep -q display ; then 11 | log "VERBOSE" "Unable to set video output $1 to $2." 12 | else 13 | log "VERBOSE" "Set video output $1 to $2" 14 | fi 15 | fi 16 | done 17 | } 18 | 19 | if [ x$CONTROL_VIDEO_OUTPUTS = x1 ] ; then 20 | if [ $ON_AC -eq 1 ]; then 21 | if [ "$ACTIVATE" -eq 1 ]; then 22 | DISABLE_VIDEO_OUTPUTS="$LM_AC_DISABLE_VIDEO_OUTPUTS" 23 | else 24 | DISABLE_VIDEO_OUTPUTS="$NOLM_AC_DISABLE_VIDEO_OUTPUTS" 25 | fi 26 | else 27 | DISABLE_VIDEO_OUTPUTS="$BATT_DISABLE_VIDEO_OUTPUTS" 28 | fi 29 | 30 | if [ -f /var/run/laptop-mode-tools/disabled-video-outputs ] ; then 31 | cat /var/run/laptop-mode-tools/disabled-video-outputs | 32 | while read VIDEO_OUTPUT REMAINDER ; do 33 | do_xrandr $VIDEO_OUTPUT auto 34 | done 35 | fi 36 | 37 | rm -f /var/run/laptop-mode-tools/disabled-video-outputs 38 | 39 | for VIDEO_OUTPUT in $DISABLE_VIDEO_OUTPUTS ; do 40 | echo $VIDEO_OUTPUT >> /var/run/laptop-mode-tools/disabled-video-outputs 41 | 42 | do_xrandr $VIDEO_OUTPUT off 43 | done 44 | else 45 | log "VERBOSE" "video-out module is disabled." 46 | fi 47 | 48 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/hal-polling.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module hal-polling. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # HAL polling settings 10 | # -------------------- 11 | # 12 | #__COMMENT If you enable this module, laptop mode tools will control the polling of 13 | #__COMMENT your CD/DVD drives by HAL. Disabling polling saves a considerable amount of 14 | #__COMMENT power, but for some older CD/DVD drives it means that inserted CDs are no 15 | #__COMMENT longer autodetected. In such cases, you must turn this option off. 16 | #__COMMENT Alternatively, you can configure laptop mode tools to turn HAL polling on only 17 | #__COMMENT when the laptop is running on AC power. This would mean that CDs are not 18 | #__COMMENT autodetected while the laptop is running on battery power, but the power 19 | #__COMMENT savings may be worth the extra manual labour when you insert a CD. 20 | # 21 | ############################################################################### 22 | 23 | # Enable debug mode for this module 24 | # Set to 1 if you want to debug this module 25 | DEBUG=0 26 | 27 | # Control HAL polling? 28 | # Set to 0 to disable. 29 | CONTROL_HAL_POLLING="auto" 30 | 31 | # Disable HAL polling on battery? 32 | BATT_DISABLE_HAL_POLLING=1 33 | 34 | # Disable HAL polling on AC? 35 | AC_DISABLE_HAL_POLLING=0 36 | 37 | # Drives to apply HAL polling settings to 38 | HAL_POLLING_DEVICES="/dev/scd?" 39 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/intel_pstate: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module that handles Intel's PState driver 4 | # 5 | 6 | INTEL_PSTATE_SYSFS=/sys/devices/system/cpu/intel_pstate 7 | 8 | # Set intel_pstate sysfs parameter 9 | # Parameter 1: parameter name 10 | # Parameter 2: the value 11 | set_intel_pstate_param () { 12 | if [ -f "$INTEL_PSTATE_SYSFS/$1" ]; then 13 | log "VERBOSE" "Executing: echo $2 > $INTEL_PSTATE_SYSFS/$1" 14 | if ! echo "$2" > "$INTEL_PSTATE_SYSFS/$1" ; then 15 | echo "SETTING OF KERNEL PARAMETER FAILED: echo $2 \> $INTEL_PSTATE_SYSFS/$1" 16 | fi 17 | fi 18 | } 19 | 20 | if [ x$CONTROL_INTEL_PSTATE = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_INTEL_PSTATE = xauto ]; then 21 | if [ $ON_AC -eq 1 ] ; then 22 | if [ "$ACTIVATE" -eq 1 ] ; then 23 | INTEL_PSTATE_PERF_MIN_PCT="$LM_AC_INTEL_PSTATE_PERF_MIN_PCT" 24 | INTEL_PSTATE_PERF_MAX_PCT="$LM_AC_INTEL_PSTATE_PERF_MAX_PCT" 25 | INTEL_PSTATE_NO_TURBO="$LM_AC_INTEL_PSTATE_NO_TURBO" 26 | else 27 | INTEL_PSTATE_PERF_MIN_PCT="$NOLM_AC_INTEL_PSTATE_PERF_MIN_PCT" 28 | INTEL_PSTATE_PERF_MAX_PCT="$NOLM_AC_INTEL_PSTATE_PERF_MAX_PCT" 29 | INTEL_PSTATE_NO_TURBO="$NOLM_AC_INTEL_PSTATE_NO_TURBO" 30 | fi 31 | else 32 | INTEL_PSTATE_PERF_MIN_PCT="$BATT_INTEL_PSTATE_PERF_MIN_PCT" 33 | INTEL_PSTATE_PERF_MAX_PCT="$BATT_INTEL_PSTATE_PERF_MAX_PCT" 34 | INTEL_PSTATE_NO_TURBO="$BATT_INTEL_PSTATE_NO_TURBO" 35 | fi 36 | set_intel_pstate_param max_perf_pct "$INTEL_PSTATE_PERF_MAX_PCT" 37 | set_intel_pstate_param min_perf_pct "$INTEL_PSTATE_PERF_MIN_PCT" 38 | set_intel_pstate_param no_turbo "$INTEL_PSTATE_NO_TURBO" 39 | fi 40 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/intel-sata-powermgmt.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module intel-sata-powermgmt. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Intel SATA power management settings 10 | # ------------------------------------ 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically enable the 13 | #__COMMENT link power management mode of Intel AHCI compliant SATA chipsets. 14 | #__COMMENT On newer kernels (4.6+), it can also help enable AHCI Runtime PM savings 15 | # 16 | ############################################################################### 17 | 18 | # Enable debug mode for this module 19 | # Set to 1 if you want to debug this module 20 | DEBUG=0 21 | 22 | # Control Intel SATA chipset power management? 23 | # Set to 0 to disable 24 | CONTROL_INTEL_SATA_POWER="auto" 25 | 26 | 27 | # Enable AHCI Runtime PM 28 | # This feature was added with Linux kernels 4.6+ 29 | CONTROL_AHCI_RUNTIME_PM=1 30 | 31 | # Handle power management of the Intel SATA host controller under specific 32 | # circumstances. Legal values are "min_power" (maximum power saving at the 33 | # expense of higher latencies), "medium_power" (reduce latencies to a minimum 34 | # while still trying to enable power-saving features), "max_performance" (power 35 | # management is disabled). Note that setting any level besides 36 | # "max_performance" also disables device hotplug. 37 | BATT_SATA_POLICY=med_power_with_dipm 38 | LM_AC_SATA_POLICY=max_performance 39 | NOLM_AC_SATA_POLICY=max_performance 40 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/cpuhotplug.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module cpuhotplug. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # CPU Hot Plugging 9 | # ---------------- 10 | # 11 | #__COMMENT Laptop mode tools can automatically switch off multiple CPU cores 12 | #__COMMENT when switching to battery. 13 | #__COMMENT This can be very useful if your use does not involve CPU intensive 14 | #__COMMENT tasks, while on battery 15 | #__COMMENT 16 | #__COMMENT IMPORTANT: This feature may break Linux Software Suspend 17 | #__COMMENT 18 | #__COMMENT Enalbe it only if you understand what you are doing 19 | # 20 | ############################################################################### 21 | 22 | # Enable debug mode for this module 23 | # Set to 1 if you want to debug this module 24 | DEBUG=0 25 | 26 | # 27 | # Should laptop mode tools control the CPU Hot Plugging functionality? 28 | # 29 | # Set to 0 to disable 30 | CONTROL_CPU_HOTPLUG=0 31 | 32 | # 33 | # How many cores to disable. This setting defines how many CPU cores should be 34 | # disabled. 35 | # 36 | # Possible values are: 37 | # half -> disable half of available logical CPUs 38 | # quarter -> disable 1/4 of available logical CPUs 39 | # 3quarter -> disable 3/4 of available logical CPUs 40 | # 41 | # integer -> Set this to a user specific number 42 | # list of cpu-s -> Disable specific CPUs. Example: "cpu1 cpu3" 43 | # 44 | DISABLE_AVAILABLE_CPU="half" 45 | 46 | # Conditions under which to enable CPU Hot Plugging, i.e. shutdown of the CPU 47 | BATT_CPU_HOTPLUG=1 48 | LM_AC_CPU_HOTPLUG=0 49 | NOLM_AC_CPU_HOTPLUG=0 50 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/bluetooth: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: bluetooth 4 | # 5 | 6 | if [ x$CONTROL_BLUETOOTH = x1 ] ; then 7 | 8 | ENABLE_BLUETOOTH=$BATT_ENABLE_BLUETOOTH 9 | if [ $ON_AC -eq 1 ] ; then 10 | ENABLE_BLUETOOTH=$AC_ENABLE_BLUETOOTH 11 | fi 12 | 13 | RFKILL=`which rfkill`; 14 | 15 | if [ x$ENABLE_BLUETOOTH = x1 ] ; then 16 | log "VERBOSE" "Enabling bluetooth." 17 | 18 | if [ -x $RFKILL ]; then 19 | log "VERBOSE" "Soft un-blocking bluetooth using rfkill interface" 20 | $RFKILL unblock bluetooth 21 | elif [ -f /proc/acpi/ibm/bluetooth ]; then 22 | # For thinkpads, where the thinkpad_acpi driver is loaded, 23 | # we can handle bluetooth easily 24 | log "VERBOSE" "Enabling ThinkPad Bluetooth device" 25 | echo "enable" > /proc/acpi/ibm/bluetooth 26 | else 27 | for INTF in $BLUETOOTH_INTERFACES ; do 28 | [ -d /sys/class/bluetooth/$INTF ] || continue 29 | log "VERBOSE" "`hciconfig $INTF up 2>&1`" 30 | done 31 | fi 32 | else 33 | log "VERBOSE" "Disabling bluetooth." 34 | 35 | if [ -x $RFKILL ]; then 36 | log "VERBOSE" "Soft blocking bluetooth using rfkill interface" 37 | $RFKILL block bluetooth 38 | elif [ -f /proc/acpi/ibm/bluetooth ]; then 39 | log "VERBOSE" "Disabling ThinkPad Bluetooth device" 40 | echo "disable" > /proc/acpi/ibm/bluetooth 41 | else 42 | for INTF in $BLUETOOTH_INTERFACES ; do 43 | [ -d /sys/class/bluetooth/$INTF ] || continue 44 | log "VERBOSE" "`hciconfig $INTF down 2>&1`" 45 | done 46 | fi 47 | fi 48 | fi 49 | 50 | -------------------------------------------------------------------------------- /etc/laptop-mode/lm-profiler.conf: -------------------------------------------------------------------------------- 1 | # Configuration for lm-profiler, the Laptop Mode Tools profiler. 2 | # 3 | # For boolean (true/false) values, use 0 for false and 1 for true. 4 | 5 | # Set this option to enable verbose output. 6 | VERBOSE_OUTPUT=0 7 | 8 | # Length, in seconds, of a profiling run. 9 | PROFILE_RUN_LENGTH=600 10 | 11 | # This option sets up a threshold for wanting to disable programs when 12 | # laptop mode is active. If a program writes performs two writes to disk 13 | # with MINIMUM_ACTIVITY_SPREAD seconds between them, within an interval 14 | # of MINIMUM_ACTIVITY_INTERVAL seconds, then we have a program that performs 15 | # regular, non-bursty disk activity, and we want to recommend that that 16 | # program be disabled. 17 | ACTIVITY_INTERVAL_MIN=5 18 | ACTIVITY_INTERVAL_MAX=150 19 | 20 | # Should lm-profiler recommend stopping default services, even if they 21 | # do not qualify according to the profiling criteria? 22 | RECOMMEND_DEFAULT_SERVICES=1 23 | 24 | # And which default services are those? 25 | DEFAULT_SERVICES="anacron cron atd" 26 | 27 | # Which programs should be ignored in the disk access profile? Separete the 28 | # programs by spaces. Any programs whose names contain strings listed here willo 29 | # be ignored. 30 | IGNORE_PROGRAMS="$DEF_IGNORE_PROGRAMS myprogram1 myprogram2" 31 | 32 | 33 | # Should lm-profiler detect running network services? 34 | # When enabled, lm-profiler will report runing network services that 35 | # listen on external addresses, and it will recommend them for disabling. 36 | RECOMMEND_NETWORK_SERVICES=1 37 | 38 | # List network services here that you would like to ignore. Separate them 39 | # by spaces. 40 | IGNORE_NETWORK_SERVICES="$DEF_IGNORE_NETWORK_SERVICES myservice1 myservice2" 41 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/intel_pstate.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module intel_pstate. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # Control Intel PState CPU frequency scaling driver 9 | # ------------------------------------------------- 10 | # 11 | #__COMMENT Laptop mode tools can automatically adjust your kernel CPU frequency 12 | #__COMMENT settings. This module handles Intel PState driver, that is somewhat 13 | #__COMMENT different from other cpufreq drivers. 14 | #__COMMENT 15 | #__COMMENT This feature is present only on kernels 3.9 and later. 16 | # 17 | ############################################################################### 18 | 19 | # Enable debug mode for this module 20 | # Set to 1 if you want to debug this module 21 | DEBUG=0 22 | 23 | # 24 | # Should laptop mode tools control the CPU frequency settings? 25 | # 26 | # Set to 0 to disable 27 | CONTROL_INTEL_PSTATE="auto" 28 | 29 | #On AC, Laptop Mode Tools inactive 30 | NOLM_AC_INTEL_PSTATE_PERF_MIN_PCT=0 # Minimum performance, in percent 31 | NOLM_AC_INTEL_PSTATE_PERF_MAX_PCT=100 # Maximum performance, in percent 32 | NOLM_AC_INTEL_PSTATE_NO_TURBO=0 # Disable "Turbo Boost"? 33 | 34 | #On AC, Laptop Mode Tools active 35 | LM_AC_INTEL_PSTATE_PERF_MIN_PCT=0 # Minimum performance, in percent 36 | LM_AC_INTEL_PSTATE_PERF_MAX_PCT=100 # Maximum performance, in percent 37 | LM_AC_INTEL_PSTATE_NO_TURBO=0 # Disable "Turbo Boost"? 38 | 39 | #On battery 40 | BATT_INTEL_PSTATE_PERF_MIN_PCT=0 # Minimum performance, in percent 41 | BATT_INTEL_PSTATE_PERF_MAX_PCT=100 # Maximum performance, in percent 42 | BATT_INTEL_PSTATE_NO_TURBO=0 # Disable "Turbo Boost"? 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Laptop Mode Tools README 2 | ------------------------ 3 | 4 | Author: Bart Samwel ([bart@samwel.tk](mailto:bart@samwel.tk), ) 5 | Maintainer: Ritesh Raj Sarraf ([rrs@researchut.com](mailto:rrs@researchut.com), ) 6 | 7 | 8 | Developers 9 | ---------- 10 | 11 | All upstream development is done in the lmt-upstream branch. 12 | Please base your changes against the lmt-upstream branch 13 | 14 | 15 | Installation 16 | ------------ 17 | 18 | To install, run `./install.sh`. That's all there's to it. 19 | This will install laptop mode, which will be enabled automatically 20 | when your laptop works on batteries. 21 | 22 | Debian users, please install the Debian package that can 23 | be found in the Debian Package repository at 24 | 25 | 26 | Notes 27 | ----- 28 | 29 | * To configure the laptop mode scripts, edit `/etc/laptop-mode/laptop-mode.conf`. 30 | 31 | * The laptop mode FAQ can be found at 32 | 33 | * The revision history is included in the `Documentation` directory. 34 | 35 | * The original laptop mode documentation that was distributed with the Linux 36 | kernel is included in this package as `Documentation/laptop-mode.txt`. It 37 | contains some documentation on the internals of laptop mode, and some tips 38 | and tricks. Note that some of the tips are outdated and superseded by FAQ 39 | questions. 40 | 41 | GUI Configuration Tool 42 | ---------------------- 43 | ![lmt-config-gui](https://github.com/rickysarraf/__pr0n/raw/master/LMT%20GUI.png) 44 | 45 | References 46 | ---------- 47 | 48 | The laptop mode tools website: 49 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/hal-polling: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: change HAL polling mode 4 | # 5 | 6 | # Some backward compatibility for version 1.42 7 | if [ ! x$BATT_ENABLE_HAL_POLLING = x ] ; then 8 | if [ x$BATT_ENABLE_HAL_POLLING = x1 ] ; then 9 | BATT_DISABLE_HAL_POLLING=0 10 | else 11 | BATT_DISABLE_HAL_POLLING=1 12 | fi 13 | fi 14 | 15 | if [ ! x$AC_ENABLE_HAL_POLLING = x ] ; then 16 | if [ x$AC_ENABLE_HAL_POLLING = x1 ] ; then 17 | AC_DISABLE_HAL_POLLING=0 18 | else 19 | AC_DISABLE_HAL_POLLING=1 20 | fi 21 | fi 22 | 23 | 24 | if [ x$CONTROL_HAL_POLLING = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_HAL_POLLING = xauto ]; then 25 | DISABLE_HAL_POLLING=$BATT_DISABLE_HAL_POLLING 26 | if [ $ON_AC -eq 1 ] ; then 27 | DISABLE_HAL_POLLING=$AC_DISABLE_HAL_POLLING 28 | fi 29 | if [ x$DISABLE_HAL_POLLING = x1 ] ; then 30 | DISABLE_HAL_POLLING_CMD="hal-disable-polling --device" 31 | else 32 | DISABLE_HAL_POLLING_CMD="hal-disable-polling --enable-polling --device" 33 | fi 34 | 35 | for DEV in $HAL_POLLING_DEVICES ; do 36 | # Thanks to the kernel's new in-kernel block dev polling. 37 | device=`realpath $DEV | awk -v FS="/" '{print $NF}'`; 38 | 39 | if [ -f /sys/block/$device/events_poll_msecs ]; then 40 | if [ x$DISABLE_HAL_POLLING = x1 ]; then 41 | echo 0 > /sys/block/$device/events_poll_msecs; 42 | log "VERBOSE" "Set polling to 0 for device /sys/block/$device/events_poll_msecs" 43 | else 44 | echo "-1" > /sys/block/$device/events_poll_msecs; 45 | log "VERBOSE" "Set polling to -1 i.e. System Default, for device /sys/block/$device/events_poll_msecs" 46 | fi 47 | else 48 | if [ -b "$DEV" ] ; then 49 | $DISABLE_HAL_POLLING_CMD "$DEV" 50 | log "VERBOSE" "Executing command $DISABLE_HAL_POLLING_CMD on device $DEV" 51 | fi 52 | fi 53 | done 54 | fi 55 | 56 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/terminal-blanking.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module terminal-blanking. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # Terminal settings 9 | # ----------------- 10 | # 11 | #__COMMENT Using these settings, you can let laptop mode tools control the terminal 12 | #__COMMENT blanking timeouts. This only works for linux virtual consoles. 13 | #__COMMENT 14 | #__COMMENT 15 | #__COMMENT IMPORTANT: In versions 1.36 and earlier, these settings were included in the 16 | #__COMMENT main laptop-mode.conf configuration file. If they are still present, they 17 | #__COMMENT overrule the settings in this file. To fix this, simply delete the settings 18 | #__COMMENT from the main config file. 19 | # 20 | ############################################################################### 21 | 22 | # Enable debug mode for this module 23 | # Set to 1 if you want to debug this module 24 | DEBUG=0 25 | 26 | # 27 | # Should laptop mode tools control terminal blanking settings? 28 | # 29 | # Set to 0 to disable 30 | CONTROL_TERMINAL="auto" 31 | 32 | 33 | # 34 | # Terminal device files that should be affected. (One terminal is enough, this 35 | # affects all consoles. ) 36 | # 37 | TERMINALS="/dev/tty1" 38 | 39 | 40 | # 41 | # These settings specify the blanking and powerdown timeouts. Note that 42 | # the powerdown timeout is counted from the moment the screen is blanked, 43 | # i.e. BLANK_MINUTES=2 and POWERDOWN_MINUTES=5 means the screen powers 44 | # down after 7 minutes of inactivity. The range for all these settings is 45 | # 1 to 60 minutes, or 0 to disable. 46 | # 47 | BATT_TERMINAL_BLANK_MINUTES=1 48 | BATT_TERMINAL_POWERDOWN_MINUTES=2 49 | LM_AC_TERMINAL_BLANK_MINUTES=10 50 | LM_AC_TERMINAL_POWERDOWN_MINUTES=10 51 | NOLM_AC_TERMINAL_BLANK_MINUTES=10 52 | NOLM_AC_TERMINAL_POWERDOWN_MINUTES=50 53 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/dpms-standby.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module dpms-standby. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # X display settings 9 | # ------------------ 10 | # 11 | #__COMMENT Using these settings, you can let laptop mode tools control the X display 12 | #__COMMENT standby timeouts. 13 | #__COMMENT 14 | #__COMMENT This requires that you have installed the "xset" utility. It is part of the 15 | #__COMMENT X.org server distribution and included in the package xorg-server-utils. 16 | #__COMMENT 17 | #__COMMENT The X settings are not automatically applied on login, and this is 18 | #__COMMENT impossible fix for the user, since laptop mode tools must operate as root. 19 | #__COMMENT The laptop-mode.conf(8) manual page section on the CONTROL_DPMS_STANDBY 20 | #__COMMENT setting describes a workaround for this limitation. 21 | #__COMMENT 22 | #__COMMENT 23 | #__COMMENT IMPORTANT: In versions 1.36 and earlier, these settings were included in the 24 | #__COMMENT main laptop-mode.conf configuration file. If they are still present, they 25 | #__COMMENT overrule the settings in this file. To fix this, simply delete the settings 26 | #__COMMENT from the main config file. 27 | # 28 | ############################################################################### 29 | 30 | # Enable debug mode for this module 31 | # Set to 1 if you want to debug this module 32 | DEBUG=0 33 | 34 | # 35 | # Should laptop mode tools control DPMS standby settings for X displays? 36 | # 37 | # Set to 0 to disable 38 | CONTROL_DPMS_STANDBY="auto" 39 | 40 | 41 | # 42 | # These settings specify the standby timeout for the X display, 43 | # in seconds. The suspend and poweroff timeouts are somewhat 44 | # larger values derived from these values. 45 | # 46 | BATT_DPMS_STANDBY=300 47 | LM_AC_DPMS_STANDBY=1200 48 | NOLM_AC_DPMS_STANDBY=1200 49 | -------------------------------------------------------------------------------- /etc/rules/lmt-udev: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | 4 | # /usr is not guaranteed to be mounted when udev starts 5 | non_systemd_way() { 6 | if [ -e /lib/udev/hotplug.functions ]; then 7 | . /lib/udev/hotplug.functions 8 | wait_for_file /usr/sbin/laptop_mode 9 | exec /usr/sbin/laptop_mode "$@" 10 | else 11 | file=$1 12 | timeout=$2 13 | [ "$timeout" ] || timeout=120 14 | 15 | count=$timeout 16 | while [ $count != 0 ]; do 17 | [ -e "/usr/sbin/laptop_mode" ] && exec /usr/sbin/laptop_mode "$@" && return 0 18 | sleep 1 19 | count=$(($count - 1)) 20 | done 21 | 22 | mesg "$file did not appear before the timeout!" 23 | exit 1 24 | fi 25 | } 26 | 27 | 28 | ## For Debug only 29 | #export LMT_DEBUG="/tmp/__lmt__debug.txt" 30 | [ -z $LMT_DEBUG ] || rm -f $LMT_DEBUG 31 | ## 32 | 33 | # Under systemd, we don't do synchronous operations, so we can run in the foreground; 34 | # And we need also need to run in foreground, because forked children get kill immediately 35 | # under systemd/udev 36 | 37 | # The seconds "auto" evaluation is to determine if it is a standard execution; 38 | # i.e. a reload/restart or a device plug/unplug 39 | 40 | if [ -d /run/systemd/system ] && [ x$1 = xauto ]; then 41 | [ -z $LMT_DEBUG ] || echo "systemd is $PPID $$ $@" > $LMT_DEBUG 42 | exec systemctl --no-block reload-or-restart laptop-mode 43 | else 44 | # Under sysvinit/upstart, we need to fork as we start the long-running 45 | # /usr/sbin/laptop_mode process. 46 | # 47 | # Also, if this happens during boot, we may want to wait until /usr is available 48 | # 49 | # On newer systemd/udev (232-3 over here), the behavior has changed in my tests. 50 | # Now, it'll immediately and quietly kill the process that is backgrounded 51 | # systemd is nice, but I hate when it tries to become a magician 52 | # 53 | # This stanza will also be called for device plug/unplug events 54 | 55 | [ -z $LMT_DEBUG ] || echo "regulard is $PPID $$ $@" > $LMT_DEBUG 56 | exec > /dev/null 2>/dev/null 57 | non_systemd_way "$@" 58 | fi 59 | 60 | exit 0 61 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/auto-hibernate.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module auto-hibernate. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # Auto-hibernation settings 9 | # ------------------------- 10 | # 11 | #__COMMENT Using these settings, you can make laptop mode tools automatically put your 12 | #__COMMENT computer into hibernation when the battery level goes critically low. 13 | #__COMMENT 14 | #__COMMENT This feature only works on ACPI, and only works on computers whose batteries 15 | #__COMMENT give off battery events often enough. 16 | #__COMMENT 17 | #__COMMENT NOTE: If your battery does NOT give off battery events often enough, you can 18 | #__COMMENT enable the battery-level-polling module to make this work after all. See 19 | #__COMMENT battery-level-polling.conf for more information. 20 | #__COMMENT 21 | #__COMMENT 22 | #__COMMENT IMPORTANT: In versions 1.36 and earlier, these settings were included in the 23 | #__COMMENT main laptop-mode.conf configuration file. If they are still present, they 24 | #__COMMENT overrule the settings in this file. To fix this, simply delete the settings 25 | #__COMMENT from the main config file. 26 | # 27 | ############################################################################### 28 | 29 | # Enable debug mode for this module 30 | # Set to 1 if you want to debug this module 31 | DEBUG=0 32 | 33 | # 34 | # Should laptop mode tools perform auto-hibernation? 35 | # 36 | ENABLE_AUTO_HIBERNATION=0 37 | 38 | 39 | # 40 | # The hibernation command that is to be executed when auto-hibernation 41 | # is triggered. 42 | # 43 | HIBERNATE_COMMAND=/usr/share/laptop-mode-tools/module-helpers/pm-hibernate 44 | 45 | 46 | # 47 | # Auto-hibernation battery level threshold, in percentage of the battery's 48 | # total design capacity. 49 | # 50 | AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT=4 51 | 52 | 53 | # 54 | # Enable this to auto-hibernate if the battery reports that its level is 55 | # "critical". 56 | # 57 | AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL=1 58 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/syslog-conf: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: syslog.conf switching functionality (DEPRECATED) 4 | # 5 | # 6 | # This module implements the old syslog.conf functionality -- deprecated but 7 | # still supported for backward compatibility. 8 | # 9 | 10 | if [ x$CONTROL_SYSLOG_CONF = x1 ] ; then 11 | log "VERBOSE" "Adjusting syslog configuration." 12 | if [ "`readlink -f $SYSLOG_CONF`" != "$SYSLOG_CONF" ] ; then 13 | log "MSG" "$SYSLOG_CONF is a symlink." 14 | if [ ! -f "$SYSLOG_CONF.no-lm" ] ; then 15 | log "VERBOSE" "But there is no $SYSLOG_CONF.no-lm. This must have been done by an earlier" 16 | log "VERBOSE" "version of laptop-mode-tools." 17 | log "VERBOSE" "Creating it now from $NOLM_AC_SYSLOG_CONF." 18 | cp "$NOLM_AC_SYSLOG_CONF" "$SYSLOG_CONF.no-lm" 19 | fi 20 | else 21 | log "VERBOSE" "$SYSLOG_CONF is not a symlink." 22 | if [ "$STATE" = "enabled" ] ; then 23 | log "VERBOSE" "Saving it to $SYSLOG_CONF.no-lm." 24 | cp --backup=numbered "$SYSLOG_CONF" "$SYSLOG_CONF.no-lm" 25 | fi 26 | fi 27 | 28 | if [ "$STATE" != "enabled" ] ; then 29 | log "VERBOSE" "Laptop mode is not enabled. Restoring $SYSLOG_CONF." 30 | if [ -f "$SYSLOG_CONF.no-lm" ] ; then 31 | mv "$SYSLOG_CONF.no-lm" "$SYSLOG_CONF" 32 | elif [ "`readlink -f $SYSLOG_CONF`" != "$SYSLOG_CONF" ] ; then 33 | echo "ERROR: $SYSLOG_CONF is a symlink but $SYSLOG_CONF.no-lm is not present." 34 | fi 35 | elif [ $ON_AC -eq 1 ] ; then 36 | if [ "$ACTIVATE" -eq 1 ] ; then 37 | log "VERBOSE" "Setting syslog config to $LM_AC_SYSLOG_CONF." 38 | ln -fs "$LM_AC_SYSLOG_CONF" "$SYSLOG_CONF" 39 | else 40 | log "VERBOSE" "Setting syslog config to $NOLM_AC_SYSLOG_CONF." 41 | ln -fs "$NOLM_AC_SYSLOG_CONF" "$SYSLOG_CONF" 42 | fi 43 | else 44 | log "VERBOSE" "Setting syslog config to $BATT_SYSLOG_CONF." 45 | ln -fs "$BATT_SYSLOG_CONF" "$SYSLOG_CONF" 46 | fi 47 | # Notify syslogd of configuration change. 48 | if [ "$SYSLOG_CONF_SIGNAL_PROGRAM" != "" ] ; then 49 | log "VERBOSE" "Sending SIGHUP to all $SYSLOG_CONF_SIGNAL_PROGRAM processes." 50 | killall -q -HUP $SYSLOG_CONF_SIGNAL_PROGRAM 51 | fi 52 | fi 53 | 54 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/intel-hda-powersave: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: Intel HDA integrated audio power saving mode. 4 | # 5 | 6 | if [ x$CONTROL_INTEL_HDA_POWER = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_INTEL_HDA_POWER = xauto ]; then 7 | if [ $ON_AC -eq 1 ]; then 8 | if [ "$ACTIVATE" -eq 1 ]; then 9 | INTEL_HDA_POWERSAVE="$LM_AC_INTEL_HDA_POWERSAVE" 10 | else 11 | INTEL_HDA_POWERSAVE="$NOLM_AC_INTEL_HDA_POWERSAVE" 12 | fi 13 | else 14 | INTEL_HDA_POWERSAVE="$BATT_INTEL_HDA_POWERSAVE" 15 | fi 16 | 17 | # Handle Intel HDA Power Save 18 | if [ -w /sys/module/snd_hda_intel/parameters/power_save ]; then 19 | if [ x$INTEL_HDA_POWERSAVE = x1 ]; then 20 | echo $INTEL_HDA_DEVICE_TIMEOUT > /sys/module/snd_hda_intel/parameters/power_save 21 | log "VERBOSE" "Intel HDA power save mode enabled with timeout $INTEL_HDA_DEVICE_TIMEOUT." 22 | if [ -c /dev/dsp ]; then 23 | # This can fail if the audio device is busy. 24 | # Since this failure is non-fatal (worst case is that the timer changes 25 | # don't get activated), we don't bother if it was successful or not 26 | #(exec 2>/dev/null; echo 1 > /dev/dsp;) 27 | # Better way 28 | echo 1 2>/dev/null >/dev/dsp 29 | log "VERBOSE" "Initialize timer change by close/open /dev/dsp" 30 | fi 31 | else 32 | echo 0 > /sys/module/snd_hda_intel/parameters/power_save 33 | log "VERBOSE" "Intel HDA power save mode disabled." 34 | fi 35 | else 36 | log "VERBOSE" "Intel HDA power saving is not available on this system." 37 | fi 38 | 39 | # Handle Intel HDA Controller Power Savings. 40 | if [ x$INTEL_HDA_DEVICE_CONTROLLER = x1 -a x$INTEL_HDA_POWERSAVE = x1 ]; then 41 | POWER_SAVE="Y" 42 | else 43 | POWER_SAVE="N" 44 | fi 45 | 46 | if [ -w /sys/module/snd_hda_intel/parameters/power_save_controller ]; then 47 | echo $POWER_SAVE > /sys/module/snd_hda_intel/parameters/power_save_controller 48 | log "VERBOSE" "Intel HDA Controller power save set to $POWER_SAVE." 49 | else 50 | log "VERBOSE" "Sound Card doesn't seem to support Controller Power Save." 51 | fi 52 | else 53 | log "VERBOSE" "Intel HDA audio power setting is disabled." 54 | fi 55 | 56 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/kbd-backlight.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module kbd-backlight 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Keyboard Backlight settings 10 | # --------------------------- 11 | # 12 | #__COMMENT Using these settings, you can make laptop mode tools automatically adjust 13 | #__COMMENT your keyboard's backlight settings, if your driver supports it. The settings 14 | #__COMMENT are extremely simple -- they 15 | #__COMMENT only allow for the execution of a command, nothing more. The reason for this 16 | #__COMMENT is that keyboard backlight settings are very different between laptop vendors. 17 | #__COMMENT 18 | #__COMMENT Suggestions for commands: 19 | #__COMMENT 20 | #__COMMENT * If your system has the directory "/sys/class/leds/smc::kbd_backlight/" 21 | #__COMMENT (or something similar), use this file as BRIGHTNESS_OUTPUT, and use 22 | #__COMMENT the command "echo ". 23 | #__COMMENT 24 | #__COMMENT * If you have a file /sys/class/backlight/.../brightness, then you can use 25 | #__COMMENT that file as BRIGHTNESS_OUTPUT, and the command "echo ". 26 | #__COMMENT 27 | #__COMMENT As far as I understand it the values are between 0 and 28 | #__COMMENT the value contained in the file /sys/class/backlight/.../max_brightness. 29 | #__COMMENT 30 | #__COMMENT * For Toshiba laptops, use the command "toshset" with the -lcd or -inten 31 | #__COMMENT command. Read the toshset(1) manual page for more information on the 32 | #__COMMENT parameters for this command. If you use this command, set 33 | #__COMMENT BRIGHTNESS_OUTPUT to "/dev/null". 34 | #__COMMENT 35 | #__COMMENT * For ThinkPad laptops, use the tp-smapi kernel module and then look 36 | #__COMMENT for the equivalent under /proc/acpi 37 | # 38 | ############################################################################### 39 | 40 | # Enable debug mode for this module 41 | # Set to 1 if you want to debug this module 42 | DEBUG=0 43 | 44 | # 45 | # Should laptop mode tools control Keyboard Backlight? 46 | # 47 | CONTROL_KBDLIGHT=0 48 | 49 | 50 | # 51 | # Commands to execute to set the brightness on your Keyboard Backlight 52 | # 53 | BATT_KBDLIGHT_COMMAND="echo [value]" 54 | LM_AC_KBDLIGHT_COMMAND="echo [value]" 55 | NOLM_AC_KBDLIGHT_COMMAND="echo [value]" 56 | KBD_BRIGHTNESS_OUTPUT="/sys/class/leds/smc::kbd_backlight/brightness" 57 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/cpuhotplug: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module to handle CPU Hot Plugging 4 | # 5 | 6 | 7 | # Determine number cpu cores on machine 8 | max_available_cpus() { 9 | CPU=/sys/devices/system/cpu/present 10 | if [ -f $CPU ]; then 11 | max_cpu=$(cat $CPU | cut -d '-' -f2) 12 | max_cpu=$(expr $max_cpu + 1) 13 | echo $max_cpu 14 | else 15 | echo -1 16 | fi 17 | } 18 | 19 | # Get a list of cpus to control from a number of cpus that user wants to 20 | # disable. 21 | get_cpus_from_number() { 22 | counter=0 23 | cpu_list= 24 | 25 | for cpu in /sys/devices/system/cpu/cpu[0-9]* ; do 26 | if [ $counter -le $1 ]; then 27 | counter=$(expr $counter + 1) 28 | else 29 | break 30 | fi 31 | 32 | cpu_list="$cpu_list $cpu" 33 | done 34 | } 35 | 36 | # Get a list of cpus from a list of cpu ids. Where each id is of the form 37 | # cpu. 38 | get_cpus_from_ids() { 39 | cpu_list= 40 | 41 | for cpu_id in $1 ; do 42 | cpu_path="/sys/devices/system/cpu/$cpu_id" 43 | if [ -d "$cpu_path" ] ; then 44 | cpu_list="$cpu_list $cpu_path" 45 | fi 46 | done 47 | } 48 | 49 | # Get a list of cpus to control from DISABLE_AVAILABLE_CPU value. 50 | get_cpus_to_control() { 51 | num_cpu=`max_available_cpus` 52 | 53 | case "$1" in 54 | "quarter") 55 | get_cpus_from_number $((num_cpu * 1/4)) 56 | ;; 57 | "half") 58 | get_cpus_from_number $((num_cpu * 1/2)) 59 | ;; 60 | "3quarter") 61 | get_cpus_from_number $((num_cpu * 3/4)) 62 | ;; 63 | [0-9]*) 64 | get_cpus_from_number $1 65 | ;; 66 | cpu*) 67 | get_cpus_from_ids "$1" 68 | ;; 69 | esac 70 | } 71 | 72 | 73 | if [ x$CONTROL_CPU_HOTPLUG = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_CPU_HOTPLUG = xauto ]; then 74 | if [ $ON_AC -eq 1 ] ; then 75 | if [ "$ACTIVATE" -eq 1 ] ; then 76 | ECHO_VAL="$LM_AC_CPU_HOTPLUG" 77 | else 78 | ECHO_VAL="$NOLM_AC_CPU_HOTPLUG" 79 | fi 80 | else 81 | ECHO_VAL="$BATT_CPU_HOTPLUG" 82 | fi 83 | 84 | # To disable the CPU, write 0. So flip it here. 85 | if [ x$ECHO_VAL = x1 ]; then 86 | CPU_VAL=0 87 | else 88 | CPU_VAL=1 89 | fi 90 | 91 | get_cpus_to_control "$DISABLE_AVAILABLE_CPU" 92 | 93 | for THISCPU in $cpu_list ; do 94 | if [ -e "$THISCPU/online" ]; then 95 | log "VERBOSE" "Bringing CPU $THISCPU to $ECHO_VAL" 96 | echo $CPU_VAL > $THISCPU/online 97 | else 98 | log "VERBOSE" "CPU $THISCPU cannot be hot plugged" 99 | fi 100 | done 101 | fi 102 | -------------------------------------------------------------------------------- /etc/init.d/laptop-mode: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # chkconfig: - 99 99 4 | # description: Starts and stops "laptop-mode" - tweaks system behavior 5 | # to extend battery life. 6 | # 7 | # config: /etc/laptop-mode/laptop-mode.conf 8 | 9 | ### BEGIN INIT INFO 10 | # Provides: laptop-mode 11 | # Required-Start: $remote_fs 12 | # Required-Stop: $remote_fs 13 | # Default-Start: 2 3 4 5 14 | # Default-Stop: 0 1 6 15 | # Short-Description: Enable laptop-mode-tools power management functions 16 | # Description: Enable laptop-mode-tools power management functions 17 | ### END INIT INFO 18 | 19 | test -f /usr/sbin/laptop_mode || exit 0 20 | 21 | if [ -f /lib/lsb/init-functions ] ; then 22 | . /lib/lsb/init-functions 23 | else 24 | log_success_msg() 25 | { 26 | logger -t LAPTOP-MODE -p daemon.info -- $* 27 | echo "$*" 28 | } 29 | log_failure_msg() 30 | { 31 | logger -t LAPTOP-MODE -p daemon.notice -- $* 32 | echo "$*" 33 | } 34 | fi 35 | 36 | # Enable laptop mode when the system is booted when running on battery. 37 | 38 | case $1 in 39 | start) 40 | # Clean-up any possibilities of a leftover 41 | # From the initscript, we want a clean start 42 | test -f /var/run/laptop-mode-tools/enabled && rm -f /var/run/laptop-mode-tools/enabled 43 | test -f /var/run/laptop-mode-tools/state && rm -f /var/run/laptop-mode-tools/state 44 | 45 | if RESULT=`/usr/sbin/laptop_mode force` ; then 46 | log_success_msg "$RESULT" 47 | else 48 | log_failure_msg "$RESULT" 49 | fi 50 | ;; 51 | 52 | restart) 53 | $0 stop; 54 | $0 start; 55 | ;; 56 | 57 | reload|force-reload) 58 | if RESULT=`/usr/sbin/laptop_mode auto` ; then 59 | log_success_msg "$RESULT" 60 | else 61 | log_failure_msg "$RESULT" 62 | fi 63 | ;; 64 | 65 | stop) 66 | if RESULT=`/usr/sbin/laptop_mode stop` ; then 67 | log_success_msg "$RESULT" 68 | else 69 | log_failure_msg "$RESULT" 70 | fi 71 | 72 | # Clean-up any possibilities of a leftover 73 | # From the initscript, we want a clean start 74 | test -f /var/run/laptop-mode-tools/enabled && rm -f /var/run/laptop-mode-tools/enabled 75 | test -f /var/run/laptop-mode-tools/state && rm -f /var/run/laptop-mode-tools/state 76 | ;; 77 | 78 | status) 79 | echo "Laptop mode status:" 80 | echo 81 | /usr/sbin/laptop_mode status 82 | ;; 83 | 84 | *) 85 | echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2 86 | exit 2 87 | ;; 88 | esac 89 | 90 | exit 0 91 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/start-stop-programs.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module start-stop-programs. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # Start/Stop Programs settings 9 | # ---------------------------- 10 | # 11 | #__COMMENT Laptop mode tools can automatically start and stop programs when entering 12 | #__COMMENT various power modes. Put scripts accepting "start" and "stop" parameters 13 | #__COMMENT in the directories 14 | #__COMMENT /etc/laptop-mode/batt-stop 15 | #__COMMENT /etc/laptop-mode/batt-start 16 | #__COMMENT /etc/laptop-mode/lm-ac-stop 17 | #__COMMENT /etc/laptop-mode/lm-ac-start 18 | #__COMMENT /etc/laptop-mode/nolm-ac-stop 19 | #__COMMENT /etc/laptop-mode/nolm-ac-start 20 | #__COMMENT Laptop mode will call the scripts in a state-"stop" directory with the "stop" 21 | #__COMMENT parameter when entering the state in question, and it will call the same 22 | #__COMMENT scripts with the "start" parameter when leaving the state. Scripts in a 23 | #__COMMENT state-"start" directory are called with the "start" parameter when the 24 | #__COMMENT specified state is entered, and with the "stop" parameter when the specified 25 | #__COMMENT state is left. 26 | #__COMMENT 27 | #__COMMENT Alternatively, if you only want to start/stop services, you can place the 28 | #__COMMENT names of these services in one of the ..._STOP and ..._START config values 29 | #__COMMENT below. 30 | #__COMMENT 31 | #__COMMENT 32 | #__COMMENT IMPORTANT: In versions 1.36 and earlier, these settings were included in the 33 | #__COMMENT main laptop-mode.conf configuration file. If they are still present, they 34 | #__COMMENT overrule the settings in this file. To fix this, simply delete the settings 35 | #__COMMENT from the main config file. 36 | # 37 | ############################################################################### 38 | 39 | # Enable debug mode for this module 40 | # Set to 1 if you want to debug this module 41 | DEBUG=0 42 | 43 | # 44 | # Should laptop mode start and stop programs? 45 | # 46 | CONTROL_START_STOP=1 47 | 48 | 49 | # 50 | # Services to start/stop depending on the power state. 51 | # 52 | # 53 | # These services are started/stopped through their init scripts, together with 54 | # the files from the directories mentioned above. Specify the services as a 55 | # space separated list. 56 | # 57 | BATT_STOP="" 58 | BATT_START="" 59 | LM_AC_STOP="" 60 | LM_AC_START="" 61 | NOLM_AC_STOP="" 62 | NOLM_AC_START="" 63 | -------------------------------------------------------------------------------- /man/laptop_mode.8: -------------------------------------------------------------------------------- 1 | .TH "LAPTOP_MODE" "8" 2 | .SH "NAME" 3 | .I /usr/sbin/laptop_mode 4 | \- apply laptop mode settings 5 | .SH "SYNOPSIS" 6 | .B /usr/sbin/laptop_mode [ 7 | .I cmd 8 | .B ] [ force ] 9 | .SH "DESCRIPTION" 10 | This manual page documents briefly the 11 | .I /usr/sbin/laptop_mode 12 | command. laptop_mode is a program that applies the settings given in the 13 | .I /etc/laptop-mode/laptop-mode.conf 14 | configuration file. The primary use is to control the laptop mode feature 15 | included in Linux kernels with versions 2.6.6 and higher, and 2.4.23 and higher. 16 | This feature increases battery life by letting your 17 | hard drive spin down. This is achieved by grouping disk write 18 | activity into "chunks" that are spaced at larger intervals than 19 | they normally would be. In addition to supporting the Linux kernel's laptop mode 20 | feature, 21 | .I /usr/sbin/laptop_mode 22 | also supports various power saving modules which are configured through 23 | configuration files in the 24 | .I /etc/laptop-mode/conf.d 25 | directory. 26 | .PP 27 | It is not recommended to call 28 | .I /usr/sbin/laptop_mode 29 | directly to start or stop laptop mode, except in hardware event handlers. To 30 | apply new configuration settings from \fIlaptop-mode.conf\fP, call the 31 | laptop-mode service init script with the reload parameter. 32 | .SH "COMMANDS" 33 | Specify \fBforce\fP as the second parameter to force laptop_mode to re-apply 34 | a state even if the computer is already in that state. These are the values that 35 | are allowed for 36 | .I cmd 37 | : 38 | .IP "\fBauto\fP" 10 39 | Enable or disable laptop mode based on the current power state. Note that 40 | this will not do anything if the laptop-mode service has not been 41 | started! 42 | .IP "\fBstatus\fP" 10 43 | Display a status report about everything that laptop_mode affects. 44 | .IP "\fBhelp\fP" 10 45 | Display this help message 46 | .IP "\fBpower-stats\fP" 10 47 | Display the power statistics on the machine. 48 | .IP "\fBpower-events\fP" 10 49 | Capture power-related events on the machine. 50 | .IP "\fBversion\fP" 10 51 | Display version of Laptop Mode Tools 52 | .SH "SEE ALSO" 53 | laptop-mode.conf(8). 54 | .SH "AUTHOR" 55 | This manual page was written by Bart Samwel (bart@samwel.tk) for 56 | the 57 | .B Debian 58 | system (but may be used by others). Permission is 59 | granted to copy, distribute and/or modify this document under 60 | the terms of the GNU General Public License, Version 2 any 61 | later version published by the Free Software Foundation. 62 | 63 | On Debian systems, the complete text of the GNU General Public 64 | License can be found in /usr/share/common-licenses/GPL. 65 | -------------------------------------------------------------------------------- /man/lm-profiler.8: -------------------------------------------------------------------------------- 1 | .TH "LM-PROFILER" "8" 2 | .SH "NAME" 3 | .I /usr/sbin/lm-profiler 4 | \- laptop mode profiler 5 | .SH "SYNOPSIS" 6 | .B /usr/sbin/lm-profiler 7 | .SH "DESCRIPTION" 8 | This manual page documents briefly the 9 | .I /usr/sbin/lm-profiler 10 | command. lm-profiler is a tool for profiling disk operations. It is a part of 11 | laptop mode tools and 12 | is useful only in relation to rest of laptop mode tools. It helps you to 13 | detect programs and services that use up system resources and that cause 14 | disk activity, and it allows you to disable them when laptop mode is active. 15 | 16 | When you start lm-profiler, it will execute a "profiling run", which can 17 | take some time. Start lm-profiler when you are working on batteries, 18 | preferably, because that will allow it to analyze the actual situation that 19 | it is supposed to optimize. During the profiling run, you can use your system 20 | normally; however, any disk activity caused by your actions will end up in 21 | the profiler's results. When the profiling run is finished, you will be 22 | presented with a list of programs that deserve your attention, either because 23 | they listen on a network (which is not usually useful when you are working 24 | offline) or because they caused disk activity in a disk-spindown-unfriendly 25 | pattern. When lm-profiler can guess an init script that belongs to a program, 26 | it presents you with the opportunity to disable the program when you are 27 | working on battery. It does this by placing a link to the init script in 28 | /etc/laptop-mode/batt-stop. Any programs that lm-profiler cannot find an 29 | init script for is simply reported, so that you can stop the 30 | program manually if you want to. 31 | .PP 32 | .B WARNING ABOUT DISABLING PROGRAMS: 33 | It may not be safe to disable some programs. They may be needed for proper 34 | operation of your system. Disable services only if you know what they do 35 | and why you don't need them. 36 | .SH "FILES" 37 | .IP "\fI/etc/lm-profiler.conf\fP" 38 | lm-profiler retrieves its profiling rules from this file. 39 | 40 | .SH "SEE ALSO" 41 | .PP 42 | lm-profiler.conf(8). 43 | .PP 44 | laptop-mode.conf(8). 45 | .PP 46 | daemons.conf(8). 47 | .SH "AUTHOR" 48 | This manual page was written by Bart Samwel (bart@samwel.tk) and 49 | Jan Polacek (jerome@ucw.cz) for the 50 | .B Debian 51 | system (but may be used by others). Permission is 52 | granted to copy, distribute and/or modify this document under 53 | the terms of the GNU General Public License, Version 2 any 54 | later version published by the Free Software Foundation. 55 | 56 | On Debian systems, the complete text of the GNU General Public 57 | License can be found in /usr/share/common-licenses/GPL. 58 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/ethernet.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module ethernet. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Ethernet power saving settings 10 | # ------------------------------ 11 | # 12 | #__COMMENT There are various ways to save power with ethernet. This section allows you 13 | #__COMMENT to control the speed of your ethernet connection, and your wakeup-on-LAN 14 | #__COMMENT settings. Both these things can have quite a power impact if you use Ethernet. 15 | #__COMMENT 16 | #__COMMENT Note: Changing ethernet device speed may require link up/down on some devices. 17 | #__COMMENT This might lead to connection to be re-initialized 18 | # 19 | ############################################################################### 20 | 21 | # Enable debug mode for this module 22 | # Set to 1 if you want to debug this module 23 | DEBUG=0 24 | 25 | # Control Ethernet settings? 26 | CONTROL_ETHERNET=0 27 | 28 | # Handle throttling of the ethernet device under specific circumstances 29 | BATT_THROTTLE_ETHERNET=1 30 | LM_AC_THROTTLE_ETHERNET=0 31 | NOLM_AC_THROTTLE_ETHERNET=0 32 | 33 | 34 | # Speed to throttle to when throttling is set 35 | # Please use the desired throttle value as reported by ethtool and set it accordingly 36 | # To get the speed capacity supported by your ethernet card, as user "root" run 37 | # "ethtool eth0", where eth0 is your physical ethernet device. 38 | # Example: 39 | # Set speed to 100Mbps. 40 | # THROTTLE_SPEED=100 41 | # 42 | # Throttle ethernet to the lowest available speed of the ethernet device 43 | # THROTTLE_SPEED="slowest" 44 | # 45 | # Throttle ethernet to the fastest available speed of the ethernet device 46 | # This can be helpful when you want to control the speed, even when on battery 47 | # THROTTLE_SPEED="fastest" 48 | # 49 | # Note: If you don't know how to find the speed of your ethernet card, leave the 50 | # following values as it is. 51 | THROTTLE_SPEED="slowest" 52 | 53 | # Disable wakeup-on-LAN? This will disable wakeup-on-LAN unconditionally, 54 | # independent of battery power. It will save power while your laptop is turned 55 | # off or in standby mode. 56 | DISABLE_WAKEUP_ON_LAN=1 57 | 58 | # A list of the ethernet devices that should be controlled. 59 | ETHERNET_DEVICES="" 60 | 61 | 62 | # In practise, most of the times a user is on battery, she is using the wireless device 63 | # Under such cases, you might want to disable your ethernet interface completely, when 64 | # on battery. 65 | # 66 | # Set below setting to 1, to disable ethernet interface when on battery and 67 | # when no carrier is detected on the interface (e.g., no active cable is 68 | # plugged in). 69 | DISABLE_ETHERNET_ON_BATTERY=0 70 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/dpms-standby: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: control X display standby / suspend / off using DPMS 4 | # 5 | 6 | # getXuser gets the X user belonging to the display in $displaynum. 7 | # (This code was borrowed from the Debian acpi-support package.) 8 | getXuser() { 9 | user=`w -hs | awk '{ if ($3 == ":'$displaynum'" || $3 ~ /:'$displaynum'\..*/ || $2 == ":'$displaynum'" || $2 ~ /:'$displaynum'\..*/) { print $1; exit; } }'` 10 | if [ x"$user" = x"" ]; then 11 | startx=`pgrep -n startx` 12 | if [ x"$startx" != x"" ]; then 13 | user=`ps -o user --no-headers $startx` 14 | fi 15 | fi 16 | 17 | export XAUTHORITY="" 18 | if [ x"$user" != x"" ]; then 19 | xauthdir=`getent passwd $user | cut -d: -f6` 20 | xauthuser=`getent passwd $user | cut -d: -f1` 21 | xauthuserid=`getent passwd $user | cut -d: -f3` 22 | 23 | if [ -f /run/user/$xauthuserid/*/Xauthority ]; then 24 | export XAUTHORITY=/run/user/$xauthuserid/*/Xauthority 25 | log "VERBOSE" "XAUTHORITY path is: $XAUTHORITY" 26 | elif [ -f "$xauthdir/.Xauthority" ]; then 27 | export XAUTHORITY=$xauthdir/.Xauthority 28 | fi 29 | else 30 | export XAUTHORITY="" 31 | fi 32 | export XUSER=$user 33 | } 34 | 35 | 36 | # Set X screen standby/suspend/powerdown timing 37 | if [ x$CONTROL_DPMS_STANDBY = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_DPMS_STANDBY = xauto ]; then 38 | if [ $ON_AC -eq 1 ]; then 39 | if [ "$ACTIVATE" -eq 1 ]; then 40 | STANDBY="$LM_AC_DPMS_STANDBY" 41 | SUSPEND=$(($STANDBY+30)) 42 | OFF=$(($STANDBY+60)) 43 | else 44 | STANDBY="$NOLM_AC_DPMS_STANDBY" 45 | SUSPEND=$(($STANDBY+300)) 46 | OFF=$(($STANDBY+600)) 47 | fi 48 | else 49 | STANDBY="$BATT_DPMS_STANDBY" 50 | SUSPEND=$(($STANDBY+30)) 51 | OFF=$(($STANDBY+60)) 52 | fi 53 | 54 | # Loop through all X servers using their unix domain sockets. 55 | # (Partly borrowed from the Debian acpi-support package.) 56 | for x in /tmp/.X11-unix/*; do 57 | if [ -e "$x" ] ; then 58 | displaynum=`echo $x | sed -r 's#/tmp/.X11-unix/X([0-9]*)$#\1#'` 59 | log "VERBOSE" "Determining Xauthority for display $displaynum" 60 | getXuser; 61 | if [ x"$XAUTHORITY" != x"" ]; then 62 | export DISPLAY=":$displaynum" 63 | if su $XUSER -c "xset dpms $STANDBY $SUSPEND $OFF" 2>> $OUTPUT | grep -q display 2>&1 ; then 64 | log "VERBOSE" "Unable to set DPMS timeouts: X is not running on $DISPLAY" 65 | else 66 | log "VERBOSE" "Set screen $DISPLAY for the user $XUSER to standby in $STANDBY s, suspend in $SUSPEND s, powerdown in $OFF s using Xauthority $XAUTHORITY" 67 | fi 68 | else 69 | log "VERBOSE" "Unable to determine Xauthority for display :$displaynum." 70 | fi 71 | fi 72 | done 73 | else 74 | log "VERBOSE" "CONTROL_DPMS_STANDBY is disabled, skipping..." 75 | fi 76 | 77 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/lcd-brightness.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module lcd-brightness. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # LCD brightness settings 10 | # ----------------------- 11 | # 12 | #__COMMENT Using these settings, you can make laptop mode tools automatically adjust 13 | #__COMMENT your LCD's brightness settings. The settings are extremely simple -- they 14 | #__COMMENT only allow for the execution of a command, nothing more. The reason for this 15 | #__COMMENT is that LCD brightness settings are very different between laptop vendors. 16 | #__COMMENT 17 | #__COMMENT Suggestions for commands: 18 | #__COMMENT 19 | #__COMMENT * If your system has the file "/proc/acpi/video/VID/LCD/brightness" (VID may 20 | #__COMMENT be VID1 or similar), use this file as BRIGHTNESS_OUTPUT, and use 21 | #__COMMENT the command "echo ". The possible values can be listed using the 22 | #__COMMENT command: 23 | #__COMMENT 24 | #__COMMENT cat /proc/acpi/video/VID/LCD/brightness 25 | #__COMMENT 26 | #__COMMENT * If you have a file /sys/class/backlight/.../brightness, then you can use 27 | #__COMMENT that file as BRIGHTNESS_OUTPUT, and the command "echo ". 28 | #__COMMENT 29 | #__COMMENT As far as I understand it the values are between 0 and 30 | #__COMMENT the value contained in the file /sys/class/backlight/.../max_brightness. 31 | #__COMMENT 32 | #__COMMENT * For Toshiba laptops, use the command "toshset" with the -lcd or -inten 33 | #__COMMENT command. Read the toshset(1) manual page for more information on the 34 | #__COMMENT parameters for this command. If you use this command, set 35 | #__COMMENT BRIGHTNESS_OUTPUT to "/dev/null". 36 | # 37 | ############################################################################### 38 | 39 | ############################################################################### 40 | # 41 | # IMPORTANT: In versions 1.36 and earlier, these settings were included in the 42 | # main laptop-mode.conf configuration file. If they are still present, they 43 | # overrule the settings in this file. To fix this, simply delete the settings 44 | # from the main config file. 45 | # 46 | ############################################################################### 47 | 48 | # Enable debug mode for this module 49 | # Set to 1 if you want to debug this module 50 | DEBUG=0 51 | 52 | # 53 | # Should laptop mode tools control LCD brightness? 54 | # 55 | CONTROL_BRIGHTNESS=0 56 | 57 | 58 | # 59 | # Commands to execute to set the brightness on your LCD 60 | # 61 | BATT_BRIGHTNESS_COMMAND="echo [value]" 62 | LM_AC_BRIGHTNESS_COMMAND="echo [value]" 63 | NOLM_AC_BRIGHTNESS_COMMAND="echo [value]" 64 | BRIGHTNESS_OUTPUT="/proc/acpi/video/VID/LCD/brightness" 65 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/intel-sata-powermgmt: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: Power management for Intel SATA controllers 4 | # 5 | 6 | if [ x$CONTROL_INTEL_SATA_POWER = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_INTEL_SATA_POWER = xauto ]; then 7 | # Set defaults (these settings were added later) 8 | if [ -z "$BATT_SATA_POLICY" ]; then 9 | if [ -z "$BATT_ACTIVATE_SATA_POWER" -o "$BATT_ACTIVATE_SATA_POWER" -eq 1 ]; then 10 | BATT_SATA_POLICY=min_power 11 | else 12 | BATT_SATA_POLICY=max_performance 13 | fi 14 | fi 15 | if [ -z "$LM_AC_SATA_POLICY" ]; then 16 | if [ "$LM_AC_ACTIVATE_SATA_POWER" -eq 1 ]; then 17 | LM_AC_SATA_POLICY=min_power 18 | else 19 | LM_AC_SATA_POLICY=max_performance 20 | fi 21 | fi 22 | if [ -z "$NOLM_AC_SATA_POLICY" ]; then 23 | if [ "$NOLM_AC_ACTIVATE_SATA_POWER" -eq 1 ]; then 24 | NOLM_AC_SATA_POLICY=min_power 25 | else 26 | NOLM_AC_SATA_POLICY=max_performance 27 | fi 28 | fi 29 | 30 | # Determine setting 31 | if [ $ON_AC -eq 1 ]; then 32 | if [ "$ACTIVATE" -eq 1 ]; then 33 | SATA_POLICY="$LM_AC_SATA_POLICY" 34 | else 35 | SATA_POLICY="$NOLM_AC_SATA_POLICY" 36 | fi 37 | RUNTIME_PM_AHCI="on" 38 | else 39 | SATA_POLICY="$BATT_SATA_POLICY" 40 | RUNTIME_PM_AHCI="auto" 41 | fi 42 | 43 | for POLICYFILE in /sys/class/scsi_host/*/link_power_management_policy ; do 44 | if [ -f $POLICYFILE ] ; then 45 | log "VERBOSE" "Intel SATA link power saving set to $SATA_POLICY for $POLICYFILE." 46 | echo $SATA_POLICY > $POLICYFILE 47 | else 48 | log "VERBOSE" "Intel SATA link power saving enabled but not supported by system for $POLICYFILE." 49 | fi 50 | done 51 | 52 | if [ x$CONTROL_AHCI_RUNTIME_PM = x1 ]; then 53 | # Enable Runtime PM for AHCI Class Ports 54 | for port in /sys/bus/pci/devices/*/ata*/power/control ; do 55 | if [ -f $port ]; then 56 | log "VERBOSE" "Setting AHCI Runtime PM value for $port to value: $RUNTIME_PM_AHCI" 57 | echo $RUNTIME_PM_AHCI > $port; 58 | fi 59 | done 60 | 61 | # Now scan through available devices that are marked for power savings 62 | # Let's scan through all block devices, typically there aren't many, even after considering the virtual block devices 63 | for device in /sys/block/*/device/power/control ; do 64 | if [ -f $device ]; then 65 | log "VERBOSE" "Setting AHCI Runtime PM value for $device to value: $RUNTIME_PM_AHCI" 66 | echo $RUNTIME_PM_AHCI > $device; 67 | fi 68 | done 69 | else 70 | log "VERBOSE" "AHCI Runtime PM is disabled" 71 | fi 72 | else 73 | log "VERBOSE" "Intel SATA link power saving disabled." 74 | fi 75 | 76 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/runtime-pm.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module runtime-pm 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Runtime Power Management Settings 10 | # --------------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will automatically enable 13 | #__COMMENT the Runtime Power Management feature for all devices. 14 | #__COMMENT 15 | #__COMMENT NOTE: Some devices claim they support autosuspend, but implement it in a 16 | #__COMMENT broken way. This can mean keyboards losing keypresses, or optical mice 17 | #__COMMENT turning their LED completely off. If you have a device that misbehaves, 18 | #__COMMENT add its DEVICE ID to the blacklist section below and complain to your 19 | #__COMMENT hardware / device driver contact 20 | # 21 | ################################################################################ 22 | 23 | # Enable debug mode for this module 24 | # Set to 1 if you want to debug this module 25 | DEBUG=0 26 | 27 | # Enable Runtime autosuspend feature? 28 | # Set to 0 to disable 29 | CONTROL_RUNTIME_AUTOSUSPEND=1 30 | 31 | # Set this to use opt-in/whitelist instead of opt-out/blacklist for deciding 32 | # which devices should be autosuspended. 33 | # AUTOSUSPEND_USE_WHITELIST=0 means AUTOSUSPEND_*_BLACKLIST will be used. 34 | # AUTOSUSPEND_USE_WHITELIST=1 means AUTOSUSPEND_*_WHITELIST will be used. 35 | AUTOSUSPEND_USE_WHITELIST=0 36 | 37 | # The list of Device IDs that should not use autosuspend. Use system commands or 38 | # look into sysfs to find out the IDs of your devices. 39 | # Example: AUTOSUSPEND_RUNTIME_DEVID_BLACKLIST="046d:c025 0123:abcd" 40 | AUTOSUSPEND_RUNTIME_DEVID_BLACKLIST="" 41 | 42 | # The list of 'device driver types' or 'device types' that should not use autosuspend. 43 | # The driver type is given by "DRIVER=..." in a device's uevent file. 44 | # The driver type is given by "DEVTYPE=..." in a device's uevent file. 45 | # Example: AUTOSUSPEND_RUNTIME_DEVTYPE_BLACKLIST="usbhid usb-storage" 46 | AUTOSUSPEND_RUNTIME_DEVTYPE_BLACKLIST="sd hub usbhid usb-storage" 47 | 48 | # The list of Device IDs that should use autosuspend. Use system commands or 49 | # look into sysfs to find out the IDs of your devices. 50 | # Example: AUTOSUSPEND_RUNTIME_DEVID_WHITELIST="046d:c025 0123:abcd" 51 | AUTOSUSPEND_RUNTIME_DEVID_WHITELIST="" 52 | 53 | # The list of device driver types that should use autosuspend. The driver 54 | # type is given by "DRIVER=..." in a device's uevent file. 55 | # Example: AUTOSUSPEND_RUNTIME_DEVTYPE_WHITELIST="usbhid usb-storage" 56 | AUTOSUSPEND_RUNTIME_DEVTYPE_WHITELIST="" 57 | 58 | # Trigger auto-suspension of the device under conditional circumstances 59 | # Warning: DO NOT CHANGE THESE DEFAULTS UNLESS YOU KNOW 60 | BATT_SUSPEND_RUNTIME=1 61 | LM_AC_SUSPEND_RUNTIME=1 62 | NOLM_AC_SUSPEND_RUNTIME=0 63 | 64 | # Auto-Suspend timeout in seconds 65 | # Number of seconds after which the USB devices should suspend 66 | AUTOSUSPEND_TIMEOUT=2 67 | 68 | 69 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/exec-commands.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module exec-commands 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | 8 | ############################################################################### 9 | # Execute custom commands for power saving settings 10 | # ------------------------------------------------- 11 | # 12 | #__COMMENT If you enable this setting, laptop mode tools will execute the specified 13 | #__COMMENT commands on mode change. 14 | #__COMMENT Please double test your commands before adding them here 15 | # 16 | ############################################################################### 17 | 18 | # Control exec-commands power savings? 19 | CONTROL_EXEC_COMMANDS="auto" 20 | 21 | # Enable debug mode for this module 22 | # Set to 1 if you want to debug this module 23 | DEBUG=0 24 | 25 | 26 | # Command list 27 | # You can populate the command list on the basis of the events 28 | # Please double test your commands before adding them here 29 | # 30 | # Currently, a max of 10 commands are supported 31 | # 32 | BATT_EXEC_COMMAND_0="" # Enable power saving feature 0 here 33 | LM_AC_EXEC_COMMAND_0="" # Enable power saving feature 0 here 34 | NOLM_AC_EXEC_COMMAND_0="" # Disable power saving feature 0 here 35 | 36 | BATT_EXEC_COMMAND_1="" # Enable power saving feature 1 here 37 | LM_AC_EXEC_COMMAND_1="" # Enable power saving feature 1 here 38 | NOLM_AC_EXEC_COMMAND_1="" # Disable power saving feature 1 here 39 | 40 | BATT_EXEC_COMMAND_2="" # Enable power saving feature 2 here 41 | LM_AC_EXEC_COMMAND_2="" # Enable power saving feature 2 here 42 | NOLM_AC_EXEC_COMMAND_2="" # Disable power saving feature 2 here 43 | 44 | BATT_EXEC_COMMAND_3="" # Enable power saving feature 3 here 45 | LM_AC_EXEC_COMMAND_3="" # Enable power saving feature 3 here 46 | NOLM_AC_EXEC_COMMAND_3="" # Disable power saving feature 3 here 47 | 48 | BATT_EXEC_COMMAND_4="" # Enable power saving feature 4 here 49 | LM_AC_EXEC_COMMAND_4="" # Enable power saving feature 4 here 50 | NOLM_AC_EXEC_COMMAND_4="" # Disable power saving feature 4 here 51 | 52 | BATT_EXEC_COMMAND_5="" # Enable power saving feature 5 here 53 | LM_AC_EXEC_COMMAND_5="" # Enable power saving feature 5 here 54 | NOLM_AC_EXEC_COMMAND_5="" # Disable power saving feature 5 here 55 | 56 | BATT_EXEC_COMMAND_6="" # Enable power saving feature 6 here 57 | LM_AC_EXEC_COMMAND_6="" # Enable power saving feature 6 here 58 | NOLM_AC_EXEC_COMMAND_6="" # Disable power saving feature 6 here 59 | 60 | BATT_EXEC_COMMAND_7="" # Enable power saving feature 7 here 61 | LM_AC_EXEC_COMMAND_7="" # Enable power saving feature 7 here 62 | NOLM_AC_EXEC_COMMAND_7="" # Disable power saving feature 7 here 63 | 64 | BATT_EXEC_COMMAND_8="" # Enable power saving feature 8 here 65 | LM_AC_EXEC_COMMAND_8="" # Enable power saving feature 8 here 66 | NOLM_AC_EXEC_COMMAND_8="" # Disable power saving feature 8 here 67 | 68 | BATT_EXEC_COMMAND_9="" # Enable power saving feature 9 here 69 | LM_AC_EXEC_COMMAND_9="" # Enable power saving feature 9 here 70 | NOLM_AC_EXEC_COMMAND_9="" # Disable power saving feature 9 here 71 | 72 | -------------------------------------------------------------------------------- /man/lm-profiler.conf.8: -------------------------------------------------------------------------------- 1 | .TH "LM-PROFILER.CONF" "8" 2 | .SH "NAME" 3 | .I /etc/laptop-mode/lm-profiler.conf 4 | \- Configuration file for \fIlm-profiler\fP, a profiler for laptop-mode-tools. 5 | .SH "DESCRIPTION" 6 | .PP 7 | This manual page documents the options that can be set in the 8 | .I /etc/laptop-mode/lm-profiler.conf 9 | configuration file. For a description of what lm-profiler does, see the 10 | lm-profiler(8) manpage. 11 | 12 | .SH "SETTINGS" 13 | .PP 14 | The syntax of options is \fBOPTION=value\fP. 15 | 16 | .PP 17 | The following settings are available in \fIlm-profiler.conf\fP: 18 | 19 | .IP "\fBVERBOSE_OUTPUT\fP" 10 20 | Set this to 1 if you want to see a lot of output when you run lm-profiler, 21 | and 0 if you don't want this. Useful for debugging purposes. (Currently 22 | does nothing.) 23 | 24 | .IP "\fBPROFILE_RUN_LENGTH\fP" 10 25 | The length of a profiling run, in seconds. This should be a while, so that 26 | lm-profiler can gather enough information. The default is 10 minutes (600 27 | seconds). 28 | 29 | .IP "\fBACTIVITY_INTERVAL_MIN\fP" 10 30 | .IP "\fBACTIVITY_INTERVAL_MAX\fP" 10 31 | The behaviour that you want to avoid when you have your hard 32 | drive spun down, is disk accesses that are spread out over time, because 33 | your hard drive will have to spin up for each access. lm-profiler detects 34 | when applications perform disk accesses that are at least some time apart 35 | (otherwise they can be considered part of the same access) but not TOO 36 | far apart (otherwise they are no problem). These settings configure what 37 | lm-profiler considers "at least some time apart" and "too far apart", 38 | respectively, in seconds. 39 | 40 | .IP "\fBRECOMMEND_DEFAULT_SERVICES\fP" 10 41 | .IP "\fBDEFAULT_SERVICES\fP" 10 42 | If \fBRECOMMEND_DEFAULT_SERVICES\fP is set to 1 (enabled), then lm-profiler will always 43 | suggest turning off the services listed in \fBDEFAULT_SERVICES\fP (separated by 44 | spaces). 45 | 46 | .IP "\fBIGNORE_PROGRAMS\fP" 10 47 | Programs listed in this option, separated by spaces, will be ignored for 48 | disk activity profiling. The default settings (which can be referenced 49 | as \fB$DEF_IGNORE_PROGRAMS\fP) include common utility programs and all programs 50 | used by lm-profiler itself. 51 | 52 | .IP "\fBRECOMMEND_NETWORK_SERVICES\fP" 10 53 | When this option is enabled (value 1), lm-profiler will detect any services 54 | that are listening on network ports, and it will suggest that you disable 55 | them. 56 | 57 | .IP "\fBIGNORE_NETWORK_SERVICES\fP" 10 58 | Services listed in this configuration option (separated by spaces) are not 59 | suggested as a network service by lm-profiler. The default values can be 60 | accessed as \fB$DEF_IGNORE_NETWORK_SERVICES\fP. 61 | 62 | 63 | .SH "SEE ALSO" 64 | .PP 65 | lm-profiler(8). 66 | .PP 67 | laptop_mode(8). 68 | .PP 69 | laptop-mode.conf(8). 70 | .SH "AUTHOR" 71 | .PP 72 | This manual page was written by Bart Samwel (bart@samwel.tk). Permission is 73 | granted to copy, distribute and/or modify this document under 74 | the terms of the GNU General Public License, Version 2 any 75 | later version published by the Free Software Foundation. 76 | 77 | .\" created by instant / docbook-to-man, Tue 09 Nov 2004, 23:14 78 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/cpufreq.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module cpufreq. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # CPU frequency scaling and throttling 9 | # ------------------------------------ 10 | # 11 | #__COMMENT Laptop mode tools can automatically adjust your kernel CPU frequency 12 | #__COMMENT settings. This includes upper and lower limits and scaling governors. 13 | #__COMMENT There is also support for CPU throttling, on systems that don't support 14 | #__COMMENT frequency scaling. 15 | #__COMMENT 16 | #__COMMENT This feature only works on 2.6 kernels. 17 | #__COMMENT 18 | #__COMMENT 19 | #__COMMENT IMPORTANT: In versions 1.36 and earlier, these settings were included in the 20 | #__COMMENT main laptop-mode.conf configuration file. If they are still present, they 21 | #__COMMENT overrule the settings in this file. To fix this, simply delete the settings 22 | #__COMMENT from the main config file. 23 | # 24 | ############################################################################### 25 | 26 | # Enable debug mode for this module 27 | # Set to 1 if you want to debug this module 28 | DEBUG=0 29 | 30 | # 31 | # Should laptop mode tools control the CPU frequency settings? 32 | # 33 | # Set to 0 to disable 34 | CONTROL_CPU_FREQUENCY="auto" 35 | 36 | 37 | # 38 | # Legal values are "slowest" for the slowest speed that your 39 | # CPU is able to operate at, "fastest" for the fastest speed, 40 | # "medium" for some value in the middle, or any value listed in 41 | # /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies. 42 | # The "governor" can be any governor installed on your system, this usually 43 | # includes "ondemand", "conservative", and "performance". And it can also be 44 | # a speical value "auto" which is the default case meaning that the governor 45 | # is picked automatically by LMT, that is try to use governors provided by 46 | # intel_pstate driver first and fallback to ondemand if that's not possible. 47 | # The "IGNORE_NICE_LOAD" setting specifies that background programs that have 48 | # a low priority ("nice level") should not cause the CPU frequency to 49 | # be increased. (You generally want this to be enabled in battery mode.) 50 | # 51 | BATT_CPU_MAXFREQ=fastest 52 | BATT_CPU_MINFREQ=slowest 53 | BATT_CPU_GOVERNOR=auto 54 | BATT_CPU_IGNORE_NICE_LOAD=1 55 | LM_AC_CPU_MAXFREQ=fastest 56 | LM_AC_CPU_MINFREQ=slowest 57 | LM_AC_CPU_GOVERNOR=auto 58 | LM_AC_CPU_IGNORE_NICE_LOAD=1 59 | NOLM_AC_CPU_MAXFREQ=fastest 60 | NOLM_AC_CPU_MINFREQ=slowest 61 | NOLM_AC_CPU_GOVERNOR=auto 62 | NOLM_AC_CPU_IGNORE_NICE_LOAD=0 63 | 64 | 65 | # 66 | # Should laptop mode tools control the CPU throttling? This is only useful 67 | # on processors that don't have frequency scaling. 68 | # (Only works when you have /proc/acpi/processor/CPU*/throttling.) 69 | # 70 | # This is only useful on older P4 processors that do not support frequency 71 | # scaling. On such processors, this is the only way to reduce power consumption 72 | # but at the cost of higher performance penalty. 73 | # 74 | # Enable this only if you have a processor that does not support frequency scaling 75 | # On most new processors, you might want to disable it. 76 | # 77 | # Set to 0 to disable. 78 | CONTROL_CPU_THROTTLING=0 79 | 80 | 81 | # 82 | # Legal values are "maximum" for the maximum (slowest) throttling level, 83 | # "minimum" for minimum (fastest) throttling level, "medium" for a value 84 | # somewhere in the middle (this is usually 50% for P4s), or any value listed 85 | # in /proc/acpi/processor/CPU*/throttling. Be careful when using "maximum": 86 | # this may be _very_ slow (in fact, with P4s it slows down the processor 87 | # by a factor 8). 88 | # 89 | BATT_CPU_THROTTLING=medium 90 | LM_AC_CPU_THROTTLING=medium 91 | NOLM_AC_CPU_THROTTLING=minimum 92 | 93 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/configuration-file-control: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Laptop mode tools module: switch config files based on power state. 4 | # 5 | 6 | if [ x$CONTROL_CONFIG_FILES = x1 ] ; then 7 | log "MSG" "Swapping out configuration files." 8 | for CONFFILE in $CONFIG_FILES ; do 9 | if [ -e $CONFFILE ] ; then 10 | # 11 | # Initialize the -nolm-ac, -lm-ac and -batt files if they don't 12 | # already exist. 13 | # 14 | if [ ! -e "$CONFFILE-nolm-ac" ] ; then 15 | cp $CONFFILE $CONFFILE-nolm-ac 16 | fi 17 | if [ ! -e "$CONFFILE-lm-ac" ] ; then 18 | cp $CONFFILE $CONFFILE-lm-ac 19 | fi 20 | if [ ! -e "$CONFFILE-batt" ] ; then 21 | cp $CONFFILE $CONFFILE-batt 22 | fi 23 | 24 | # 25 | # Create the .lmbackup file 26 | # 27 | if [ "`readlink -f $CONFFILE`" != "$CONFFILE" ] ; then 28 | log "MSG" "$CONFFILE is a symlink." 29 | if [ ! -f "$CONFFILE.lmbackup" ] ; then 30 | log "MSG" "But there is no $CONFFILE.lmbackup." 31 | log "MSG" "Creating it now from $CONFFILE-nolm-ac." 32 | cp "$CONFFILE-nolm-ac" "$CONFFILE.lmbackup" 33 | fi 34 | else 35 | log "MSG" "$CONFFILE is not a symlink." 36 | if [ "$STATE" = "enabled" ] ; then 37 | log "MSG" "Saving it to $CONFFILE.lmbackup." 38 | cp --backup=numbered "$CONFFILE" "$CONFFILE.lmbackup" 39 | fi 40 | fi 41 | 42 | # 43 | # Swizzle the config file 44 | # 45 | if [ "$STATE" != "enabled" ] ; then 46 | log "MSG" "Laptop mode is not enabled. Restoring $CONFFILE." 47 | if [ -f "$CONFFILE.lmbackup" ] ; then 48 | mv "$CONFFILE.lmbackup" "$CONFFILE" 49 | elif [ "`readlink -f $CONFFILE`" != "$CONFFILE" ] ; then 50 | echo "ERROR: $CONFFILE is a symlink but $CONFFILE.lmbackup is not present." 51 | fi 52 | elif [ $ON_AC -eq 1 ] ; then 53 | if [ "$ACTIVATE" -eq 1 ] ; then 54 | log "MSG" "Pointing config file $CONFFILE to $CONFFILE-lm-ac." 55 | ln -fs "$CONFFILE-lm-ac" "$CONFFILE" 56 | else 57 | log "MSG" "Pointing config file $CONFFILE to $CONFFILE-nolm-ac." 58 | ln -fs "$CONFFILE-nolm-ac" "$CONFFILE" 59 | fi 60 | else 61 | log "MSG" "Pointing config file $CONFFILE to $CONFFILE-batt." 62 | ln -fs "$CONFFILE-batt" "$CONFFILE" 63 | fi 64 | fi 65 | done 66 | # Notify daemons of configuration change. 67 | for PROGRAM in $CONFIG_FILE_SIGNAL_PROGRAMS ; do 68 | log "VERBOSE" "Sending SIGHUP to all $PROGRAM processes." 69 | killall -q -HUP $PROGRAM 70 | done 71 | 72 | 73 | if [ ! -z "$CONFIG_FILE_RELOAD_SERVICES" ] ; then 74 | # Determine how we can start/restart services. 75 | if ( which invoke-rc.d > /dev/null ) ; then 76 | # Debian uses invoke-rc.d 77 | RCPROG="invoke-rc.d " 78 | INITSCRIPT=laptop-mode 79 | elif ( which service > /dev/null ) ; then 80 | # RedHat uses service 81 | RCPROG="service " 82 | INITSCRIPT=laptop-mode 83 | else 84 | # Any other -- we start the init script it ourselves. 85 | 86 | # Try non-link directories first, then try links. This helps if one of 87 | # the locations is linked to another, which is the case on some distros. 88 | if [ -d /etc/rc.d/init.d -a ! -L /etc/rc.d/init.d ] ; then 89 | INIT_D=/etc/rc.d/init.d 90 | elif [ -d /etc/rc.d -a ! -L /etc/rc.d -a ! -d /etc/rc.d/init.d ] ; then 91 | INIT_D=/etc/rc.d 92 | elif [ -d /etc/init.d -a ! -L /etc/init.d ] ; then 93 | INIT_D=/etc/init.d 94 | elif [ -d /etc/rc.d/init.d ] ; then 95 | INIT_D=/etc/rc.d/init.d 96 | elif [ -d /etc/rc.d ] ; then 97 | INIT_D=/etc/rc.d 98 | elif [ -d /etc/init.d ] ; then 99 | INIT_D=/etc/init.d 100 | else 101 | log "VERBOSE" "Cannot determine location of init scripts." 102 | exit 1 103 | fi 104 | 105 | RCPROG="$INIT_D/" 106 | fi 107 | 108 | for SERVICE in $CONFIG_FILE_RELOAD_SERVICES ; do 109 | log "VERBOSE" "Reloading service $SERVICE." 110 | $RCPROG$SERVICE reload 111 | done 112 | fi 113 | fi 114 | 115 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/wireless-iwl-power: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module, called from /usr/sbin/laptop_mode. 4 | # Configuration in /etc/laptop-mode/conf.d/wireless-iwl-power.conf. 5 | # 6 | # PURPOSE: power saving for the Intel 3945 and 4965 adapters when using the 7 | # iwlwifi drivers. 8 | # 9 | # This script relies upon the name of the driver. 10 | # 11 | 12 | # 13 | # Find all the wireless devices using the supplied driver names. 14 | # Place the interface names on the list WIFI_IFNAMES. 15 | # 16 | findWifiIfsByDriver () { 17 | local DEVICE; 18 | local LINK_TARGET; 19 | local ENABLED; 20 | 21 | for DEVICE in /sys/class/net/*; do 22 | if [ -d $DEVICE/wireless -a -h $DEVICE/device/driver ]; then 23 | # See if the driver for $DEVICE matches the supplied one by checking the link to 24 | # the driver. 25 | LINK_TARGET=`readlink $DEVICE/device/driver` 26 | LINK_TARGET=${LINK_TARGET##*/} 27 | ENABLED=`[ -r $DEVICE/device/enabled ] && cat $DEVICE/device/enabled || cat $DEVICE/device/enable` 28 | 29 | if [ $ENABLED -eq 1 -a "$LINK_TARGET" = "$1" ] ; then 30 | # add the interface name to the list 31 | WIFI_IFNAMES="$WIFI_IFNAMES ${DEVICE##*/}" 32 | else 33 | log "VERBOSE" "$DEVICE doesn't seem to be enabled. Radio Switched off?"; 34 | fi 35 | else 36 | # LP: #369113 37 | # Kernel's 2.6.29 and above have been reported to be missing 38 | # the $DEVICE/wireless folder. 39 | dev=`basename $DEVICE` 40 | 41 | # Inverting return values, we get "0" for wireless device, 42 | # and "1" for non-wireless device. 43 | ($IWCONFIG $dev 2>&1 | grep -q "no wireless extensions.") && ret=1 || ret=0 44 | if [ "$ret" = "0" ]; then 45 | # add the interface name to the list 46 | WIFI_IFNAMES="$WIFI_IFNAMES ${DEVICE##*/}" 47 | fi 48 | fi 49 | done 50 | } 51 | 52 | if [ x$CONTROL_IWL_POWER = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_IWL_POWER = xauto ]; then 53 | log "VERBOSE" "Setting power levels for iwlwifi wireless interfaces." 54 | 55 | # Provide defaults for config file settings 56 | [ "$IWL_AC_POWER" ] || IWL_AC_POWER=0 57 | [ "$IWL_BATT_POWER" ] || IWL_BATT_POWER=3 58 | 59 | # find executables 60 | if [ -x /sbin/iwpriv ] ; then 61 | IWPRIV=/sbin/iwpriv 62 | elif [ -x /usr/sbin/iwpriv ] ; then 63 | IWPRIV=/usr/sbin/iwpriv 64 | else 65 | log "VERBOSE" "iwpriv is not installed" 66 | IWPRIV=/bin/false 67 | fi 68 | if [ -x /sbin/iwconfig ] ; then 69 | IWCONFIG=/sbin/iwconfig 70 | elif [ -x /usr/sbin/iwconfig ] ; then 71 | IWCONFIG=/usr/sbin/iwconfig 72 | else 73 | log "VERBOSE" "iwconfig is not installed" 74 | IWCONFIG=/bin/false 75 | fi 76 | 77 | WIFI_IFNAMES="" 78 | [ -d /sys/module/iwl3945 ] && findWifiIfsByDriver iwl3945 79 | [ -d /sys/module/iwl4965 ] && findWifiIfsByDriver iwl4965 80 | [ -d /sys/module/iwlagn ] && findWifiIfsByDriver iwlagn 81 | [ -d /sys/module/iwlwifi ] && findWifiIfsByDriver iwlwifi 82 | for IF in $WIFI_IFNAMES ; do 83 | if [ $ON_AC -eq 1 ] ; then 84 | log "VERBOSE" "On AC power: setting power level for $IF to $IWL_AC_POWER." 85 | if [ -f /sys/class/net/$IF/device/power_level ]; then 86 | echo $IWL_AC_POWER > /sys/class/net/$IF/device/power_level; 87 | log "VERBOSE" "Using method echo for power mgmt" 88 | else 89 | # For iwlagn, it is one standard behavior. Not multiple like ipwXXXX 90 | # Thus let's just simply exec the command here. 91 | $IWCONFIG $IF power off 92 | log "VERBOSE" "Using $IWCONFIG for power mgmt" 93 | fi 94 | else 95 | log "VERBOSE" "On battery: setting power level for $IF to $IWL_BATT_POWER." 96 | if [ -f /sys/class/net/$IF/device/power_level ]; then 97 | echo $IWL_BATT_POWER > /sys/class/net/$IF/device/power_level; 98 | log "VERBOSE" "Using method echo for power mgmt" 99 | else 100 | $IWCONFIG $IF power on 101 | log "VERBOSE" "Using $IWCONFIG for power mgmt" 102 | fi 103 | fi 104 | done 105 | else 106 | log "VERBOSE" "Intel IWL Wireless power setting is disabled." 107 | fi 108 | 109 | -------------------------------------------------------------------------------- /gui/laptop-mode-tools.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 44 | 46 | 47 | 49 | image/svg+xml 50 | 52 | 53 | 54 | 55 | 56 | 61 | 65 | 68 | 75 | 82 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/ethernet: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: Ethernet power saving tweaks. 4 | # 5 | 6 | if [ x$CONTROL_ETHERNET = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_ETHERNET = xauto ]; then 7 | 8 | # Let's check the binaries firts 9 | if [ -x /sbin/ethtool ]; then 10 | ETHTOOL=/sbin/ethtool 11 | elif [ -x /usr/sbin/ethtool ]; then 12 | ETHTOOL=/usr/sbin/ethtool 13 | else 14 | log "VERBOSE" "ethtool is not installed" 15 | ETHTOOL=/bin/false 16 | fi 17 | 18 | if [ -x /sbin/mii-tool ]; then 19 | MIITOOL=/sbin/mii-tool 20 | elif [ -x /usr/sbin/mii-tool ]; then 21 | MIITOOL=/usr/sbin/mii-tool 22 | else 23 | log "VERBOSE" "mii-tool is not installed" 24 | MIITOOL=/bin/false 25 | fi 26 | 27 | if [ -x /bin/ip ]; then 28 | IPTOOL=/bin/ip 29 | else 30 | log "VERBOSE" "ip is not installed" 31 | IPTOOL=/bin/false 32 | fi 33 | 34 | 35 | # Determine speed capability of physical device 36 | speed=`$MIITOOL -v $DEVICE 2>/dev/null | grep capabilities | tr ' ' '\n' |\ 37 | sort -n | sed -ne '/^1.*/p' | cut -d "b" -f1` 38 | if [ -z "$speed" ]; then 39 | speed=0; 40 | fi 41 | max_s=0; 42 | min_s=100000; 43 | for s in $speed; 44 | do 45 | if [ $s -gt $max_s ]; then 46 | max_s=$s 47 | fi 48 | if [ $s -lt $min_s ]; then 49 | min_s=$s 50 | fi 51 | done 52 | MAX_SPEED=$max_s; 53 | 54 | case "$THROTTLE_SPEED" in 55 | "slowest") 56 | THROTTLE_SPEED=$min_s 57 | ;; 58 | "fastest") 59 | THROTTLE_SPEED=$max_s 60 | ;; 61 | esac 62 | 63 | # Carrier detection 64 | if $IPTOOL link show $DEVICE | grep -q NO-CARRIER; then 65 | carrier="false"; 66 | else 67 | carrier="true"; 68 | fi 69 | 70 | 71 | # What state we are in 72 | if [ $ON_AC -eq 1 ]; then 73 | if [ "$ACTIVATE" -eq 1 ]; then 74 | THROTTLE_ETHERNET="$LM_AC_THROTTLE_ETHERNET" 75 | else 76 | THROTTLE_ETHERNET="$NOLM_AC_THROTTLE_ETHERNET" 77 | fi 78 | 79 | # One off a case. 80 | # So that when back on AC, we can resume the speed back to MAX. 81 | if [ x$THROTTLE_ETHERNET = x0 ]; then 82 | THROTTLE_SPEED=$MAX_SPEED; 83 | fi 84 | 85 | if [ x$DISABLE_ETHERNET_ON_BATTERY = x1 ]; then 86 | # We are ON_AC and Disable feature is requested 87 | # So we might be required to re-enable the device. 88 | DISABLE_ETHERNET=0 #zero would mean that the device needs be re-enabled. 89 | else 90 | DISABLE_ETHERNET=2 91 | # IF this is the case, don't touch the device for 92 | # enable/disable 93 | fi 94 | else 95 | THROTTLE_ETHERNET="$BATT_THROTTLE_ETHERNET" 96 | 97 | if [ x$DISABLE_ETHERNET_ON_BATTERY = x1 ]; then 98 | DISABLE_ETHERNET=1 99 | else 100 | DISABLE_ETHERNET=2 101 | fi 102 | fi 103 | 104 | for DEVICE in $ETHERNET_DEVICES ; do 105 | log "VERBOSE" "ethernet: $DEVICE" 106 | 107 | # Wakeup-on-LAN handling 108 | if [ x$DISABLE_WAKEUP_ON_LAN = x1 ] ; then 109 | ret=`$ETHTOOL -s $DEVICE wol d 2>&1` 110 | exit_status=$?; 111 | log "VERBOSE" "$ret" 112 | if [ $exit_status -eq 0 ]; then 113 | log "VERBOSE" "Enabled wakeup-on-LAN for $DEVICE" 114 | else 115 | log "VERBOSE" "Could not enable wakeup-on-LAN for $DEVICE" 116 | fi 117 | fi 118 | 119 | # Handle throttling 120 | if [ x$THROTTLE_ETHERNET = x1 ] ; then 121 | # Handle Speed Throttling 122 | ret=`$ETHTOOL -s $DEVICE speed $THROTTLE_SPEED 2>&1` 123 | exit_status=$?; 124 | log "VERBOSE" "$ret"; 125 | if [ $exit_status -eq 0 ]; then 126 | log "VERBOSE" "Throttled speed to $THROTTLE_SPEED Mbit for $DEVICE" 127 | else 128 | log "VERBOSE" "Could not throttle speed for $DEVICE" 129 | fi 130 | fi 131 | 132 | # Shut down interface 133 | if [ x$DISABLE_ETHERNET = x1 -a $carrier = "false" ]; then 134 | log "VERBOSE" "ethernet: Disabling ethernet device $DEVICE" 135 | $IPTOOL link set dev $DEVICE down 136 | elif [ x$DISABLE_ETHERNET = x0 ]; then 137 | $IPTOOL link set dev $DEVICE up 138 | log "VERBOSE" "ethernet: Re-enabling ethernet device $DEVICE" 139 | fi 140 | 141 | done 142 | else 143 | log "VERBOSE" "Ethernet module is disabled." 144 | fi 145 | 146 | -------------------------------------------------------------------------------- /etc/laptop-mode/conf.d/configuration-file-control.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for Laptop Mode Tools module configuration-file-control. 3 | # 4 | # For more information, consult the laptop-mode.conf(8) manual page. 5 | # 6 | 7 | ############################################################################### 8 | # Configuration file control 9 | # -------------------------- 10 | # 11 | #__COMMENT Laptop mode tools can automatically swap out configuration files depending on 12 | #__COMMENT the power state of your system. 13 | #__COMMENT 14 | #__COMMENT The primary use for this feature is for controlling the configuration files 15 | #__COMMENT of syslog daemons. Syslog daemons have a tendency to sync their log files when 16 | #__COMMENT entries are written to them. This causes disks to spin up, which is not very 17 | #__COMMENT nice when you're trying to save power. The syslog.conf can be tweaked to *not* 18 | #__COMMENT sync a given file, by prepending the log file name with a dash, like this: 19 | #__COMMENT 20 | #__COMMENT mail.* -/var/log/mail/mail.log 21 | #__COMMENT 22 | #__COMMENT Using the following options, you can let laptop mode switch between 23 | #__COMMENT different configurations depending on whether you are working on 24 | #__COMMENT battery or on AC power. 25 | #__COMMENT 26 | #__COMMENT 27 | #__COMMENT IMPORTANT NOTE 28 | #__COMMENT -------------- 29 | #__COMMENT 30 | #__COMMENT This feature will NOT work if CONTROL_SYSLOG_CONF is set in laptop-mode.conf. 31 | #__COMMENT To start using this feature, remove the CONTROL_SYSLOG_CONF section in 32 | #__COMMENT laptop-mode.conf, and then restart the laptop-mode-tools service. 33 | #__COMMENT 34 | #__COMMENT Note that the new config files will have different names than the old ones, 35 | #__COMMENT and that settings are NOT migrated. You will have to do this manually. 36 | # 37 | ############################################################################### 38 | 39 | # Enable debug mode for this module 40 | # Set to 1 if you want to debug this module 41 | DEBUG=0 42 | 43 | # 44 | # Should laptop mode tools control which configuration files should be used? 45 | # 46 | CONTROL_CONFIG_FILES=0 47 | 48 | 49 | # 50 | # Specify the configuration files that you want to control, as a space-separated 51 | # list. 52 | # 53 | # The specific configuration files will be named as follows: 54 | # 55 | # -nolm-ac 56 | # -lm-ac 57 | # -batt 58 | # 59 | # The first file will be used when the system is on AC power and laptop mode 60 | # is not active. The second file will be used when the system is on AC power and 61 | # laptop mode is active. The third file will be used when the system is on 62 | # battery power. 63 | # 64 | # When the laptop mode tools service is enabled, it will replace the 65 | # configuration files with a symlink to one of the three state-based 66 | # configuration files. The original configuration file will be saved as 67 | # .lmbackup, and it will be restored when the laptop mode tools 68 | # service is disabled. 69 | # 70 | # When you add files to this list, make sure to also add the appropriate 71 | # programs and services to the configuration settings below. 72 | # 73 | # You can create the alternate configuration files yourself. If you don't, they 74 | # will be created by laptop mode tools the next time it is restarted. To force 75 | # the files to be created, run the laptop mode tools init script with the 76 | # "restart" parameter. 77 | # 78 | CONFIG_FILES="/etc/syslog.conf /etc/syslog-ng/syslog-ng.conf /etc/rsyslog.conf" 79 | 80 | 81 | # 82 | # Signal these programs and reload these services when configuration files hav 83 | # been replaced. 84 | # 85 | # Programs in CONFIG_FILE_SIGNAL_PROGRAMS receive the SIGHUP signal after 86 | # configuration files have been replaced. All common syslog daemons interpret 87 | # this as an instruction to reload their config files, it may work for other 88 | # daemons as well but your mileage may vary. 89 | # 90 | # For services listed in CONFIG_FILE_RELOAD_SERVICES, laptop mode tools will 91 | # call the init script with the "reload" parameter after configuration files 92 | # have been replaced. 93 | # 94 | CONFIG_FILE_SIGNAL_PROGRAMS="syslogd syslog-ng rsyslogd" 95 | CONFIG_FILE_RELOAD_SERVICES="" 96 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/wireless-power: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module, called from /usr/sbin/laptop_mode. 4 | # Configuration in /etc/laptop-mode/conf.d/wireless-power.conf. 5 | # 6 | # PURPOSE: power saving for generic wireless adapters that support 7 | # the iwconfig power command. 8 | # 9 | 10 | [ "$WIRELESS_POWER_SAVING_EXCLUDE_DRIVERS" ] || WIRELESS_POWER_SAVING_EXCLUDE_DRIVERS="iwl3945 iwl4965 iwlagn ipw3945 ipw2200 ipw2100" 11 | 12 | # 13 | # Find all the wireless devices that do not use an excluded driver. 14 | # Place the interface names on the list WIFI_IFNAMES. 15 | # 16 | findWifiIfs () { 17 | local SYSDEVICE EXCLUDED LINK_TARGET DRIVER IFNAME EXCLUDED_DRIVER; 18 | 19 | for SYSDEVICE in /sys/class/net/*; do 20 | IFNAME=`basename $SYSDEVICE` 21 | 22 | # Check if it is a wireless device 23 | # 24 | if isWifiIf $IFNAME; then 25 | # Yes, it is a wireless device. 26 | if [ -h $SYSDEVICE/device/driver ]; then 27 | # Read the driver name 28 | LINK_TARGET=`readlink $SYSDEVICE/device/driver` 29 | DRIVER=${LINK_TARGET##*/} 30 | 31 | EXCLUDED=0 32 | for EXCLUDED_DRIVER in $WIRELESS_POWER_SAVING_EXCLUDE_DRIVERS ; do 33 | if [ "$EXCLUDED_DRIVER" = "$DRIVER" ] ; then 34 | log "VERBOSE" "Wireless interface $IFNAME excluded for wireless-power by driver name." 35 | EXCLUDED=1 36 | fi 37 | done 38 | if [ $EXCLUDED = 0 ] ; then 39 | # add the interface name to the list 40 | WIFI_IFNAMES="$WIFI_IFNAMES $IFNAME" 41 | fi 42 | fi 43 | 44 | fi 45 | done 46 | } 47 | 48 | isWifiIf() { 49 | local IF=$1 50 | 51 | if [ -n "$IW" ]; then 52 | $IW dev $IF info > /dev/null 2>&1 53 | ret=$? 54 | else 55 | # Inverting return values, we get "0" for wireless device, 56 | # and "1" for non-wireless device. 57 | ($IWCONFIG $IF 2>&1 | grep -q "no wireless extensions.") && ret=1 || ret=0 58 | fi 59 | 60 | return $ret 61 | } 62 | 63 | setPowerSave() { 64 | local IF=$1 65 | local ONOFF=$2 66 | 67 | if [ -n "$IW" ]; then 68 | $IW dev $IF set power_save $ONOFF 69 | else 70 | $IWCONFIG $IF power $ONOFF 71 | if [ $ONOFF = "on" ]; then 72 | $IWCONFIG $IF txpower auto 73 | else 74 | $IWCONFIG $IF txpower fixed 75 | fi 76 | fi 77 | } 78 | 79 | if [ x$CONTROL_WIRELESS_POWER_SAVING = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_WIRELESS_POWER_SAVING = xauto ]; then 80 | log "VERBOSE" "Setting power saving for generic wireless interfaces." 81 | 82 | # Provide defaults for config file settings 83 | [ "$WIRELESS_AC_POWER_SAVING" ] || WIRELESS_AC_POWER_SAVING=0 84 | [ "$WIRELESS_BATT_POWER_SAVING" ] || WIRELESS_BATT_POWER_SAVING=1 85 | 86 | # Find executables 87 | if [ -x /sbin/iw ] ; then 88 | IW=/sbin/iw 89 | elif [ -x /usr/sbin/iw ] ; then 90 | IW=/usr/sbin/iw 91 | else 92 | log "VERBOSE" "iw is not installed" 93 | if [ -x /sbin/iwconfig ] ; then 94 | IWCONFIG=/sbin/iwconfig 95 | elif [ -x /usr/sbin/iwconfig ] ; then 96 | IWCONFIG=/usr/sbin/iwconfig 97 | else 98 | log "VERBOSE" "iwconfig is not installed" 99 | IW=/bin/false 100 | fi 101 | fi 102 | 103 | # Translate 1 => on, 0 => off 104 | WIRELESS_AC_POWER_SAVING_ONOFF="off" 105 | WIRELESS_BATT_POWER_SAVING_ONOFF="off" 106 | [ "$WIRELESS_AC_POWER_SAVING" = 1 ] && WIRELESS_AC_POWER_SAVING_ONOFF="on" 107 | [ "$WIRELESS_BATT_POWER_SAVING" = 1 ] && WIRELESS_BATT_POWER_SAVING_ONOFF="on" 108 | 109 | WIFI_IFNAMES="" 110 | findWifiIfs 111 | for IF in $WIFI_IFNAMES ; do 112 | if [ $ON_AC -eq 1 ] ; then 113 | log "VERBOSE" "On AC power: setting power saving mode for $IF to $WIRELESS_AC_POWER_SAVING_ONOFF." 114 | if ! setPowerSave $IF $WIRELESS_AC_POWER_SAVING_ONOFF; then 115 | log "ERR" "Failed to re-set power saving mode for wireless card" 116 | else 117 | log "VERBOSE" "On AC power: Successfully set power saving mode for $IF to $WIRELESS_AC_POWER_SAVING_ONOFF." 118 | fi 119 | else 120 | log "VERBOSE" "On battery: setting power saving mode for $IF to $WIRELESS_BATT_POWER_SAVING_ONOFF." 121 | if ! setPowerSave $IF $WIRELESS_BATT_POWER_SAVING_ONOFF; then 122 | log "ERR" "Failed to set power saving mode for wireless card" 123 | else 124 | log "VERBOSE" "On battery: Successfully set power saving mode for $IF to $WIRELESS_BATT_POWER_SAVING_ONOFF." 125 | fi 126 | fi 127 | done 128 | else 129 | log "VERBOSE" "Generic wireless interface power saving module is disabled." 130 | fi 131 | 132 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/start-stop-programs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: start and stop programs 4 | # 5 | 6 | if [ x$CONTROL_START_STOP = x1 ] ; then 7 | 8 | 9 | # 10 | # Release the locks. The global locks of LMT get inherited by all sub-processes 11 | # which, further, gets inherited by all programs that are run as part of this 12 | # module, including daemon. By releasing the lock for this shell process, we ensure 13 | # that the daemons will not hold lock to the LMT locks. 14 | # 15 | 16 | # TODO: Variablize the lock descriptors and then use them instead 17 | log "VERBOSE" "Prepare to release locks for descriptors 8 & 9" 18 | exec 8>&- 19 | exec 9>&- 20 | log "VERBOSE" "Released locks for descriptors 8 & 9" 21 | 22 | 23 | # 24 | # Undo the previous state. 25 | # 26 | if [ -f /var/run/laptop-mode-tools/start-stop-undo-actions ] ; then 27 | cat /var/run/laptop-mode-tools/start-stop-undo-actions | \ 28 | while read SCRIPT STARTSTOPACTION ; do 29 | $SCRIPT $STARTSTOPACTION 30 | done 31 | fi 32 | 33 | # 34 | # Apply the new state, if LMT is enabled. 35 | # 36 | if [ "$STATE" = "enabled" ]; then 37 | # Empty undo file first. We write the actions we take 38 | # into this file, so that we can undo them at the 39 | # next state change. Note: we actually 40 | # write the actions to the file in reverse order, 41 | # so we can execute the commands easily afterwards. 42 | echo > /var/run/laptop-mode-tools/start-stop-undo-actions 43 | 44 | 45 | if [ $ON_AC -eq 1 ] ; then 46 | if [ "$ACTIVATE" -eq 1 ] ; then 47 | START_STOP_DIR_PREFIX=/etc/laptop-mode/lm-ac 48 | START_SERVICES="$LM_AC_START" 49 | STOP_SERVICES="$LM_AC_STOP" 50 | else 51 | START_STOP_DIR_PREFIX=/etc/laptop-mode/nolm-ac 52 | START_SERVICES="$NOLM_AC_START" 53 | STOP_SERVICES="$NOLM_AC_STOP" 54 | fi 55 | else 56 | START_STOP_DIR_PREFIX=/etc/laptop-mode/batt 57 | START_SERVICES="$BATT_START" 58 | STOP_SERVICES="$BATT_STOP" 59 | fi 60 | START_DIR="$START_STOP_DIR_PREFIX"-start 61 | STOP_DIR="$START_STOP_DIR_PREFIX"-stop 62 | if [ -d "$STOP_DIR" ] ; then 63 | for SCRIPT in "$STOP_DIR"/* ; do 64 | if [ -e "$SCRIPT" ] ; then 65 | log "VERBOSE" "Stopping $SCRIPT" 66 | "$SCRIPT" stop 67 | # Dereference any links. When people configure 68 | # the directories with links and then they remove 69 | # links while laptop mode is active, the "undo" 70 | # will fail if we don't dereference the links 71 | # before storing them. 72 | LINKTARGET=`readlink -f "$SCRIPT"` 73 | sed -i "1i $LINKTARGET start" /var/run/laptop-mode-tools/start-stop-undo-actions 74 | fi 75 | done 76 | fi 77 | if [ -d "$START_DIR" ] ; then 78 | for SCRIPT in "$START_DIR"/* ; do 79 | if [ -e "$SCRIPT" ] ; then 80 | log "VERBOSE" "Starting $SCRIPT" 81 | "$SCRIPT" start 82 | LINKTARGET=`readlink -f "$SCRIPT"` 83 | sed -i "1i $LINKTARGET stop" /var/run/laptop-mode-tools/start-stop-undo-actions 84 | fi 85 | done 86 | fi 87 | 88 | 89 | log "VERBOSE" "START_SERVICES = $START_SERVICES" 90 | log "VERBOSE" "STOP_SERVICES = $STOP_SERVICES" 91 | if [ "$START_SERVICES" != "" -o "$STOP_SERVICES" != "" ] ; then 92 | log "MSG" "Starting/stopping services" 93 | 94 | # Determine how we can start/restart services. 95 | 96 | STARTCMD='$RCPROG$SERVICE start' 97 | STOPCMD='$RCPROG$SERVICE stop' 98 | if ( ps -e | grep " systemd$" > /dev/null ) ; then 99 | # Systemd 100 | STARTCMD='systemctl start $SERVICE' 101 | STOPCMD='systemctl stop $SERVICE' 102 | elif ( which invoke-rc.d > /dev/null ) ; then 103 | # Debian uses invoke-rc.d 104 | RCPROG="invoke-rc.d " 105 | INITSCRIPT=laptop-mode 106 | elif ( which service > /dev/null ) ; then 107 | # RedHat uses service 108 | RCPROG="service " 109 | INITSCRIPT=laptop-mode 110 | else 111 | # Any other -- we start the init script it ourselves. 112 | 113 | # Try non-link directories first, then try links. This helps if one of 114 | # the locations is linked to another, which is the case on some distros. 115 | if [ -d /etc/rc.d/init.d -a ! -L /etc/rc.d/init.d ] ; then 116 | INIT_D=/etc/rc.d/init.d 117 | elif [ -d /etc/rc.d -a ! -L /etc/rc.d -a ! -d /etc/rc.d/init.d ] ; then 118 | INIT_D=/etc/rc.d 119 | elif [ -d /etc/init.d -a ! -L /etc/init.d ] ; then 120 | INIT_D=/etc/init.d 121 | elif [ -d /etc/rc.d/init.d ] ; then 122 | INIT_D=/etc/rc.d/init.d 123 | elif [ -d /etc/rc.d ] ; then 124 | INIT_D=/etc/rc.d 125 | elif [ -d /etc/init.d ] ; then 126 | INIT_D=/etc/init.d 127 | else 128 | log "ERR" "Cannot determine location of init scripts." 129 | exit 1 130 | fi 131 | 132 | RCPROG="$INIT_D/" 133 | fi 134 | 135 | for SERVICE in $STOP_SERVICES ; do 136 | log "VERBOSE" "Stopping service $SERVICE." 137 | eval $STOPCMD 138 | sed -i "1i $(eval echo $STARTCMD)" /var/run/laptop-mode-tools/start-stop-undo-actions 139 | done 140 | for SERVICE in $START_SERVICES ; do 141 | log "VERBOSE" "Starting service $SERVICE." 142 | eval $STARTCMD 143 | sed -i "1i $(eval echo $STOPCMD)" /var/run/laptop-mode-tools/start-stop-undo-actions 144 | done 145 | fi 146 | fi 147 | fi 148 | 149 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/wireless-ipw-power: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: power saving for IPW3945, IPW2200 and IPW2100 using 4 | # the Intel ipw drivers. 5 | # 6 | # 7 | # This script relies upon the name of the driver. 8 | # 9 | # Original source: http://ubuntuforums.org/showthread.php?t=419772 10 | 11 | if [ x$CONTROL_IPW_POWER = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_IPW_POWER = xauto ]; then 12 | 13 | # Provide defaults for config file settings 14 | [ "$IPW3945_AC_POWER" ] || IPW3945_AC_POWER=6 15 | [ "$IPW3945_BATT_POWER" ] || IPW3945_BATT_POWER=7 16 | [ "$IPW2100_AC_POWER" ] || IPW3945_AC_POWER=0 17 | [ "$IPW2100_BATT_POWER" ] || IPW3945_BATT_POWER=5 18 | 19 | I3945_DRIVERNAME=ipw3945 20 | I2200_DRIVERNAME=ipw2200 21 | I2100_DRIVERNAME=ipw2100 22 | 23 | # find executables 24 | if [ -x /sbin/iwpriv ] ; then 25 | IWPRIV=/sbin/iwpriv 26 | elif [ -x /usr/sbin/iwpriv ] ; then 27 | IWPRIV=/usr/sbin/iwpriv 28 | else 29 | log "VERBOSE" "iwpriv is not installed" 30 | IWPRIV=/bin/false 31 | fi 32 | if [ -x /sbin/iwconfig ] ; then 33 | IWCONFIG=/sbin/iwconfig 34 | elif [ -x /usr/sbin/iwconfig ] ; then 35 | IWCONFIG=/usr/sbin/iwconfig 36 | else 37 | log "VERBOSE" "iwconfig is not installed" 38 | IWCONFIG=/bin/false 39 | fi 40 | 41 | SET_I3945_AC_PARMS="set_power $IPW3945_AC_POWER" 42 | SET_I3945_BAT_PARMS="set_power $IPW3945_BATT_POWER" 43 | 44 | SET_I2200_AC_PARMS="power off" 45 | SET_I2200_BAT_PARMS="power on" 46 | 47 | # Note the fact that we're setting "power on" on both AC and battery. 48 | # This is due to the fact that the second statement will have no effect 49 | # if we turn power management off completely, and some laptops will 50 | # reportedly get very hot if you turn off power management on the 51 | # IPW2100. 52 | SET_I2100_AC_PARMS_1="power on" 53 | SET_I2100_BAT_PARMS_1="power on" 54 | SET_I2100_AC_PARMS_2="set_power $IPW2100_AC_POWER" 55 | SET_I2100_BAT_PARMS_2="set_power $IPW2100_BATT_POWER" 56 | 57 | 58 | # 59 | # Find all the wireless devices using the supplied driver names. 60 | # Place the interface names on the list WIFI_IFNAMES. 61 | # 62 | findWifiIfsByDriver() { 63 | local DEVICE; 64 | local LINK_TARGET; 65 | local ENABLED; 66 | WIFI_IFNAMES="" 67 | 68 | for DEVICE in /sys/class/net/*; do 69 | if [ -d $DEVICE/wireless -a -h $DEVICE/device/driver ]; then 70 | # See if the driver for $DEVICE matches the supplied one by checking the link to 71 | # the driver. 72 | LINK_TARGET=`readlink $DEVICE/device/driver` 73 | LINK_TARGET=${LINK_TARGET##*/} 74 | ENABLED=`[ -r $DEVICE/device/enabled ] && cat $DEVICE/device/enabled || cat $DEVICE/device/enable` 75 | 76 | if [ $ENABLED -eq 1 -a "$LINK_TARGET" = "$1" ]; then 77 | # add the interface name to the list 78 | WIFI_IFNAMES="$WIFI_IFNAMES ${DEVICE##*/}" 79 | else 80 | log "VERBOSE" "$DEVICE doesn't seem to be enabled. Radio Switched off?"; 81 | fi 82 | else 83 | # LP: #369113 84 | # Kernel's 2.6.29 and above have been reported to be missing 85 | # the $DEVICE/wireless folder. 86 | dev=`basename $DEVICE` 87 | 88 | # Inverting return values, we get "0" for wireless device, 89 | # and "1" for non-wireless device. 90 | ($IWCONFIG $dev 2>&1 | grep -q "no wireless extensions.") && ret=1 || ret=0 91 | if [ "$ret" = "0" ]; then 92 | # add the interface name to the list 93 | WIFI_IFNAMES="$WIFI_IFNAMES ${DEVICE##*/}" 94 | fi 95 | fi 96 | done 97 | } 98 | 99 | 100 | # 101 | # Set all the adaptors using the supplied driver into the supplied 102 | # power saving mode 103 | # 104 | # $1 - driver name 105 | # $2 - power command 106 | # $3 - power command arguments 107 | # 108 | setWifiPwrSave () { 109 | local DEVICE; 110 | findWifiIfsByDriver $1; 111 | 112 | for DEVICE in $WIFI_IFNAMES; do 113 | log "VERBOSE" "Wireless power saving: $2 $DEVICE $3" 114 | $2 $DEVICE $3 115 | done 116 | } 117 | 118 | intel3945_BatPwrSave () { 119 | setWifiPwrSave "$I3945_DRIVERNAME" "$IWPRIV" "$SET_I3945_BAT_PARMS" 120 | } 121 | 122 | intel3945_AcPwrSave () { 123 | setWifiPwrSave "$I3945_DRIVERNAME" "$IWPRIV" "$SET_I3945_AC_PARMS" 124 | } 125 | 126 | intel2200_BatPwrSave () { 127 | setWifiPwrSave "$I2200_DRIVERNAME" "$IWCONFIG" "$SET_I2200_BAT_PARMS" 128 | } 129 | 130 | intel2200_AcPwrSave () { 131 | setWifiPwrSave "$I2200_DRIVERNAME" "$IWCONFIG" "$SET_I2200_AC_PARMS" 132 | } 133 | 134 | intel2100_BatPwrSave () { 135 | setWifiPwrSave "$I2100_DRIVERNAME" "$IWCONFIG" "$SET_I2100_BAT_PARMS_1" 136 | setWifiPwrSave "$I2100_DRIVERNAME" "$IWPRIV" "$SET_I2100_BAT_PARMS_2" 137 | } 138 | 139 | intel2100_AcPwrSave () { 140 | setWifiPwrSave "$I2100_DRIVERNAME" "$IWCONFIG" "$SET_I2100_AC_PARMS_1" 141 | setWifiPwrSave "$I2100_DRIVERNAME" "$IWPRIV" "$SET_I2100_BAT_PARMS_2" 142 | } 143 | 144 | 145 | if [ $ON_AC -eq 1 ] ; then 146 | [ -d /sys/module/$I3945_DRIVERNAME ] && intel3945_AcPwrSave 147 | [ -d /sys/module/$I2200_DRIVERNAME ] && intel2200_AcPwrSave 148 | [ -d /sys/module/$I2100_DRIVERNAME ] && intel2100_AcPwrSave 149 | else 150 | [ -d /sys/module/$I3945_DRIVERNAME ] && intel3945_BatPwrSave 151 | [ -d /sys/module/$I2200_DRIVERNAME ] && intel2200_BatPwrSave 152 | [ -d /sys/module/$I2100_DRIVERNAME ] && intel2100_BatPwrSave 153 | fi 154 | else 155 | log "VERBOSE" "Intel IPW Wireless power setting is disabled." 156 | fi 157 | 158 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/cpufreq: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module to handle CPU frequency settings. 4 | # 5 | 6 | # Set kernel setting, showing an error if this fails. 7 | # Parameter 1: sysctl/proc path 8 | # Parameter 2: the value 9 | set_sysctl() { 10 | log "VERBOSE" "Executing: echo $2 > $1" 11 | if ! echo "$2" > "$1" ; then 12 | echo "SETTING OF KERNEL PARAMETER FAILED: echo $2 \> $1" 13 | fi 14 | } 15 | 16 | 17 | # 18 | # get_medium_value 19 | # 20 | # Get the medium value from a list of numerical values. 21 | # $1 = file containing the list of values 22 | # 23 | get_medium_value() { 24 | cat "$1" | tr ' ' '\n' | sort -n | awk -v RS="" '{n=split($0,a); print a[int((n+1)/2)]}' 25 | } 26 | 27 | # get_real_cpu_governor trys to correct the special governor "auto": 28 | # 29 | # 1. use ondemand on CPUs that are not using intel_pstate driver. 30 | # 2. on CPUs that are using intel_psatte driver: 31 | # - use powersave if the machine is on battery 32 | # - otherwise use performance. 33 | # 34 | # $1 = the CPU to be set governor on. 35 | # $2 = the governor to use. 36 | get_real_cpu_governor() { 37 | local CPU=$1 38 | local GOVERNOR=$2 39 | if [ x$GOVERNOR = xauto ]; then 40 | if [ -f "$CPU/cpufreq/scaling_driver" ] && 41 | [ "$(cat $CPU/cpufreq/scaling_driver)" = "intel_pstate" ] 42 | then 43 | if [ $ON_AC -eq 1 ] ; then 44 | GOVERNOR=performance 45 | else 46 | GOVERNOR=powersave 47 | fi 48 | else 49 | GOVERNOR=ondemand 50 | fi 51 | fi 52 | echo $GOVERNOR 53 | } 54 | 55 | 56 | if [ x$CONTROL_CPU_FREQUENCY = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_CPU_FREQUENCY = xauto ]; then 57 | if [ $ON_AC -eq 1 ] ; then 58 | if [ "$ACTIVATE" -eq 1 ] ; then 59 | CPU_MAXFREQ="$LM_AC_CPU_MAXFREQ" 60 | CPU_MINFREQ="$LM_AC_CPU_MINFREQ" 61 | CPU_GOVERNOR="$LM_AC_CPU_GOVERNOR" 62 | CPU_IGNORE_NICE_LOAD="$LM_AC_CPU_IGNORE_NICE_LOAD" 63 | else 64 | CPU_MAXFREQ="$NOLM_AC_CPU_MAXFREQ" 65 | CPU_MINFREQ="$NOLM_AC_CPU_MINFREQ" 66 | CPU_GOVERNOR="$NOLM_AC_CPU_GOVERNOR" 67 | CPU_IGNORE_NICE_LOAD="$NOLM_AC_CPU_IGNORE_NICE_LOAD" 68 | fi 69 | else 70 | CPU_MAXFREQ="$BATT_CPU_MAXFREQ" 71 | CPU_MINFREQ="$BATT_CPU_MINFREQ" 72 | CPU_GOVERNOR="$BATT_CPU_GOVERNOR" 73 | CPU_IGNORE_NICE_LOAD="$BATT_CPU_IGNORE_NICE_LOAD" 74 | fi 75 | for THISCPU in /sys/devices/system/cpu/* ; do 76 | CPU_GOVERNOR="$(get_real_cpu_governor $THISCPU $CPU_GOVERNOR)" 77 | if [ -e $THISCPU/cpufreq/cpuinfo_min_freq ]; then 78 | THIS_CPU_MAXFREQ="$CPU_MAXFREQ" 79 | THIS_CPU_MINFREQ="$CPU_MINFREQ" 80 | THIS_CPU_GOVERNOR="$CPU_GOVERNOR" 81 | THIS_CPU_IGNORE_NICE_LOAD="$CPU_IGNORE_NICE_LOAD" 82 | 83 | case "$CPU_MAXFREQ" in 84 | "slowest") 85 | THIS_CPU_MAXFREQ=`cat $THISCPU/cpufreq/cpuinfo_min_freq` 86 | ;; 87 | "medium") 88 | THIS_CPU_MAXFREQ=$(get_medium_value $THISCPU/cpufreq/scaling_available_frequencies) 89 | if [ -z "$THIS_CPU_MAXFREQ" ] ; then 90 | THIS_CPU_MAXFREQ=`cat $THISCPU/cpufreq/cpuinfo_max_freq` 91 | THIS_CPU_MAXFREQ="$(( $THIS_CPU_MAXFREQ / 2 ))" 92 | fi 93 | ;; 94 | "fastest") 95 | THIS_CPU_MAXFREQ=`cat $THISCPU/cpufreq/cpuinfo_max_freq` 96 | ;; 97 | esac 98 | 99 | case "$CPU_MINFREQ" in 100 | "slowest") 101 | THIS_CPU_MINFREQ=`cat $THISCPU/cpufreq/cpuinfo_min_freq` 102 | ;; 103 | "medium") 104 | THIS_CPU_MINFREQ=$(get_medium_value $THISCPU/cpufreq/scaling_available_frequencies) 105 | if [ -z "$THIS_CPU_MAXFREQ" ] ; then 106 | THIS_CPU_MAXFREQ=`cat $THISCPU/cpufreq/cpuinfo_max_freq` 107 | THIS_CPU_MAXFREQ="$(( $THIS_CPU_MAXFREQ / 2 ))" 108 | fi 109 | ;; 110 | "fastest") 111 | THIS_CPU_MINFREQ=`cat $THISCPU/cpufreq/cpuinfo_max_freq` 112 | ;; 113 | esac 114 | 115 | log "VERBOSE" "Setting CPU maximum frequency for cpu $THISCPU to $THIS_CPU_MAXFREQ." 116 | set_sysctl $THISCPU/cpufreq/scaling_max_freq $THIS_CPU_MAXFREQ 117 | log "VERBOSE" "Setting CPU minimum frequency for cpu $THISCPU to $THIS_CPU_MINFREQ." 118 | set_sysctl $THISCPU/cpufreq/scaling_min_freq $THIS_CPU_MINFREQ 119 | log "VERBOSE" "Setting CPU frequency governor for cpu $THISCPU to $THIS_CPU_GOVERNOR." 120 | log "VERBOSE" "`/sbin/modprobe -q cpufreq_$THIS_CPU_GOVERNOR 2>&1`" 121 | set_sysctl $THISCPU/cpufreq/scaling_governor $THIS_CPU_GOVERNOR 122 | 123 | # Retain for backward compatibility 124 | if [ -f "$THISCPU/cpufreq/$THIS_CPU_GOVERNOR/ignore_nice_load" ] ; then 125 | log "VERBOSE" "Setting CPU ignore_nice_load for cpu $THISCPU to $THIS_CPU_IGNORE_NICE_LOAD." 126 | set_sysctl $THISCPU/cpufreq/$THIS_CPU_GOVERNOR/ignore_nice_load $THIS_CPU_IGNORE_NICE_LOAD 127 | else 128 | log "VERBOSE" "Not setting CPU ignore_nice_load for cpu $THISCPU." 129 | log "VERBOSE" "File $THISCPU/cpufreq/$THIS_CPU_GOVERNOR/ignore_nice_load does not exist." 130 | fi 131 | fi 132 | done 133 | 134 | # For kernels 2.6.32 and above, the sysfs interface for OnDemand per-core power savings has changed. 135 | # Instead of per-core, the new interface is generic and a single one 136 | if [ -f "/sys/devices/system/cpu/cpufreq/$THIS_CPU_GOVERNOR/ignore_nice_load" ]; then 137 | log "VERBOSE" "Setting CPU ignore_nice_load for all cpus" 138 | set_sysctl /sys/devices/system/cpu/cpufreq/$THIS_CPU_GOVERNOR/ignore_nice_load $CPU_IGNORE_NICE_LOAD 139 | else 140 | log "VERBOSE" "No generic CPU ignore_nice_load interface available" 141 | fi 142 | fi 143 | 144 | if [ x$CONTROL_CPU_THROTTLING = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_CPU_THROTTLING = xauto ]; then 145 | if [ $ON_AC -eq 1 ] ; then 146 | if [ "$ACTIVATE" -eq 1 ] ; then 147 | CPU_THROTTLING="$LM_AC_CPU_THROTTLING" 148 | else 149 | CPU_THROTTLING="$NOLM_AC_CPU_THROTTLING" 150 | fi 151 | else 152 | CPU_THROTTLING="$BATT_CPU_THROTTLING" 153 | fi 154 | for THISCPU in /proc/acpi/processor/* ; do 155 | if [ -e $THISCPU/throttling ]; then 156 | NUM_LEVELS=`cat $THISCPU/throttling | grep "T[0123456789]*\:" | wc -l` 157 | case "$CPU_THROTTLING" in 158 | "minimum") 159 | THIS_CPU_THROTTLING=0 160 | ;; 161 | "medium") 162 | # Divide but round up: that way, "medium" on a two-level system will 163 | # lead to full throttling -- which is 50% on my system, quite reasonable. 164 | THIS_CPU_THROTTLING=$(( ($NUM_LEVELS / 2 ) )) 165 | ;; 166 | "maximum") 167 | THIS_CPU_THROTTLING=$(($NUM_LEVELS - 1)) 168 | ;; 169 | *) 170 | THIS_CPU_THROTTLING="$CPU_THROTTLING" 171 | esac 172 | 173 | log "VERBOSE" "Setting throttling level for cpu $THISCPU to $THIS_CPU_THROTTLING." 174 | set_sysctl $THISCPU/throttling $THIS_CPU_THROTTLING 175 | fi 176 | done 177 | fi 178 | 179 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/runtime-pm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: runtime-pm 4 | # 5 | 6 | # Check whether a device is listed by ID 7 | listed_by_id() { 8 | device=$1 9 | list=$2 10 | 11 | if ! { read -r idvendor < $device/idVendor || read -r idvendor < $device/vendor; } 2>/dev/null || \ 12 | ! { read -r idproduct < $device/idProduct || read -r idproduct < $device/device; } 2>/dev/null; then 13 | return 1 14 | fi 15 | idvendor=${idvendor#0x} 16 | idproduct=${idproduct#0x} 17 | 18 | for devid in $list; do 19 | if [ "$devid" = "$idvendor:$idproduct" ]; then 20 | return 0 21 | fi 22 | done 23 | return 1 24 | } 25 | 26 | # Check whether the driver type is blacklisted 27 | listed_by_type() { 28 | device=$1 29 | device_base=${device##*/} 30 | list=$2 31 | 32 | [ -r $device/uevent ] || return 1 33 | 34 | while read -r uevent_data; do 35 | for driver_type in $list; do 36 | case "$uevent_data" in 37 | DRIVER=$driver_type) return 0 ;; 38 | DEVTYPE=$driver_type) return 0 ;; 39 | esac 40 | done 41 | done < $device/uevent 42 | 43 | # Check child devices as well. The actual driver type is 44 | # listed in a child device, not the top-level device. 45 | for subdevice in $device/$device_base*; do 46 | [ -r $subdevice/uevent ] || continue 47 | 48 | if listed_by_type "$subdevice" "$list"; then 49 | return 0; 50 | fi 51 | done 52 | return 1 53 | } 54 | 55 | # Checks whether a device is blacklisted by either ID or driver type 56 | blacklisted() { 57 | listed_by_id $1 "$AUTOSUSPEND_RUNTIME_DEVID_BLACKLIST"\ 58 | || listed_by_type $1 "$AUTOSUSPEND_RUNTIME_DEVTYPE_BLACKLIST"\ 59 | || return 1 60 | return 0 61 | } 62 | 63 | # Checks whether a device is whitelisted by either ID or driver type 64 | whitelisted() { 65 | listed_by_id $1 "$AUTOSUSPEND_RUNTIME_DEVID_WHITELIST"\ 66 | || listed_by_type $1 "$AUTOSUSPEND_RUNTIME_DEVTYPE_WHITELIST"\ 67 | || return 1 68 | return 0 69 | } 70 | 71 | if $LM_VERBOSE; then 72 | echo_to_file() { 73 | echo "$1" 2>&1 >"$2" | 74 | while read REPLY; do 75 | log "VERBOSE" "$REPLY" 76 | done 77 | } 78 | else 79 | echo_to_file() { 80 | echo "$1" > "$2" 2>/dev/null 81 | } 82 | fi 83 | 84 | if [ x$CONTROL_RUNTIME_AUTOSUSPEND = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_RUNTIME_AUTOSUSPEND = xauto ]; then 85 | if [ $ON_AC -eq 1 ]; then 86 | if [ "$ACTIVATE" -eq 1 ]; then 87 | SUSPEND_RUNTIME_DEVICES="$LM_AC_SUSPEND_RUNTIME" 88 | else 89 | SUSPEND_RUNTIME_DEVICES="$NOLM_AC_SUSPEND_RUNTIME" 90 | fi 91 | else 92 | SUSPEND_RUNTIME_DEVICES="$BATT_SUSPEND_RUNTIME" 93 | fi 94 | 95 | if [ "$DEVICES" != "" ]; then 96 | # If a list of devices has been provided, operate on only the 97 | # listed devices. 98 | DEVICE_LIST="" 99 | for DEVICE in $DEVICES; do 100 | DEVICE_LIST="$DEVICE_LIST $DEVICE" 101 | done 102 | else 103 | # If no list was provided, operate on all devices 104 | DEVICE_LIST=/sys/bus/*/devices/* 105 | fi 106 | 107 | if [ x$SUSPEND_RUNTIME_DEVICES = x1 ]; then 108 | 109 | if [ "$DEVICE_LIST" != "" ]; then 110 | for runtime_device in $DEVICE_LIST; do 111 | 112 | USE_DEVICE=0 113 | if [ x$AUTOSUSPEND_USE_WHITELIST = x1 ]; then 114 | if whitelisted $runtime_device; then 115 | USE_DEVICE=1 116 | else 117 | log "VERBOSE" "Device $runtime_device not whitelisted, skipping auto suspend." 118 | fi 119 | else 120 | if ! blacklisted $runtime_device; then 121 | USE_DEVICE=1 122 | else 123 | log "Device $runtime_device is blacklisted, skipping auto suspend." 124 | fi 125 | fi 126 | 127 | if [ x$USE_DEVICE = x1 ]; then 128 | if [ -f "$runtime_device"/power/autosuspend_delay_ms ]; then 129 | #INFO: Takes value in milliseconds 130 | echo_to_file $(($AUTOSUSPEND_TIMEOUT * 1000)) "$runtime_device"/power/autosuspend_delay_ms 131 | log "VERBOSE" "Enabling auto suspend mode for device $runtime_device" 132 | elif [ -f "$runtime_device"/power/autosuspend ]; then 133 | echo_to_file $AUTOSUSPEND_TIMEOUT "$runtime_device"/power/autosuspend 134 | log "VERBOSE" "Enabling auto suspend mode for device $runtime_device" 135 | else 136 | log "VERBOSE" "Not enabling auto suspend mode for device $runtime_device" 137 | fi 138 | 139 | if [ -f "$runtime_device"/power/control ]; then 140 | echo_to_file "auto" "$runtime_device"/power/control 141 | log "VERBOSE" "Enabling auto power level for device $runtime_device." 142 | elif [ -f "$runtime_device"/power/level ]; then 143 | echo_to_file "auto" "$runtime_device"/power/level 144 | log "VERBOSE" "Enabling auto power level for device $runtime_device." 145 | else 146 | log "VERBOSE" "Not enabling auto power level for device $runtime_device" 147 | fi 148 | fi 149 | done 150 | fi 151 | else 152 | AUTOSUSPEND_TIMEOUT=0 153 | if [ "$DEVICE_LIST" != "" ]; then 154 | for runtime_device in $DEVICE_LIST; 155 | do 156 | 157 | USE_DEVICE=0 158 | if [ x$AUTOSUSPEND_USE_WHITELIST = x1 ]; then 159 | if whitelisted $runtime_device; then 160 | USE_DEVICE=1 161 | else 162 | log "VERBOSE" "Device $runtime_device not whitelisted, skipping auto suspend." 163 | fi 164 | else 165 | if ! blacklisted $runtime_device; then 166 | USE_DEVICE=1 167 | else 168 | log "Device $runtime_device is blacklisted, skipping auto suspend." 169 | fi 170 | fi 171 | [ x$USE_DEVICE = x1 ] || continue 172 | 173 | if [ -f "$runtime_device"/power/autosuspend_delay_ms ]; then 174 | echo_to_file $AUTOSUSPEND_TIMEOUT "$runtime_device"/power/autosuspend_delay_ms 175 | log "VERBOSE" "Disabling auto suspend mode for device $runtime_device." 176 | elif [ -f "$runtime_device"/power/autosuspend ]; then 177 | echo_to_file $AUTOSUSPEND_TIMEOUT "$runtime_device"/power/autosuspend 178 | log "VERBOSE" "Disabling auto suspend mode for device $runtime_device." 179 | else 180 | log "VERBOSE" "Not disabling auto suspend mode for device $runtime_device" 181 | fi 182 | 183 | if [ -f "$runtime_device"/power/control ]; then 184 | echo_to_file "on" "$runtime_device"/power/control 185 | log "VERBOSE" "Enabling ON power level for device $runtime_device." 186 | elif [ -f "$runtime_device"/power/level ]; then 187 | echo_to_file "on" "$runtime_device"/power/level 188 | log "VERBOSE" "Enabling ON power level for device $runtime_device." 189 | else 190 | log "VERBOSE" "Not enabling ON power level for device $runtime_device" 191 | fi 192 | done 193 | fi 194 | fi 195 | else 196 | log "VERBOSE" "RUNTIME autosuspend is disabled." 197 | fi 198 | 199 | -------------------------------------------------------------------------------- /laptop-mode-tools.spec: -------------------------------------------------------------------------------- 1 | # Authority: dag 2 | # Upstream: Ritesh Raj Sarraf 3 | 4 | Summary: Tools for power savings based on battery/AC status 5 | Name: laptop-mode-tools 6 | Version: 1.74 7 | Release: 1 8 | License: GPL 9 | Group: System Environment/Base 10 | URL: http://github.com/rickysarraf/laptop-mode-tools 11 | Vendor: Laptop Mode Tools Developers 12 | Distribution: RPM Based distributions 13 | Packager: Ritesh Raj Sarraf 14 | Source: https://github.com/rickysarraf/laptop-mode-tools/releases/download/%{version}/laptop-mode-tools_%{version}.tar.gz 15 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 16 | 17 | BuildArch: noarch 18 | 19 | %description 20 | Laptop mode is a Linux kernel feature that allows your laptop to save 21 | considerable power, by allowing the hard drive to spin down for longer 22 | periods of time. This package contains the userland scripts that are 23 | needed to enable laptop mode. It includes support for automatically 24 | enabling laptop mode when the computer is working on batteries. In 25 | addition, it provides a set of modules which allow you to apply 26 | various other power savings. 27 | 28 | %prep 29 | %setup -n %{name}_%{version} 30 | 31 | %build 32 | 33 | %{__rm} -rf %{buildroot} 34 | 35 | DESTDIR=%{buildroot} INIT_D="" MAN_D=%{_mandir} INSTALL=install ./install.sh 36 | 37 | # Work around bug in installer. It installs the script in the wrong location if INIT_D="". 38 | rm %{buildroot}/etc/init.d/laptop-mode 39 | 40 | %{__mkdir_p} -m0755 %{buildroot}%{_initrddir} 41 | %{__install} -Dp -m755 etc/init.d/laptop-mode %{buildroot}%{_initrddir} 42 | 43 | %clean 44 | %{__rm} -rf %{buildroot} 45 | 46 | %preun 47 | if [ $1 -eq 0 ]; then 48 | /sbin/service laptop-mode stop &>/dev/null || : 49 | /sbin/chkconfig --del laptop-mode 50 | fi 51 | 52 | %post 53 | /sbin/chkconfig --add laptop-mode 54 | /sbin/service laptop-mode start &>/dev/null || : 55 | /sbin/service acpid restart &>/dev/null || : 56 | 57 | %postun 58 | /sbin/service laptop-mode condrestart &>/dev/null || : 59 | 60 | %files 61 | %defattr(-, root, root, 0755) 62 | 63 | %doc COPYING Documentation/*.txt README.md 64 | %docdir %{_mandir} 65 | %doc %{_mandir}/man8/laptop-mode.conf.8 66 | %doc %{_mandir}/man8/laptop_mode.8 67 | %doc %{_mandir}/man8/lm-profiler.8 68 | %doc %{_mandir}/man8/lm-profiler.conf.8 69 | %doc %{_mandir}/man8/lm-syslog-setup.8 70 | %config %{_sysconfdir}/acpi/actions/lm_*.sh 71 | %config %{_sysconfdir}/acpi/events/lm_* 72 | %config(noreplace) %{_sysconfdir}/laptop-mode/ 73 | %config %{_initrddir}/laptop-mode 74 | /lib/udev/lmt-udev 75 | /lib/systemd/system/laptop-mode.service 76 | /lib/systemd/system/laptop-mode.timer 77 | /lib/systemd/system/lmt-poll.service 78 | /lib/udev/rules.d/99-laptop-mode.rules 79 | 80 | %{_sysconfdir}/apm/event.d/* 81 | %{_sysconfdir}/power/scripts.d/* 82 | %{_sysconfdir}/power/event.d/* 83 | #%{_usr}/sbin/* 84 | %{_sbindir}/* 85 | %{_usr}/share/applications/laptop-mode-tools.desktop 86 | %{_usr}/share/laptop-mode-tools/lmt.py 87 | %{_usr}/share/laptop-mode-tools/modules/* 88 | %{_usr}/share/laptop-mode-tools/module-helpers/* 89 | %{_usr}/share/icons/hicolor/scalable/apps/laptop-mode-tools.svg 90 | %{_usr}/share/polkit-1/actions/org.linux.lmt.gui.policy 91 | %{_usr}/lib/pm-utils/sleep.d/* 92 | %{_usr}/lib/tmpfiles.d/laptop-mode.conf 93 | 94 | 95 | %dir %{_sysconfdir}/acpi/events 96 | %dir %{_sysconfdir}/acpi/actions 97 | %dir %{_usr}/lib/pm-utils/sleep.d 98 | %dir %{_usr}/lib/tmpfiles.d 99 | %dir %{_usr}/share/applications 100 | %dir %{_usr}/share/icons/hicolor/scalable/apps 101 | %dir %{_usr}/share/laptop-mode-tools/modules 102 | %dir %{_usr}/share/laptop-mode-tools/module-helpers 103 | %dir %{_sysconfdir}/apm/event.d 104 | %dir %{_sysconfdir}/power/scripts.d 105 | %dir %{_sysconfdir}/power/event.d 106 | 107 | 108 | %changelog 109 | * Sat Jul 18 2020 Ritesh Raj Sarraf - 1.74-1 110 | - Updated to release 1.74 111 | 112 | * Sat Jan 11 2020 Ritesh Raj Sarraf - 1.73.1-1 113 | - Updated to release 1.73.1 114 | 115 | * Sat Jan 11 2020 Ritesh Raj Sarraf - 1.73-1 116 | - Updated to release 1.73 117 | 118 | * Sat Feb 3 2018 Ritesh Raj Sarraf - 1.72.2-1 119 | - Updated to release 1.72.2 120 | 121 | * Thu Feb 1 2018 Ritesh Raj Sarraf - 1.72.1-1 122 | - Updated to release 1.72.1 123 | 124 | * Thu Jan 12 2017 Ritesh Raj Sarraf - 1.71-1 125 | - Updated to release 1.71 126 | 127 | * Sat Sep 24 2016 Ritesh Raj Sarraf - 1.70-1 128 | - Updated to release 1.70 129 | 130 | * Sun Mar 27 2016 Ritesh Raj Sarraf - 1.69.2-1 131 | - Updated to release 1.69.2 132 | 133 | * Tue Mar 15 2016 Ritesh Raj Sarraf - 1.69.1-1 134 | - Updated to release 1.69.1 135 | 136 | * Mon Mar 7 2016 Ritesh Raj Sarraf - 1.69-1 137 | - Updated to release 1.69 138 | 139 | * Sun Sep 27 2015 Ritesh Raj Sarraf - 1.68.1-1 140 | - Updated to release 1.68.1 141 | 142 | * Thu Aug 27 2015 Ritesh Raj Sarraf - 1.68-1 143 | - Updated to release 1.68. 144 | 145 | * Thu Jul 2 2015 Ritesh Raj Sarraf - 1.67-1 146 | - Updated to release 1.67. 147 | 148 | * Fri Sep 26 2014 Ritesh Raj Sarraf - 1.66-1 149 | - Updated to release 1.66. 150 | 151 | * Wed Jun 18 2014 Ritesh Raj Sarraf - 1.65-1 152 | - Updated to release 1.65. 153 | 154 | * Sun Sep 1 2013 Ritesh Raj Sarraf - 1.64-1 155 | - Updated to release 1.64. 156 | 157 | * Sat Mar 23 2013 Ritesh Raj Sarraf - 1.63-1 158 | - Updated to release 1.63. 159 | 160 | * Tue Oct 30 2012 Ritesh Raj Sarraf - 1.62-1 161 | - Updated to release 1.62. 162 | 163 | * Thu May 17 2012 Ritesh Raj Sarraf - 1.61-1 164 | - Updated to release 1.61. 165 | 166 | * Fri Oct 14 2011 Ritesh Raj Sarraf - 1.60-1 167 | - Updated to release 1.60. 168 | 169 | * Mon Aug 8 2011 Ritesh Raj Sarraf - 1.59-1 170 | - Updated to release 1.59. 171 | 172 | * Sat Jul 23 2011 Ritesh Raj Sarraf - 1.58-1 173 | - Updated to release 1.58. 174 | 175 | * Sun Feb 27 2011 Ritesh Raj Sarraf - 1.57-1 176 | - Updated to release 1.57. 177 | 178 | * Mon Feb 14 2011 Ritesh Raj Sarraf - 1.56-1 179 | - Updated to release 1.56. 180 | 181 | * Wed May 26 2010 Ritesh Raj Sarraf - 1.55-1 182 | - Updated to release 1.55. 183 | 184 | * Wed Mar 10 2010 Ritesh Raj Sarraf - 1.54-1 185 | - Updated to release 1.54. 186 | 187 | * Sat Jan 2 2010 Ritesh Raj Sarraf - 1.53-1 188 | - Updated to release 1.53. 189 | 190 | * Thu Oct 8 2009 Ritesh Raj Sarraf - 1.52-1 191 | - Updated to release 1.52. 192 | 193 | * Tue Sep 1 2009 Ritesh Raj Sarraf - 1.51-1 194 | - Updated to release 1.51. 195 | 196 | * Fri Jul 24 2009 Ritesh Raj Sarraf - 1.50-1 197 | - Updated to release 1.50. 198 | 199 | * Sun Sep 07 2008 Bart Samwel - 1.45-1 200 | - Updated to release 1.45. 201 | 202 | * Mon May 28 2007 Bart Samwel - 1.34-1 203 | - Updated to release 1.34. 204 | - Added some files from upstream that were left out in earlier packages, such as lm-profiler. 205 | - Restart acpid after %{__install} -Dping. 206 | 207 | * Sun Oct 08 2006 Dag Wieers - 1.32-1 208 | - Updated to release 1.32. 209 | 210 | * Sun Apr 16 2006 Dag Wieers - 1.31-1 211 | - Updated to release 1.31. 212 | 213 | * Sat Apr 15 2006 Dag Wieers - 1.30-1 214 | - Updated to release 1.30. 215 | 216 | * Sun Apr 10 2005 Dag Wieers - 1.05-1 217 | - Initial package. (using DAR) 218 | -------------------------------------------------------------------------------- /usr/share/laptop-mode-tools/modules/hdparm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Laptop mode tools module: adjust hard drive powermanagement settings 4 | # 5 | # This is a core module that takes its configuration from the main config 6 | # file. 7 | # 8 | 9 | # 10 | # Function for drive capability check. This prevents ugly errors in 11 | # the kernel output about unsupported commands. 12 | # 13 | # $1 = drive name 14 | # $2 = capability (SDPARM/HDPARM or IDLE_TIMEOUT/POWERMGMT/WRITECACHE) 15 | 16 | 17 | UDEVADM=`which udevadm 2>/dev/null`; 18 | UDEVINFO=`which udevinfo 2>/dev/null`; 19 | 20 | is_capable() { 21 | local dev=${1#/dev/} 22 | local MEDIA= 23 | local BUS= 24 | 25 | # Make sure the drive exists before checking anything. 26 | if ! [ -e $1 ]; then 27 | return 1; 28 | fi 29 | 30 | # If the disk is an SSD, we skip any of the power mgmt features, for now. 31 | SYSFS_DEV=/sys/block/$dev 32 | if [ -f $SYSFS_DEV/queue/rotational ]; then 33 | IS_ROTATIONAL=`cat $SYSFS_DEV/queue/rotational` 34 | else 35 | log "VERBOSE" "Disk $THISHD does not support the rotational interface" 36 | # We'll apply the traditional drive assumptions here. 37 | IS_ROTATIONAL=1 38 | fi 39 | 40 | if [ "$IS_ROTATIONAL" -eq 0 ]; then 41 | log "VERBOSE" "Disk $THISHD is a NAND (SSD / Flash) Device. Not apply power management savings" 42 | return 1 43 | fi 44 | 45 | # If we are running udev, this is the most portable way 46 | # It assumes more or less recent udev (> 070) 47 | if [ $HAVE_UDEVINFO -ne 0 ] ; then 48 | log "VERBOSE" "Querying $1 media type using udevinfo: " 49 | if [ -x "$UDEVADM" ]; then 50 | eval "$(udevadm info -q env -n $1 | grep -E '(ID_TYPE=|ID_BUS=)' )" 51 | else 52 | eval "$(udevinfo -q env -n $1 | grep -E '(ID_TYPE=|ID_BUS=)' )" 53 | fi 54 | if [ -n "$ID_TYPE" -a -n "$ID_BUS" ] ; then 55 | log "VERBOSE" "type '$ID_TYPE' on bus '$ID_BUS' detected" 56 | MEDIA=$ID_TYPE 57 | BUS=$ID_BUS 58 | else 59 | log "ERR" "failed - udev not active?" 60 | fi 61 | fi 62 | 63 | if [ -z "$MEDIA" ] ; then 64 | log "VERBOSE" "Querying $1 media type using device name: " 65 | case $dev in 66 | hd*) # IDE device 67 | if [ -r /proc/ide/$dev/media ]; then 68 | MEDIA="$(cat /proc/ide/$dev/media)" 69 | BUS=ata 70 | if [ "$MEDIA" = cdrom ] ; then 71 | MEDIA=cd 72 | fi 73 | fi 74 | ;; 75 | sd*) # SCSI disk 76 | # No need to check, sd is always SCSI disk 77 | MEDIA=disk 78 | BUS=scsi 79 | ;; 80 | sr* | scd* ) 81 | # No need to check, sr or scd is always SCSI CD-ROM 82 | MEDIA=cd 83 | BUS=scsi 84 | ;; 85 | 86 | esac 87 | if [ -n "$MEDIA" ] ; then 88 | log "VERBOSE" "type '$MEDIA' on bus '$BUS' detected" 89 | else 90 | log "ERR" "failed - unknown name" 91 | fi 92 | fi 93 | 94 | if [ -z "$MEDIA" ] ; then 95 | if [ "$HDPARM_AVAILABLE" = "1" ]; then 96 | log "VERBOSE" "Querying $1 type using hdparm: " 97 | if hdparm -I $1 | grep -q CD-ROM ; then 98 | MEDIA=cd 99 | else 100 | MEDIA=disk 101 | fi 102 | BUS=ata # or acts like it anyway, because hdparm supports it. 103 | log "VERBOSE" "type '$MEDIA' on bus '$BUS' detected" 104 | fi 105 | fi 106 | 107 | # Sanity check 108 | if [ -z "$MEDIA" -o -z "$BUS" ] ; then 109 | log "ERR" "Querying $1 type - unknown type or bus, disabling hdparm/sdparm" 110 | return 1 111 | fi 112 | 113 | if [ "$BUS" = "scsi" -a "$ASSUME_SCSI_IS_SATA" -ne 0 ] ;then 114 | # Treat scsi disks as SATA devices. Unfortunately they are hard 115 | # to recognize -- if anybody has a drive and cares to find out 116 | # how to recognize them, please enlighten me! 117 | BUS=ata 118 | fi 119 | 120 | # Now check what capabilities we support for the 121 | # various media and bus types. 122 | case "$MEDIA:$BUS:$2" in 123 | # Although CD-ROM drives usually support 124 | # idle timeout settings, they don't usually 125 | # support very low values, and we don't want 126 | # to mess with that. We simply ignore anything 127 | # that is a CD player. 128 | cd:*:* ) return 1;; 129 | 130 | # ATA drives support the "hdparm" command but 131 | # not normally the "sdparm" command. 132 | *:ata:HDPARM ) return 0 ;; 133 | *:ata:SDPARM ) return 1 ;; 134 | 135 | # SCSI drives support the "sdparm" command, but 136 | # not normally the "hdparm" command. 137 | *:scsi:SDPARM ) return 0 ;; 138 | *:scsi:HDPARM ) return 1 ;; 139 | 140 | # On ATA disks everything is supported. 141 | disk:ata:* ) return 0 ;; 142 | 143 | # For sdparm we only know how to set the idle 144 | # timeout, nothing else at the moment. 145 | *:scsi:IDLE_TIMEOUT ) return 0 ;; 146 | 147 | # No other capabilities are supported. 148 | * ) return 1 ;; 149 | esac 150 | } 151 | 152 | 153 | # Preparation: determine the tools we have available. 154 | if [ -x "$(which hdparm 2> /dev/null)" ]; then 155 | HDPARM_AVAILABLE=1 156 | fi 157 | if [ -x "$(which sdparm 2> /dev/null)" ]; then 158 | SDPARM_AVAILABLE=1 159 | fi 160 | 161 | HAVE_UDEVINFO=0 162 | if [ -x "$UDEVADM" ]; then 163 | UDEVVERSION=$(udevadm info -V) 164 | UDEV_VER_VERIFY=$(echo $UDEVVERSION | cut -b 1) 165 | case $UDEV_VER_VERIFY in 166 | [a-z]) UDEVVERSION=$(udevadm info -V | awk '{print $3}') 167 | ;; 168 | *) 169 | ;; 170 | esac 171 | 172 | if [ "$UDEVVERSION" -gt 70 ] ; then 173 | HAVE_UDEVINFO=1 174 | else 175 | log "VERBOSE" "udevadm info present but version not > 070, not using udev" 176 | fi 177 | else 178 | # Older versions of udev (udevinfo) give output in the form of 179 | # "udevinfo, version 125" 180 | # Will be removed later. Currently only for backward compatibility 181 | if [ -x "$UDEVINFO" ] ; then 182 | UDEVVERSION=$(udevinfo -V | awk '{ print $3; }') 183 | if [ "$UDEVVERSION" -gt 70 ] ; then 184 | HAVE_UDEVINFO=1 185 | else 186 | log "VERBOSE" "udevinfo present but version not > 070, not using udev" 187 | fi 188 | fi 189 | fi 190 | 191 | if [ x$CONTROL_HD_POWERMGMT = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_HD_POWERMGMT = xauto ]; then 192 | if [ $ON_AC -eq 1 ] ; then 193 | if [ "$ACTIVATE" -eq 1 ] ; then 194 | HD_POWERMGMT=$LM_AC_HD_POWERMGMT 195 | else 196 | HD_POWERMGMT=$NOLM_AC_HD_POWERMGMT 197 | fi 198 | else 199 | HD_POWERMGMT=$BATT_HD_POWERMGMT 200 | fi 201 | 202 | log "VERBOSE" "Setting powermanagement on drives to $HD_POWERMGMT." 203 | for THISHD in $HD ; do 204 | if is_capable $THISHD POWERMGMT ; then 205 | if is_capable $THISHD HDPARM ; then 206 | if [ "$HDPARM_AVAILABLE" = "1" ]; then 207 | log "VERBOSE" "Executing: hdparm -B $HD_POWERMGMT $THISHD" 208 | log "VERBOSE" "`hdparm -B $HD_POWERMGMT $THISHD 2>&1`" 209 | else 210 | log "ERR" "ERROR: hdparm not installed." 211 | fi 212 | else 213 | log "VERBOSE" "Skipping $THISHD: powermgmt only possible with hdparm but drive does not" 214 | log "VERBOSE" "support hdparm." 215 | fi 216 | else 217 | log "VERBOSE" "Skipping $THISHD: powermanagement control not supported." 218 | fi 219 | done 220 | fi 221 | 222 | if [ x$CONTROL_HD_IDLE_TIMEOUT = x1 ] ; then 223 | # Spindown timeouts may only be set when data-loss sensitive 224 | # features are active. 225 | if [ "$ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -eq 1 ] ; then 226 | if [ $ON_AC -eq 1 ] ; then 227 | HD_IDLE_TIMEOUT=$LM_AC_HD_IDLE_TIMEOUT 228 | HD_IDLE_TIMEOUT_SECONDS=$LM_AC_HD_IDLE_TIMEOUT_SECONDS 229 | else 230 | HD_IDLE_TIMEOUT=$LM_BATT_HD_IDLE_TIMEOUT 231 | HD_IDLE_TIMEOUT_SECONDS=$LM_BATT_HD_IDLE_TIMEOUT_SECONDS 232 | fi 233 | else 234 | HD_IDLE_TIMEOUT=$NOLM_HD_IDLE_TIMEOUT 235 | HD_IDLE_TIMEOUT_SECONDS=$NOLM_HD_IDLE_TIMEOUT_SECONDS 236 | fi 237 | log "VERBOSE" "Setting spindown timeout on drives to $HD_IDLE_TIMEOUT_SECONDS seconds." 238 | log "VERBOSE" "(hdparm configuration value = $HD_IDLE_TIMEOUT.)" 239 | for THISHD in $HD ; do 240 | if is_capable $THISHD IDLE_TIMEOUT ; then 241 | if is_capable $THISHD SDPARM ; then 242 | if [ "$SDPARM_AVAILABLE" = "1" ]; then 243 | HD_IDLE_TIMEOUT_DECISECONDS=$(($HD_IDLE_TIMEOUT_SECONDS*10)) 244 | log "VERBOSE" "Executing: sdparm -q -s SCT=$HD_IDLE_TIMEOUT_DECISECONDS $THISHD" 245 | log "VERBOSE" "`sdparm -q -s SCT=$HD_IDLE_TIMEOUT_DECISECONDS $THISHD 2>&1`" 246 | else 247 | log "ERR" "ERROR: sdparm not installed." 248 | fi 249 | elif is_capable $THISHD HDPARM ; then 250 | if [ "$HDPARM_AVAILABLE" = "1" ]; then 251 | log "VERBOSE" "Executing: hdparm -S $HD_IDLE_TIMEOUT $THISHD" 252 | log "VERBOSE" "`hdparm -S $HD_IDLE_TIMEOUT $THISHD 2>&1`" 253 | else 254 | log "VERBOSE" "ERROR: hdparm not installed." 255 | fi 256 | else 257 | log "VERBOSE" "Skipping $THISHD: drive supports neither hdparm nor sdparm." 258 | fi 259 | else 260 | log "VERBOSE" "Skipping $THISHD: idle timeout control not supported." 261 | fi 262 | done 263 | fi 264 | 265 | if [ x$CONTROL_HD_WRITECACHE = x1 ] ; then 266 | # The writecache may only be enabled when data-loss sensitive 267 | # features are active. 268 | 269 | if [ "$ACTIVATE" -eq 1 ] ; then 270 | if [ "$ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -eq 0 ] ; then 271 | HD_WRITECACHE=0 272 | else 273 | HD_WRITECACHE=$LM_HD_WRITECACHE 274 | fi 275 | else 276 | if [ $ON_AC -eq 1 ] ; then 277 | HD_WRITECACHE=$NOLM_AC_HD_WRITECACHE 278 | else 279 | HD_WRITECACHE=$NOLM_BATT_HD_WRITECACHE 280 | fi 281 | fi 282 | log "VERBOSE" "Setting write cache on drives to $HD_WRITECACHE." 283 | for THISHD in $HD ; do 284 | if is_capable $THISHD WRITECACHE ; then 285 | if is_capable $THISHD SDPARM ; then 286 | if [ "$SDPARM_AVAILABLE" = "1" ]; then 287 | log "VERBOSE" "Executing: sdparm Write Cache $HD_WRITECACHE $THISHD" 288 | log "VERBOSE" "`sdparm --set WCE=$HD_WRITECACHE $THISHD 2>&1`" 289 | else 290 | log "ERR" "ERROR: sdparm not installed." 291 | fi 292 | elif is_capable $THISHD HDPARM ; then 293 | if [ "$HDPARM_AVAILABLE" = "1" ]; then 294 | log "VERBOSE" "Executing: hdparm -W $HD_WRITECACHE $THISHD" 295 | log "VERBOSE" "`hdparm -W $HD_WRITECACHE $THISHD 2>&1`" 296 | else 297 | log "ERR" "ERROR: hdparm not installed." 298 | fi 299 | else 300 | log "VERBOSE" "Skipping $THISHD: writecache only possible with hdparm but drive does not" 301 | log "VERBOSE" "support hdparm." 302 | fi 303 | else 304 | log "VERBOSE" "Skipping $THISHD: writecache control not supported." 305 | fi 306 | done 307 | fi 308 | 309 | -------------------------------------------------------------------------------- /usr/sbin/lm-profiler: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # This script assists you in achieving very high power savings on laptops. 4 | # It can detect programs that perform regular, non-bursty disk operations, 5 | # and network services that listen on external addresses. When started, 6 | # lm-profiler will run for 10 minutes (or a configured number of minutes), 7 | # after which it will provide a series of recommendations. 8 | # 9 | # It will try to find init scripts for any programs that it recommends for 10 | # stopping, and it will ask if you want to place links to those scripts in 11 | # /etc/laptop-mode/batt-stop, so that laptop mode tools will automatically 12 | # stop those daemons when battery mode is detected. 13 | # 14 | # 15 | # This script is a part of Laptop Mode Tools. 16 | # 17 | # Configuration options for this script can be found in 18 | # /etc/laptop-mode/lm-profiler.conf. 19 | # 20 | # Maintainer: Bart Samwel (bart@samwel.tk) 21 | # Adapted from initial version written by Jan Polacek (jerome@ucw.cz). 22 | 23 | 24 | # 25 | # Read configuration. 26 | # 27 | 28 | # Defaults 29 | 30 | PROFILE_RUN_LENGTH=600 31 | ACTIVITY_INTERVAL_MAX=150 32 | ACTIVITY_INTERVAL_MIN=5 33 | RECOMMEND_DEFAULT_SERVICES=1 34 | DEFAULT_SERVICES="anacron cron atd" 35 | DEF_IGNORE_PROGRAMS="pdflush journald flush- XFree86 acpid apmd lm-profiler dmesg syslogd awk sed grep mc bc xfs cat diff uniq vi mv sort sleep" 36 | IGNORE_PROGRAMS="$DEF_IGNORE_PROGRAMS" 37 | RECOMMEND_NETWORK_SERVICES=1 38 | DEF_IGNORE_NETWORK_SERVICES="perl" # Some daemons run on perl, not very informative 39 | IGNORE_NETWORK_SERVICES="$DEF_IGNORE_NETWORK_SERVICES" 40 | VERBOSE_OUTPUT=0 41 | if [ -f /etc/laptop-mode/lm-profiler.conf ] ; then 42 | . /etc/laptop-mode/lm-profiler.conf 43 | fi 44 | 45 | # 46 | # Internal variables 47 | # 48 | 49 | DEBUG=0 50 | ###################################################################### 51 | 52 | if [ $DEBUG -eq 1 ]; then 53 | set -eux 54 | fi 55 | 56 | if [ "$VERBOSE_OUTPUT" -eq 1 ] ; then 57 | OUTPUT="/dev/stdout" 58 | else 59 | OUTPUT="/dev/null" 60 | fi 61 | 62 | if [ ! `id -u` -eq 0 ]; then 63 | echo "Only root can run profiler." 64 | exit 0 65 | fi 66 | 67 | WORKDIR=`mktemp -d -t lm-profiler.XXXXXX` 68 | 69 | 70 | start_profiling(){ 71 | # Turn on disk access profilling 72 | if [ -f /proc/sys/vm/block_dump ]; then 73 | echo "1" > /proc/sys/vm/block_dump 74 | else 75 | echo "/proc/sys/vm/block_dump does not exist, exiting." 76 | exit 1 77 | fi 78 | } 79 | 80 | stop_profiling(){ 81 | # Turn off disk access profilling 82 | echo "0" > /proc/sys/vm/block_dump 83 | } 84 | 85 | # Create a commandline for grep, checking for the presence of all 86 | # strings in a space-separated list passed as the first parameter. 87 | format_params(){ 88 | for PARAM in $1 ; do 89 | echo -n "-e $PARAM " 90 | done 91 | } 92 | 93 | # Detect all processes that have accessed the disk since the last 94 | # invocation of dmesg. The results are written to files called 95 | # "write_accesses_N" and "read_accesses_N", where N is the first 96 | # parameter of this function. 97 | process_dmesg_diff(){ 98 | LEFT="$WORKDIR/dmesg_prev" 99 | RIGHT="$WORKDIR/dmesg_next" 100 | dmesg > $RIGHT 101 | if [ -s $LEFT ] && [ -s $RIGHT ]; then 102 | # The following command is long and complicated. It does 103 | # the following things, separately for READ and WRITE 104 | # accesses: 105 | # 1. Retrieve only new lines, using diff. 106 | # 2. Drop the first line -- it is probably a truncated 107 | # version of an earlier line. 108 | # 3. Parse out the name of the process. 109 | # 4. Filter out IGNORE_PROGRAMS. 110 | # 5. Write process name to output. 111 | 112 | diff -u $LEFT $RIGHT \ 113 | |grep '^+' \ 114 | |grep -o '[^[:space:]]*([0-9]*): WRITE' \ 115 | |sed '1d' \ 116 | |awk -v FS="(" '{print $1}' \ 117 | |grep -v `format_params "$IGNORE_PROGRAMS"` \ 118 | |sort \ 119 | |uniq \ 120 | > $WORKDIR/write_accesses_$1 121 | 122 | diff -u $LEFT $RIGHT \ 123 | |grep '^+' \ 124 | |grep -o '[^[:space:]]*([0-9]*): READ' \ 125 | |sed '1d' \ 126 | |awk -v FS="(" '{print $1}' \ 127 | |grep -v `format_params "$IGNORE_PROGRAMS"` \ 128 | |sort \ 129 | |uniq \ 130 | > $WORKDIR/read_accesses_$1 131 | 132 | mv $RIGHT $LEFT 133 | WRITE_ACCESSES_FOUND=0 134 | for ACCESS in $(cat $WORKDIR/write_accesses_$1) ; do 135 | if [ $WRITE_ACCESSES_FOUND -eq 0 ] ; then 136 | printf '\r \rWrite accesses at %d/%d in lm-profiler run:' "$1" "$PROFILE_RUN_LENGTH" 137 | WRITE_ACCESSES_FOUND=1 138 | fi 139 | echo -n " $ACCESS" 140 | done 141 | if [ $WRITE_ACCESSES_FOUND -ne 0 ] ; then 142 | echo "" 143 | fi 144 | 145 | READ_ACCESSES_FOUND=0 146 | for ACCESS in $(cat $WORKDIR/read_accesses_$1) ; do 147 | if [ $READ_ACCESSES_FOUND -eq 0 ] ; then 148 | printf '\r \rRead accesses at %d/%d in lm-profiler run:' "$1" "$PROFILE_RUN_LENGTH" 149 | READ_ACCESSES_FOUND=1 150 | fi 151 | echo -n " $ACCESS" 152 | done 153 | if [ $READ_ACCESSES_FOUND -ne 0 ] ; then 154 | echo "" 155 | fi 156 | else 157 | echo "No dmesg data found to profile, exiting." 158 | exit 1 159 | fi 160 | } 161 | 162 | # Attempt to find an init script for ithe process given as an argument 163 | findinit(){ 164 | INITDIR= 165 | if [ -d /etc/init.d ] ; then 166 | INITDIR=/etc/init.d 167 | elif [ -d /etc/rc.d/init.d ] ; then 168 | INITDIR=/etc/rc.d/init.d 169 | fi 170 | if [ "$INITDIR" != "" ] ; then 171 | INIT=`ls $INITDIR/ |grep ^$1$ |head -n 1` 172 | if [ -z "$INIT" ]; then 173 | INIT=`grep $1 $INITDIR/* |sed s/:.*// |head -n 1` 174 | else 175 | INIT="$INITDIR/$INIT" 176 | fi 177 | if [ ! -z "$INIT" ] && [ -x $INIT ]; then 178 | echo "$INIT" 179 | fi 180 | fi 181 | } 182 | 183 | # Look for names of running network services 184 | profilenet(){ 185 | netstat -anp |grep ^tcp.*LISTEN |grep -v "Program name" |awk -v FS="/" '{print $2}' |sort |uniq |\ 186 | tr -d ['(',')','[',']'] 187 | } 188 | 189 | 190 | # 191 | # PROFILING RUN 192 | # 193 | 194 | 195 | # On newner Linux systems, 5.14+ the /proc/sys/vm/block_dump interface is gone and users are 196 | # encouraged to make use of the Linux Tracing infrastructure 197 | 198 | BTRACE=$(which btrace) 199 | if [ -f /proc/sys/vm/block_dump ]; then 200 | echo "Using older block_dump interface"; 201 | continue 202 | elif [ -n "$BTRACE" ]; then 203 | if [ -f "$BTRACE" ]; then 204 | VALID_DEVICES=""; 205 | # Get list of block devices 206 | DEVICES=$(lsblk -rd | grep disk | grep -v SWAP | grep -v loop | cut -d ' ' -f1) 207 | if [ -z "$DEVICES" ]; then 208 | echo "No block devices detected"; 209 | exit 1; 210 | fi 211 | echo "Detected list of devices are: $DEVICES" 212 | for dev in $DEVICES; 213 | do 214 | if [ -b /dev/$dev ]; then 215 | VALID_DEVICES="$VALID_DEVICES /dev/$dev "; 216 | fi 217 | done 218 | echo "Validated list of devices are: $VALID_DEVICES"; 219 | 220 | echo "Using blktrace interface"; 221 | $BTRACE -s -t -w $PROFILE_RUN_LENGTH $VALID_DEVICES 222 | exit 0 223 | else 224 | echo "No suitable tooling available to run lm-profiler"; 225 | exit 1; 226 | fi 227 | else 228 | echo "No suitable tooling available to run lm-profiler"; 229 | exit 1; 230 | fi 231 | 232 | # Disable profiling if the script gets interrupted. 233 | trap "stop_profiling; echo; exit 10" EXIT HUP INT ABRT QUIT SEGV TERM 234 | 235 | SECONDS_DONE= 236 | echo "Profiling run started." 237 | dmesg > $WORKDIR/dmesg_prev 238 | start_profiling 239 | echo > $WORKDIR/write_accesses_$SECONDS_DONE 240 | echo > $WORKDIR/read_accesses_$SECONDS_DONE 241 | SECONDS_DONE=0 242 | while [ $SECONDS_DONE -le $PROFILE_RUN_LENGTH ] ; do 243 | printf '\r%d seconds elapsed, %d remaining. \b\b\b\b\b\b\b\b\b' "$SECONDS_DONE" "$(($PROFILE_RUN_LENGTH - $SECONDS_DONE))" 244 | sleep 1 245 | SECONDS_DONE=$(($SECONDS_DONE + 1)) 246 | process_dmesg_diff $SECONDS_DONE 247 | done 248 | printf '\r \r' 249 | stop_profiling 250 | 251 | echo "Write frequency : "; cat $WORKDIR/write_accesses_* | sed -e 's/^[ \t]*//;s/[ \t]*$//' -e '/^$/ d' | sort | uniq -c | sort -n 252 | echo "Read frequency : "; cat $WORKDIR/read_accesses_* | sed -e 's/^[ \t]*//;s/[ \t]*$//' -e '/^$/ d' | sort | uniq -c | sort -n 253 | echo; 254 | 255 | NETPROFILE=`profilenet` 256 | echo "Profiling run completed." 257 | 258 | # 259 | # OUTPUT 260 | # 261 | ALREADY_SEEN= 262 | if [ "$RECOMMEND_DEFAULT_SERVICES" -ne 0 ] ; then 263 | for SERVICE in $DEFAULT_SERVICES ; do 264 | echo 265 | echo "Program: \"$SERVICE\"" 266 | echo "Reason: standard recommendation (program may not be running)" 267 | INIT=`findinit $SERVICE` 268 | if [ "$INIT" = "" ] ; then 269 | echo "Init script: none" 270 | echo "If you want to disable this program, you should do so manually." 271 | else 272 | echo "Init script: $INIT (GUESSED)" 273 | echo 274 | echo -n "Do you want to disable this service in battery mode? [y/N]: " 275 | read ANSWER 276 | if ( echo "$ANSWER" | grep -i ^y > /dev/null ) ; then 277 | ln -fs $INIT /etc/laptop-mode/batt-stop/`echo $INIT | sed 's/.*\///g'` 278 | fi 279 | fi 280 | ALREADY_SEEN="$ALREADY_SEEN $SERVICE" 281 | done 282 | fi 283 | 284 | 285 | 286 | 287 | if [ "$RECOMMEND_NETWORK_SERVICES" -ne 0 ] ; then 288 | for SERVICE in $NETPROFILE ; do 289 | if ( echo " $IGNORE_NETWORK_SERVICES " | grep -v " $SERVICE " > /dev/null ) ; then 290 | echo 291 | echo "Program: \"$SERVICE\"" 292 | echo "Reason: listens on network, may not be needed offline." 293 | INIT=`findinit $SERVICE` 294 | if [ "$INIT" = "" ] ; then 295 | echo "Init script: none" 296 | echo "If you want to disable this program, you should do so manually." 297 | else 298 | echo "Init script: $INIT (GUESSED)" 299 | echo 300 | echo -n "Do you want to disable this service in battery mode? [y/N]: " 301 | read ANSWER 302 | if ( echo "$ANSWER" | grep -i ^y > /dev/null ) ; then 303 | ln -fs $INIT /etc/laptop-mode/batt-stop/`echo $INIT | sed 's/.*\///g'` 304 | fi 305 | fi 306 | ALREADY_SEEN="$ALREADY_SEEN $SERVICE" 307 | fi 308 | done 309 | fi 310 | 311 | SECONDS_LEFT=$PROFILE_RUN_LENGTH 312 | while [ $SECONDS_LEFT -gt 0 ] ; do 313 | for SERVICE in `cat $WORKDIR/*_accesses_$SECONDS_LEFT` ; do 314 | if ( echo " $ALREADY_SEEN " | grep -v " $SERVICE " > /dev/null ) ; then 315 | CUR_COMPARE_SECONDS=$(($SECONDS_LEFT - $ACTIVITY_INTERVAL_MIN)) 316 | while [ $CUR_COMPARE_SECONDS -gt $(($SECONDS_LEFT - $ACTIVITY_INTERVAL_MAX)) -a $CUR_COMPARE_SECONDS -gt 0 ] ; do 317 | if ( grep "^$SERVICE$" $WORKDIR/*_accesses_$CUR_COMPARE_SECONDS > /dev/null ) ; then 318 | if ( echo " $ALREADY_SEEN " | grep -v " $SERVICE " > /dev/null ) ; then 319 | echo 320 | echo "Program: \"$SERVICE\"" 321 | echo "Reason: disk access." 322 | INIT=`findinit $SERVICE` 323 | if [ "$INIT" = "" ] ; then 324 | echo "Init script: none" 325 | echo "If you want to disable this program, you should do so manually." 326 | else 327 | echo "Init script: $INIT (GUESSED)" 328 | echo 329 | echo -n "Do you want to disable this service in battery mode? [y/N]: " 330 | fi 331 | read ANSWER 332 | if ( echo "$ANSWER" | grep -i ^y > /dev/null ) ; then 333 | if [ -e $INIT ] ; then 334 | ln -fs $INIT /etc/laptop-mode/batt-stop/`echo $INIT | sed 's/.*\///g'` 335 | fi 336 | fi 337 | ALREADY_SEEN="$ALREADY_SEEN $SERVICE" 338 | fi 339 | fi 340 | CUR_COMPARE_SECONDS=$(($CUR_COMPARE_SECONDS - 1)) 341 | done 342 | fi 343 | done 344 | SECONDS_LEFT=$(($SECONDS_LEFT - 1)) 345 | done 346 | -------------------------------------------------------------------------------- /etc/laptop-mode/laptop-mode.conf: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # Configuration for Laptop Mode Tools 4 | # ----------------------------------- 5 | # 6 | # There is a "system" to the configuration setting names: 7 | # CONTROL_something=0/1 Determines whether Laptop Mode Tools controls 8 | # something 9 | # LM_something=value Value of "something" when laptop mode is active 10 | # NOLM_something=value Value of "something" when laptop mode is NOT 11 | # active 12 | # AC_something=value Value of "something" when the computer is running 13 | # on AC power 14 | # BATT_something=value Value of "something" when the computer is running 15 | # on battery power 16 | # 17 | # There can be combinations of LM_/NOLM_ and AC_/BATT_ prefixes, but the 18 | # available prefixes are different for each setting. The available ones are 19 | # documented in the manual page, laptop-mode.conf(8). If there is no LM_/ 20 | # NOLM_ in a setting name, then the value is used independently of laptop 21 | # mode state, and similarly, if there is no AC_/BATT_, then the value is used 22 | # independently of power state. 23 | # 24 | # Some options only work on ACPI systems. They are marked ACPI-ONLY. 25 | # 26 | # Note that this configuration file is a fragment of shell script: you 27 | # can use all the features of the shell scripting language to achieve your 28 | # desired configuration. 29 | # 30 | # 31 | # Modules 32 | # ------- 33 | # 34 | # Laptop Mode Tools modules have separate configuration files, that can be 35 | # found in /etc/laptop-mode/conf.d. Please look through these configuration 36 | # files as well, there are many useful power saving tools in there! 37 | # 38 | ############################################################################### 39 | 40 | 41 | ############################################################################### 42 | # Enable/Disable laptop-mode-tools execution 43 | # ------------------------------------------ 44 | # Set it to 0 to completely disable laptop-mode-tools from running 45 | ############################################################################### 46 | # 47 | ENABLE_LAPTOP_MODE_TOOLS=1 48 | 49 | 50 | ############################################################################### 51 | # Configuration debugging 52 | # ----------------------- 53 | ############################################################################### 54 | 55 | # 56 | # Set this to 1 if you want to see a lot of information when you start/stop 57 | # laptop_mode. 58 | # 59 | VERBOSE_OUTPUT=0 60 | 61 | # Set this to 1 if you want to log messages to syslog 62 | LOG_TO_SYSLOG=0 63 | 64 | # Run in shell debug mode 65 | # Enable this if you would like to execute the entire laptop-mode-tools program 66 | # in shell debug mode. Warning: This will create a lot of text output 67 | # If you are debugging an individual module, perhaps you would want to enable 68 | # each module specific debug mode (available in module conf files) 69 | DEBUG=0 70 | 71 | ############################################################################### 72 | # When to enable laptop mode 73 | # -------------------------- 74 | # 75 | # "Laptop mode" is the mode in which laptop mode tools makes the computer 76 | # consume less power. This includes the kernel "laptop_mode" feature, which 77 | # allows your hard drives to spin down, as well as various other settings which 78 | # can be tweaked by laptop mode tools. You can enable or disable all of these 79 | # settings using the CONTROL_... options further down in this config file. 80 | ############################################################################### 81 | 82 | 83 | # 84 | # Enable laptop mode power saving, when on battery power. 85 | # 86 | ENABLE_LAPTOP_MODE_ON_BATTERY=1 87 | 88 | 89 | # 90 | # Enable laptop mode power savings, even when on AC power. 91 | # This is useful when running as a headless machine, in low power mode 92 | # 93 | ENABLE_LAPTOP_MODE_ON_AC=0 94 | 95 | 96 | # 97 | # Enable laptop mode when the laptop's lid is closed, even when we're on AC 98 | # power? (ACPI-ONLY) 99 | # 100 | ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=0 101 | 102 | 103 | # 104 | # Enable all simple zero-configuration auto modules 105 | # This option enables all simple modules (listed below) without requiring 106 | # the user to enable each module individually 107 | # 108 | # List of modules which can be automatically enabled with this setting are: 109 | # 110 | # ac97-powersave 111 | # cpufreq 112 | # dpms-standby 113 | # eee-superhe 114 | # ethernet 115 | # exec-commands 116 | # hal-polling 117 | # hdparm 118 | # intel-hda-powersave 119 | # intel-sata-powermgmt 120 | # nmi-watchdog 121 | # pcie-aspm 122 | # runtime-pm 123 | # sched-mc-power-savings 124 | # sched-smt-power-savings 125 | # terminal-blanking 126 | # wireless-ipw-power 127 | # wireless-iwl-power 128 | # wireless-power 129 | # 130 | # Set this to 1 to enable all simple zero-configuration auto modules listed above. 131 | # 132 | # NOTE: You can explicitly enable/disable any of the above modules by changing their 133 | # values in the individual settings file 134 | # 135 | ENABLE_AUTO_MODULES=1 136 | 137 | 138 | 139 | ############################################################################### 140 | # When to enable data loss sensitive features 141 | # ------------------------------------------- 142 | # 143 | # When data loss sensitive features are disabled, laptop mode tools acts as if 144 | # laptop mode were disabled, for those features only. 145 | # 146 | # Data loss sensitive features include: 147 | # - laptop_mode (i.e., delayed writes) 148 | # - hard drive write cache 149 | # 150 | # All of the options that follow can be set to 0 in order to prevent laptop 151 | # mode tools from using them to stop data loss sensitive features. Use this 152 | # when you have a battery that reports the wrong information, that confuses 153 | # laptop mode tools. 154 | # 155 | # Disabling data loss sensitive features is ACPI-ONLY, and it only works if 156 | # your battery gives off frequent ACPI events to indicate a change in battery 157 | # level. 158 | # 159 | # NOTE: If your battery does NOT give off battery events often enough, you can 160 | # enable the battery-level-polling module to make this work. Look at the 161 | # file /etc/laptop-mode/conf.d/battery-level-polling.conf for more information. 162 | # 163 | ############################################################################### 164 | 165 | 166 | # 167 | # Disable all data loss sensitive features when the battery level (in % of the 168 | # battery capacity) reaches this value. 169 | # 170 | MINIMUM_BATTERY_CHARGE_PERCENT=3 171 | 172 | 173 | # 174 | # Disable data loss sensitive features when the battery reports its state 175 | # as "critical". 176 | # 177 | DISABLE_LAPTOP_MODE_ON_CRITICAL_BATTERY_LEVEL=1 178 | 179 | 180 | # 181 | # Ignore the alarm value reported by your batteries. In some instances a 182 | # a battery will report an abnormally high alarm value, resulting in data-loss 183 | # sensitive features being disabled prematurely. 184 | # 185 | DISABLE_BATTERY_ALARM_CHECK=0 186 | 187 | 188 | ############################################################################### 189 | # Controlled hard drives and partitions 190 | # ------------------------------------- 191 | # 192 | # For spinning down your hard drives, laptop mode will remount file systems and 193 | # adjust hard drive spindown timeouts. These parameters specify which 194 | # devices and partitions are affected by laptop mode. 195 | ############################################################################### 196 | 197 | 198 | # 199 | # The drives that laptop mode controls. 200 | # Separate them by a space, e.g. HD="/dev/hda /dev/hdb". The default is a 201 | # wildcard, which will get you all your IDE and SCSI/SATA drives. 202 | # 203 | HD="/dev/[hs]d[abcdefgh]" 204 | 205 | # 206 | # The NVMe drives that laptop mode controls. 207 | # Separate them by a space, e.g. NVME="/dev/nvme0 /dev/nvme1". The default is a 208 | # wildcard, which will get you all your NVMe drives. 209 | # 210 | NVME="/dev/nvme[0-9]" 211 | 212 | # 213 | # The partitions (or mount points) that laptop mode controls. 214 | # Separate the values by spaces. Use "auto" to indicate all partitions on drives 215 | # listed in HD. You can add things to "auto", e.g. "auto /dev/hdc3". You can 216 | # also specify mount points, e.g. "/mnt/data". 217 | # 218 | PARTITIONS="auto /dev/mapper/* /dev/dm-*" 219 | 220 | 221 | # 222 | # If this is enabled, laptop mode tools will assume that SCSI drives are 223 | # really SATA drives that only _look_ like SCSI drives, and will use hdparm 224 | # to control them. Set this to 0 if you have /dev/sd devices and you want 225 | # laptop mode tools to use the "sdparm" command to control them. 226 | # 227 | ASSUME_SCSI_IS_SATA=1 228 | 229 | 230 | ############################################################################### 231 | # Hard drive behaviour settings 232 | # ----------------------------- 233 | # 234 | # These settings specify how laptop mode tools will adjust the various 235 | # parameters of your hard drives and file systems. 236 | ############################################################################### 237 | 238 | 239 | # 240 | # Maximum time, in seconds, of work that you are prepared to lose when your 241 | # system crashes or power runs out. This is the maximum time that Laptop Mode 242 | # will keep unsaved data waiting in memory before spinning up your hard drive. 243 | # 244 | LM_BATT_MAX_LOST_WORK_SECONDS=600 245 | LM_AC_MAX_LOST_WORK_SECONDS=360 246 | 247 | 248 | # 249 | # Should laptop mode tools control readahead? 250 | # 251 | CONTROL_READAHEAD=1 252 | 253 | 254 | # 255 | # Read-ahead, in kilobytes. You can spin down the disk while playing MP3/OGG 256 | # by setting the disk readahead to a reasonable size, e.g. 3072 (3 MB). 257 | # Effectively, the disk will read a complete MP3 at once, and will then spin 258 | # down while the MP3/OGG is playing. Don't set this too high, because the 259 | # readahead is applied to _all_ files that are read from disk. 260 | # 261 | LM_READAHEAD=3072 262 | NOLM_READAHEAD=128 263 | 264 | 265 | # 266 | # Should laptop mode tools add the "noatime" option to the mount options when 267 | # laptop mode is enabled? 268 | # 269 | CONTROL_NOATIME=0 270 | 271 | # Should laptop use relatime instead of noatime? The "relatime" mount option has 272 | # more standards-compliant semantics, and allows more applications to work, 273 | # while retaining a low level of atime updates (i.e., disk writes). 274 | USE_RELATIME=1 275 | 276 | 277 | # 278 | # Should laptop mode tools control the hard drive idle timeout settings? 279 | # 280 | CONTROL_HD_IDLE_TIMEOUT=1 281 | 282 | 283 | # 284 | # Idle timeout values. (hdparm -S) 285 | # Default is 2 hours on AC (NOLM_HD_IDLE_TIMEOUT_SECONDS=7200) and 20 seconds 286 | # for battery and for AC with laptop mode on. 287 | # 288 | LM_AC_HD_IDLE_TIMEOUT_SECONDS=20 289 | LM_BATT_HD_IDLE_TIMEOUT_SECONDS=20 290 | NOLM_HD_IDLE_TIMEOUT_SECONDS=7200 291 | 292 | 293 | # 294 | # Should laptop mode tools control the hard drive power management settings? 295 | # 296 | # Set to 0 to disable 297 | CONTROL_HD_POWERMGMT="auto" 298 | 299 | 300 | # 301 | # Power management for HD (hdparm -B values) 302 | # 303 | BATT_HD_POWERMGMT=1 304 | LM_AC_HD_POWERMGMT=254 305 | NOLM_AC_HD_POWERMGMT=254 306 | 307 | 308 | # 309 | # Should laptop mode tools control the hard drive write cache settings? 310 | # 311 | CONTROL_HD_WRITECACHE=0 312 | 313 | 314 | # 315 | # Write cache settings for HD (hdparm -W values) 316 | # 317 | NOLM_AC_HD_WRITECACHE=1 318 | NOLM_BATT_HD_WRITECACHE=0 319 | LM_HD_WRITECACHE=0 320 | 321 | 322 | 323 | 324 | ############################################################################### 325 | # Settings you probably don't want to touch 326 | # ----------------------------------------- 327 | # 328 | # It is usually not necessary to change these parameters. They are included 329 | # for completeness' sake. 330 | ############################################################################### 331 | 332 | 333 | # 334 | # Change mount options on partitions in PARTITIONS? You don't really want to 335 | # disable this. If you do, then your hard drives will probably not spin down 336 | # anymore. 337 | # 338 | CONTROL_MOUNT_OPTIONS=1 339 | 340 | 341 | # 342 | # Dirty synchronous ratio. At this percentage of dirty pages the process 343 | # which calls write() does its own writeback. 344 | # 345 | LM_DIRTY_RATIO=60 346 | NOLM_DIRTY_RATIO=40 347 | 348 | 349 | # 350 | # Allowed dirty background ratio, in percent. Once DIRTY_RATIO has been 351 | # exceeded, the kernel will wake pdflush which will then reduce the amount 352 | # of dirty memory to dirty_background_ratio. Set this nice and low, so once 353 | # some writeout has commenced, we do a lot of it. 354 | # 355 | LM_DIRTY_BACKGROUND_RATIO=1 356 | NOLM_DIRTY_BACKGROUND_RATIO=10 357 | 358 | 359 | # 360 | # kernel default settings -- don't touch these unless you know what you're 361 | # doing. 362 | # 363 | DEF_UPDATE=5 364 | DEF_XFS_AGE_BUFFER=15 365 | DEF_XFS_SYNC_INTERVAL=30 366 | DEF_XFS_BUFD_INTERVAL=1 367 | DEF_MAX_AGE=30 368 | 369 | 370 | # 371 | # This must be adjusted manually to the value of HZ in the running kernel 372 | # on 2.4, until the XFS people change their 2.4 external interfaces to work in 373 | # centisecs. This can be automated, but it's a work in progress that still 374 | # needs some fixes. On 2.6 kernels, XFS uses USER_HZ instead of HZ for 375 | # external interfaces, and that is currently always set to 100. So you don't 376 | # need to change this on 2.6. 377 | # 378 | XFS_HZ=100 379 | 380 | 381 | # 382 | # Seconds laptop mode has to to wait after the disk goes idle before doing 383 | # a sync. 384 | # 385 | LM_SECONDS_BEFORE_SYNC=2 386 | 387 | 388 | --------------------------------------------------------------------------------