Slow boot with systemd due to NetworkManager and laptop-mode-tools

ernestas ~ $ systemd-analyze blame
25787ms NetworkManager.service
  3440ms laptop-mode-tools.service
  1792ms systemd-logind.service
  1573ms systemd-modules-load.service
  1519ms home.mount
  1305ms polkit.service
   977ms systemd-udevd.service
   903ms systemd-sysctl.servic
What could be the underlying problem? How do I solve it?

Okay. I no longer use laptop-mode-tools, but NetworkManager still seems to be slow:
ernestas ~ $ systemd-analyze blame
  3592ms NetworkManager.service
  3013ms systemd-logind.service
   869ms dev-sda7.swap
   762ms home.mount
   666ms systemd-modules-load.service
   546ms systemd-udev-trigger.service
   523ms systemd-udevd.service
   500ms dev-hugepages.mount
   479ms sys-kernel-debug.mount
Last edited by ernetas (2012-11-03 16:01:44)

Similar Messages

  • [SOLVED] Systemd and laptop-mode-tools frequency scaling

    Hi all.
    After a long time with no arch updates (november 2011) for various reasons, I decided to reinstall Arch from point 0 on my Clevo laptop.
    I was pleased to see nothing went bad, all is now set like I want. I installed systemd yesterday. All very straightforward for me, I only have a problem with CPU frequency scaling plus some minor glitches.
    Before systemd, everything went fine. Ondemand governor, set up like I wanted.
    Now when on AC the system uses ondemand, but when on battery it uses the conservative governor. What's more, it does not go over 1.6GHz (2.54GHz max).
    Here are some infos about it:
    [adriano@M735T ~] cpupower frequency-info
    analyzing CPU 0:
    driver: acpi-cpufreq
    CPUs which run at the same hardware frequency: 0 1
    CPUs which need to have their frequency coordinated by software: 0
    maximum transition latency: 10.0 us.
    hardware limits: 800 MHz - 2.53 GHz
    available frequency steps: 2.53 GHz, 2.53 GHz, 1.60 GHz, 800 MHz
    available cpufreq governors: ondemand, performance
    current policy: frequency should be within 800 MHz and 1.60 GHz.
    The governor "ondemand" may decide which speed to use
    within this range.
    current CPU frequency is 1.60 GHz.
    boost state support:
    Supported: yes
    Active: yes
    [yes this is all come out of the cpupower command, no mention of CPU 1. Is this normal?]
    Of course LMT is set up correctly
    CONTROL_CPU_FREQUENCY="1"
    BATT_CPU_MAXFREQ=fastest
    BATT_CPU_MINFREQ=slowest
    BATT_CPU_GOVERNOR=ondemand
    BATT_CPU_IGNORE_NICE_LOAD=1
    LM_AC_CPU_MAXFREQ=fastest
    LM_AC_CPU_MINFREQ=slowest
    LM_AC_CPU_GOVERNOR=ondemand
    LM_AC_CPU_IGNORE_NICE_LOAD=1
    NOLM_AC_CPU_MAXFREQ=fastest
    NOLM_AC_CPU_MINFREQ=slowest
    NOLM_AC_CPU_GOVERNOR=ondemand
    NOLM_AC_CPU_IGNORE_NICE_LOAD=0
    [adriano@M735T ~] sudo systemctl status laptop-mode-tools.service
    laptop-mode-tools.service - Laptop Power Saving Tools
    Loaded: loaded (/usr/lib/systemd/system/laptop-mode-tools.service; enabled)
    Active: active (exited) since Sun, 02 Sep 2012 17:03:45 +0200; 4h 34min ago
    Main PID: 367 (code=exited, status=0/SUCCESS)
    CGroup: name=systemd:/system/laptop-mode-tools.service
    Sep 02 17:03:43 M735T laptop_mode[367]: /usr/sbin/laptop_mode: line 198: /dev/fd/1: No such device or address
    Sep 02 17:03:44 M735T laptop_mode[367]: /usr/sbin/laptop_mode: line 198: /dev/fd/1: No such device or address
    Sep 02 17:03:44 M735T laptop_mode[367]: /usr/sbin/laptop_mode: line 198: /dev/fd/1: No such device or address
    I wonder why LMT status is "exited"
    OK bin that, I just now see something is wrong. I said it used conservative, but I'm on battery and it now says ondemand (still 1.6GHz max). However it seems it does so casually.
    ACPI:
    [adriano@M735T ~] acpi
    Battery 0: Discharging, 53%, rate information unavailable
    This may be (?) or may not be linked with nother problem I have: when unplugging the AC the KDE battery monitor does not update. It says AC is plugged and it will not activate power saving features (screen dimming, suspend...)
    Note that this battery monitor problem occurred even before systemd, so it should not be linked to the above problem. However I'm not 100% sure the above problems did not occur before installing systemd since I only had the system up and running for a comple of days. I seem to recall I checked and it worked fine.
    Any idea why all this happens?
    Last edited by OdinEidolon (2012-11-20 08:56:31)

    Ok rebooted and this is the output of the pm-powersave log file:
    (AC IN, no battery)
    (pastebin)
    http://pastebin.com/Kf2Lx7UQ
    If I grep cpupower:
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower true:
    Setting cpupower frequency governor to conservative...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower true: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    Running hook /usr/lib/pm-utils/power.d/cpupower false:
    Setting cpupower frequency governor to ondemand...Setting cpu: 0
    /usr/lib/pm-utils/power.d/cpupower false: success.
    right now:
    1) cpupower reports ondemand and 2.54GHz (right)
    2) acpi -bi reports nothing as it should (battery is disconnected)
    3) acpi -a reports AC in as it should
    4) all KDE stuff works OK
    Now I plug the battery in:
    1) cpupower reports ondemand and 2.54GHz (right)
    2) acpi -bi reports nothing, which is wrong
    3) acpi -a reports AC in as it should
    4) KDE battery monitor reports no battery in, as signaled by acpi
    5) if performing acpi_listen ,it reports nothing interesting
    Now I unplug AC:
    Absolutely nothing changes (not even in the log file) but:
    1) cpupower reports ondemand and 1.6GHz (wrong)
    2) acpi -bi reports nothing, which is wrong
    3) acpi -a reports no AC as it should
    4) KDE battery monitor reports no battery in, as signaled by acpi,  but it also reports AC is inserted

  • Xfce4-power-manager and laptop-mode-tools + backlight problems.

    Cross posted from here: https://bbs.archlinux.org/viewtopic.php?id=127992
    I don't know which forum it belongs to, so maybe a mod can close the one in the wrong forum.
    Out of curiosity, do these two tools conflict with each other? There seems to be some features that do the same thing, ie harddrive spin down time, but I'm not sure if these two will try to kill each other trying to configure the same power settings. If they do conflict, how could I go about disabling the conflicting parts (on either)? laptop-mode-tools claims it needs acpid "for ACPI support", however, acpid seems to be grabbing the standby event and throwing the laptop in standby despite the standby button bound to do nothing in xfce-power-manager. If I take out acpid, does that mean laptop-mode will no longer detect acpi events such as connecting/disconnecting AC power and thus not change modes when its plugged in?
    Another problem I've had after installing xfce4-power-manager is that when I use the brightness hotkeys the backlight gets stuck and starts flashing, locking up the system until I force shutdown. However, I can use the brightness plugin without trouble at all. What's causing the power manager to screw up setting the brightness since it clearly seems to work otherwise.

    It is easier to close this one and move the other thread over here. Just continue there.
    BTW better use the Report button when you want to have a thread of yours moved to another forum. That way it is guaranteed a mod will see this in time. And you never need to cross post.

  • Autohibernate with pm-utils and laptop-mode

    Hi all,
    I know this is a frequent problem but I cannot find any solution around the web.
    I am using pm-utils and am able to suspend to disk and ram properly.
    Now I want to hibernate automatically based on battery condition of my laptop.
    I have installed acpi and laptop-mode-tool,  and both seem to work correctly, my battery status appear on conky, and every other events based on laptop-mode run smoothly.
    I even wrote an /etc/laptop-mode/auto-hibernate.conf according to this post https://bbs.archlinux.org/viewtopic.php?id=50702.
    But the problem is still there, the laptop doesn't autohibernate on low battery.
    If anyone has managed to autohibernate based on low battery, I will glad to know his/her solution,
    regards
    Last edited by capnion (2012-01-25 10:38:18)

    even if im not using the tools you pasted. this is what ive done (since my battery hardware is a bit shaky, i had to add some cornercases, which lead to me creating a new script).
    some bits have been taken from the web (notify-send function for example).
    see if it works for you. of course, input will be appreciated too!.
    #!/bin/bash
    # power management script for my crappy laptop
    #BAT_FILE='/proc/acpi/battery/BAT0/state'
    BAT_BASE='/sys/class/power_supply/BAT0/'
    BAT_FILE='/sys/class/power_supply/BAT0/voltage_now'
    PDIR="/run/"
    LCK_FILE=${PDIR}`basename $0`.pid
    SAFE_STATE='5000000'
    MIN_STATE='10000000'
    MAX_STATE='12500000'
    THRESHOLD='10500000'
    HIB_SECS=60
    notify() {
    # Usage: notify "title" "description" [options to pass to send-notify"
    title="$1"
    body="$2"
    shift 2
    opts="$*"
    # Send messages to users listed by the 'users' command, but only once
    # Maybe sh has a better way of doing set operations, but this works:
    SENT=""
    for USER in $(users); do
    case $SENT in
    "$USER") ;;
    *" $USER") ;;
    "$USER "*) ;;
    *" $USER "*) ;;
    # use 'su USER' to send the message
    *) SENT="$SENT $USER";DISPLAY=:0 su $USER -c "notify-send $opts \"$title\" \"$body\"" ;;
    esac
    done
    # test if we are root.
    if [ $EUID != 0 ]; then
    sudo "$0" "$@"
    exit $?
    fi
    #test if we are running already
    echo "LCK_FILE=$LCK_FILE"
    if [ -f "${LCK_FILE}" ]; then
    MYPID=`head -n 1 "${LCK_FILE}"`
    TEST_RUNNING=`ps -p ${MYPID}|grep ${MYPID}`
    if [ -z "${TEST_RUNNING}" ]; then
    #the process is not running
    echo $$ > "$LCK_FILE"
    else
    echo "`basename $0` is already running [${MYPID}]"
    exit 0
    fi
    else
    echo $$ > "$LCK_FILE"
    fi
    if [ -a "$BAT_BASE" ]; then
    PRESENT=$(cat ${BAT_BASE}/present)
    if [ $PRESENT == '0' ]; then
    echo "Battery not present!"
    rm "${LCK_FILE}"
    exit 0
    else
    CURR_STATE=$(cat ${BAT_BASE}/voltage_now)
    CHAR_STATE=$(cat ${BAT_BASE}/status)
    fi
    else
    echo "Something wrong, file missing!"
    rm "${LCK_FILE}"
    exit 1
    fi
    if [ $CURR_STATE -lt $SAFE_STATE ]; then
    echo "buggy batt, ignored result: $CURR_STATE"
    rm "${LCK_FILE}"
    exit 0
    fi
    if [ $CURR_STATE -lt $THRESHOLD ]; then
    if [ $CHAR_STATE != "Charging" ]; then
    echo "battery level low, hibernating in $HIB_SECS seconds"
    notify "BATTERY STATUS" "battery level low, hibernating in $HIB_SECS seconds. Connect to AC to cancel"
    sleep $HIB_SECS
    CHAR_STATE=$(cat ${BAT_BASE}/status)
    if [ $CHAR_STATE != "Charging" ]; then
    /usr/sbin/pm-hibernate
    # notify "BATTERY STATUS" "Comming out of hibernate!!"
    rm "${LCK_FILE}"
    exit 0
    fi
    notify "BATTERY STATUS" "Charger plugged. hibernate disabled"
    fi
    else
    echo "battery state: $CHAR_STATE"
    echo "battery level: $CURR_STATE"
    # notify "battery level:" "$CURR_STATE"
    fi
    rm "${LCK_FILE}"
    it is run by root every minute. it warns through notify-send one minute prior to hibernating, and aborts if the laptop was plugged within that minute.
    some variables should be tweaked for your battery
    EDIT: fixed a bug when testing if battery was being charged/discharged. added test for root.
    Last edited by eldragon (2012-01-25 14:33:40)

  • [SOLVED] systemd: laptop-mode-tools fails to start (No such file ...)

    Hi,
    I recently moved to systemd. I noticed that 'laptop-mode-tools' does not start:
    Loaded: error (Reason: No such file or directory)
    Active: inactive (dead)
    Also laptop-mode itself does not run (but exits successfully), maybe this has something to do with it:
    laptop-mode.service - Laptop Mode Tools
    Loaded: loaded (/usr/lib/systemd/system/laptop-mode.service; enabled)
    Active: active (exited) since Sat, 2012-11-10 10:44:13 CET; 2min 17s ago
    Process: 1020 ExecStart=/usr/sbin/laptop_mode init auto (code=exited, status=0/SUCCESS)
    CGroup: name=systemd:/system/laptop-mode.service
    I cannot find anything in journal that would help resolve this issue. Has someone else come across this problem? Where should I look to fix this issue?
    Sidenote: When I boot up, there show up some errors about 'eth0' and 'wlan0' "No such file or directory", but I cannot find them in the journal so I don't know them exactly.
    Last edited by javex (2012-11-10 12:41:07)

    When I upgraded, pacman said the following
    [2012-11-04 09:41] The systemd service name has changed from \laptop-mode-tools" to "laptop-mode"
    [2012-11-04 09:41] The change requires the old symlink to be manually removed:
    [2012-11-04 09:41] rm /etc/systemd/system/multi-user.target.wants/laptop-mode-tools.service
    [2012-11-04 09:41] The laptop-mode.service can be enabled using:
    [2012-11-04 09:41] systemctl enable laptop-mode
    [2012-11-04 09:41] upgraded laptop-mode-tools (1.61-2 -> 1.62-2)

  • Power management: laptop-mode-tools and pm-utils confusion

    There have been a few threads recently that touch on this topic, but I'm still somewhat confused as to how best to use these two tools for power management.
    As I understand it, laptop-mode-tools is a set of scripts and config files for controlling various aspects of power saving, while pm-utils started as a tool for managing suspend/hibernate.  However, newer versions of pm-utils have begun to include general power management features that conflict with those of laptop-mode-tools, and respond to the pm-powersave command.
    Ideally, I would like to control power management in the following way: Have acpid as the only running daemon (rather than acpid and laptop-mode-tools as I have now), which then calls pm-suspend, pm-hibernate and pm-powersave in the appropriate circumstances. 
    The wiki has a brief guide on how to insert pm-powersave as an acpi event; however, it seems to me that pm-utils is not able to replicate all the functions of laptop-mode-tools yet, for example in controlling the eeepc's SHE.
    In this thread: https://bbs.archlinux.org/viewtopic.php?pid=784969, einhard seems to suggest that its quite a simple process to modify some hooks from laptop-mode-tools to make them work with pm-utils.  I would be eternally grateful if somebody could post an example of how to carry out this modification.  I have very minimal knowledge of bash, which means that I can't get going on my own but I think I could modify the rest of the hooks on my own if I had an example, a template, to guide me. 
    Of course if anyone has any other suggestions regarding how best to mix these tools for power management it would be very good to hear them.  I am aware of this thread: https://bbs.archlinux.org/viewtopic.php?id=88011&p=2, in which takedown suggests writing some dummy hooks to pm-utils to prevent any conflict, but I'm not entirely clear about which hooks I should apply this to, i. e. just the hooks in power.d or those in sleep.d, too?

    mordoc, what exactly is the problem your having?
    Since I made the original post I have actually succeeded in creating the setup I described, i.e. I have removed laptop-mode-tools and have pm-utils do all suspend, hibernate and power management functions using acpid.  This required adding a very simple custom hook to pm-powersave to deal with all the power-saving functions of laptop-mode-tools that pm-powersave does not (yet) replace OOTB.

  • Laptop-mode-tools fixes and improvements

    I have been in contact with the autor of laptop-mode-tools and new version is coming some time next month or maybe even in March. So I decided to share my tweaks because some things are broken right now and some need improvements.
    There are some modules I don't use and so didn't notice any problems with them, if there are any (lcd-brightness, video-out and those for which I don't have suitable hardware like cpufreq, iwl/ipw and sched-mc).
    Alright then, first is the problem with systems where the battery doesn't report events and has no alarm support on which the auto-hibernate module depends. There is a script from gentoo-wiki which is quite popular among people with lousy batteries. It would be great if the package manager would take care of it for us. Author of laptop-mode-tools also said (on debian lists) that such script could be included in future versions, for now the common "solution" is to create a cronjob that calls /usr/sbin/laptop_mode every few minutes. I don't quite like it compared to the gentoo script. For now I include the script in the package as /usr/sbin/battery_mode and call it from rc.local on boot.
    Currently there is a module called ac97-powersave that controls power management on those sound cards. Intel HDA sound cards also support this and in the future versions a module them will probably be included. For now I patch the ac97-powersave module to include the support for Intel HDA.
    Bluetooth module removes bluetooth and hci_usb modules when disabling the device. However on my system it's not enough to completly turn it off. For now I patch the bluetooth module to include rfkill support. Only then the system reports a USB disconnect and the LED goes off. The default path in the patch is for my acer system with acer-wmi rfkill support.
    Due to w differences the dpms-standby module is broken on many systems. The module uses xset and arguments are piped from the command w -hs where the third field is supposed to be DPMS_SCREEN but it's actually IDLE time, so xset command fails because the argument passed to xset -d is something like 4:54. On Debian/Ubuntu they went around this by including this in their acpi-support package. I didn't bother to see what they actually did, to backport it. It should be done in future laptop-mode-tools anyway. For now I just hardcode the display value for my single-user/one-X-screen system in the dpms-standby module.
    Due to a simple mistake LM_VERBOSE was broken. Meaning that none of those informative status messages from laptop-mode-tools were logged when VERBOSE LOGGING was enabled. Only the output of called commands was logged. For now I fix this in the build process.
    Speaking of logging, default output for verbose is /dev/stdout, and I would like to log everything to a file. So I modify it in the build process to log everything to /var/log/laptop-mode.log, and also include a logrotate script in the package. With the above fix I have a complete and informative log file.
    It's not a bad idea to stop/restart laptop-mode-tools when suspending, so a pm-utils hook is helpful. Arch PKGBUILD already includes installing pm-utils support but it's actually pbbuttonsd/pmud support and not pm-utils. Such a script/hook could one day be included in laptop-mode-tools however there is/was a debate going if it's their job to provide it. I read somewhere that Ubuntu already provides such script/hook but I'm not sure if it's provided by acpi-support or laptop-mode-tools package. For now I wrote my own pm-utils hook and I include it in the build process.
    Powertop suggests usbcore.autosuspend=1 sysctl, but it would be nice if we have all this power management control in one place. Usb-autosuspend module will be included in future versions of laptop-mode-tools, but for now someone wrote a module and posted it to the Debian bug tracker. I keep the module and configuration in my build dir but don't include it in the final package for now. I'll wait a bit and see how things will develop.
    To help you start hacking on laptop-mode-tools you can take a look at all the above patches and my PKGBUILD. Every step is documented in PKGBUILD comments, and please do check them because some things I patch but some I modify inline with sed. I also don't install acpid handlers and before mentioned false pm-utils support... everything is commented: http://sysphere.org/~anrxc/local/softwa … ode-tools/

    Hello,
    this was one year ago, and I helped the author improve these things. Today I don't have to patch my laptop-mode-tools... (I still do with some minor things, but that's just to satisfy some personal preferences . Use the arch package, even the battery polling helper is included.

  • Laptop-mode-tools and hdparm -B settings

    Since the change to systemd (I think so), I have a problem with laptop-mode-tools and hdparm. The hdparm -B settings (settings to park the hard drive) are most of the times not applied on startup of my laptop. But: sometimes the setting in the config file of laptop-mode-tools is applied.
    These configs I have in /etc/laptop-mode/laptop-mode.conf:
    # Power management for HD (hdparm -B values)
    BATT_HD_POWERMGMT=254
    LM_AC_HD_POWERMGMT=254
    NOLM_AC_HD_POWERMGMT=254
    If I check the settings of hdparm after starting my laptop (sudo hdparm -B /dev/sda), most of the times the setting is 128. Because I am afraid that my hard drive will damage with this setting, every time I have to do 'sudo systemctl restart laptop-mode.service'. After that, the setting of hdparm -B is 254.
    Does anybody know something to solve this annoying problem? Thanks in advance!

    You could write an udev rule. That's what I did, although laptop-mode-tools was giving me the same result - I just wanted to reduce the list of services for the sake of boot speed.
    Mine looks like this:
    /etc/udev/rules.d/75-hdparm.rules
    ACTION=="add", KERNEL=="sda", ATTR{queue/rotational}=="1", RUN+="/sbin/hdparm -B 254 /dev/$kernel"
    You might have to change "sda" according to your system.
    Disclaimer (and friendly hint): I didn't come up with this by myself, I had to borrow it from somewhere on this forum.
    Edit: from here, but you can also find it there.
    Last edited by sano (2013-04-04 23:53:09)

  • Laptop-mode-tools issue with log / logger

    I had an issue with laptop-mode-tools where systemd reported it failed (the laptop-mode service). Specifically I got an error with wireless-power in /usr/share/laptop-mode/modules/. Clearly one issue was that I did not install wireless_tools. But I had another issue: It complained with "log: command not found" so I looked into the file and there were several calls to "log [...]". I changed them to "logger [...]" and the error is gone.
    Am I missing something here or is this really an issue? Maybe a bug? Or an error on my side?

    I had the problem but edited the line in /usr/sbin/laptop_mode and it worked. But thoes lines are not there anymore. I guess they changed it at the recent update of laptop-mode-tools.
    Regarding your heat problem; is there any other thing you use to cut down power usage (from AUR  maybe)? I use acpi_call from AUR had to edit lines there aswell, but it should be updated by now.

  • Laptop mode tools problem with kernel 3.0

    today I just updated the system and my laptop runs dramatically hotter after that. I read the archwiki, it does talk about the laptop mode tools problem with kernel 3.0 but when I opened the file /usr/sbin/laptop_mode, the lines which the wiki mentions are not there. Does anyone here have the same problem and can you offer the solution?
    Here is my /usr/sbin/laptop_mode
    #! /bin/sh
    # Script to start or stop laptop_mode, and to control various settings of the
    # kernel, hardware etc. that influence power consumption.
    # This script is a part of Laptop Mode Tools. If you are running a supported
    # power management daemon, this script will be automatically called on power
    # state change.
    # Configure laptop mode tools in /etc/laptop-mode/laptop-mode.conf, and in
    # the broken-out config files in /etc/laptop-mode/conf.d.
    # Please consult the manual pages laptop-mode.conf(8) and laptop_mode(8) for
    # additional information.
    # Maintainer: Ritesh Raj Sarraf ([email protected])
    # Original Author: Bart Samwel ([email protected])
    # Project home page: http://samwel.tk/laptop_mode
    # Contributors to this script: Bart Samwel
    # Kiko Piris
    # Micha Feigin
    # Andrew Morton
    # Herve Eychenne
    # Dax Kelson
    # Jan Polacek
    # ... and many others that I've stopped
    # keeping track of.
    # Based on a script for Linux 2.4 written by Jens Axboe.
    set -a
    # The laptop mode tools version number. Extracted by the installer makefile
    # as well, so don't change the format!
    LMTVERSION=1.59
    # This script is loaded from multiple scripts to set the config defaults
    # and to read the configuration on top of those. Only when the command is
    # recognized does this script do anything else.
    VERBOSE_OUTPUT=0
    ENABLE_LAPTOP_MODE_ON_BATTERY=1
    ENABLE_LAPTOP_MODE_ON_AC=0
    ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=0
    PARTITIONS="auto /dev/mapper/*"
    LM_BATT_MAX_LOST_WORK_SECONDS=600
    LM_AC_MAX_LOST_WORK_SECONDS=360
    DEF_MAX_AGE=30
    LM_READAHEAD=3072
    NOLM_READAHEAD=128
    CONTROL_READAHEAD=1
    CONTROL_NOATIME=0
    USE_RELATIME=1
    CONTROL_HD_IDLE_TIMEOUT=1
    LM_AC_HD_IDLE_TIMEOUT=4 # 20 seconds
    LM_BATT_HD_IDLE_TIMEOUT=4 # 20 seconds
    NOLM_HD_IDLE_TIMEOUT=244 # 2 hours
    DEF_UPDATE=5
    DEF_XFS_AGE_BUFFER=15
    DEF_XFS_SYNC_INTERVAL=30
    DEF_XFS_BUFD_INTERVAL=1
    XFS_HZ=100
    CONTROL_MOUNT_OPTIONS=1
    BATT_HD_POWERMGMT=1
    LM_AC_HD_POWERMGMT=254
    NOLM_AC_HD_POWERMGMT=254
    CONTROL_HD_POWERMGMT=0
    CONTROL_HD_WRITECACHE=0
    NOLM_AC_HD_WRITECACHE=1
    NOLM_BATT_HD_WRITECACHE=0
    LM_HD_WRITECACHE=0
    LM_DIRTY_RATIO=60
    LM_DIRTY_BACKGROUND_RATIO=1
    NOLM_DIRTY_BACKGROUND_RATIO=10
    NOLM_DIRTY_RATIO=40
    LM_SECONDS_BEFORE_SYNC=2
    BATT_CPU_MAXFREQ=medium
    BATT_CPU_MINFREQ=slowest
    BATT_CPU_GOVERNOR=ondemand
    BATT_CPU_IGNORE_NICE_LOAD=1
    LM_AC_CPU_MAXFREQ=fastest
    LM_AC_CPU_MINFREQ=slowest
    LM_AC_CPU_GOVERNOR=ondemand
    LM_AC_CPU_IGNORE_NICE_LOAD=1
    NOLM_AC_CPU_MAXFREQ=fastest
    NOLM_AC_CPU_MINFREQ=slowest
    NOLM_AC_CPU_GOVERNOR=ondemand
    NOLM_AC_CPU_IGNORE_NICE_LOAD=0
    CONTROL_CPU_FREQUENCY=0
    HD="/dev/[hs]d[abcdefgh]"
    CONTROL_SYSLOG_CONF=0
    LM_AC_SYSLOG_CONF=/etc/syslog-on-ac-with-lm.conf
    NOLM_AC_SYSLOG_CONF=/etc/syslog-on-ac-without-lm.conf
    BATT_SYSLOG_CONF=/etc/syslog-on-battery.conf
    SYSLOG_CONF_SIGNAL_PROGRAM=syslogd
    SYSLOG_CONF=/etc/syslog.conf
    CONTROL_DPMS_STANDBY=0
    BATT_DPMS_STANDBY=300
    LM_AC_DPMS_STANDBY=1200
    NOLM_AC_DPMS_STANDBY=1200
    CONTROL_CPU_THROTTLING=0
    BATT_CPU_THROTTLING=medium
    LM_AC_CPU_THROTTLING=minimum
    NOLM_AC_CPU_THROTTLING=minimum
    CONTROL_START_STOP=1
    CONTROL_TERMINAL=0
    TERMINALS="/dev/vc/1 /dev/vcs1"
    BATT_TERMINAL_BLANK_MINUTES=1
    BATT_TERMINAL_POWERDOWN_MINUTES=2
    LM_AC_TERMINAL_BLANK_MINUTES=10
    LM_AC_TERMINAL_POWERDOWN_MINUTES=10
    NOLM_AC_TERMINAL_BLANK_MINUTES=10
    NOLM_AC_TERMINAL_POWERDOWN_MINUTES=50
    ENABLE_AUTO_HIBERNATION=0
    HIBERNATE_COMMAND=/usr/sbin/hibernate
    AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL=1
    DISABLE_LAPTOP_MODE_ON_CRITICAL_BATTERY_LEVEL=1
    AUTO_HIBERNATION_BATTERY_CHARGE_MAH=0
    AUTO_HIBERNATION_BATTERY_CHARGE_MWH=0
    MINIMUM_BATTERY_CHARGE_MAH=0
    MINIMUM_BATTERY_CHARGE_MWH=0
    ASSUME_SCSI_IS_SATA=1
    CONTROL_BRIGHTNESS=0
    BATT_BRIGHTNESS_COMMAND=false
    LM_AC_BRIGHTNESS_COMMAND=false
    NOLM_AC_BRIGHTNESS_COMMAND=false
    LOG_TO_SYSLOG=1
    DEBUG=0
    ENABLE_LAPTOP_MODE_TOOLS=1
    # Initialize the PATH Variable
    export PATH="${PATH}":/bin:/sbin:/usr/bin:/usr/sbin
    # This is a 2 phase locking approach. LMT_REQ_LOCK is the outer lock and LMT_INVOC_LOCK is the inner lock
    # We take this approach to ensure the scenario that, "At any point when an event occurs (AC/BATT), the
    # kernel can generate multiple events spanning over a couple of events. The first event is honored and
    # lmt executes. If the last event triggered at the 9th second, there is a fair chance that a good amount
    # of state change would have occured in the OS, to honor that state, we keep an outer lock (LMT_REQ_LOCK)
    # handy, so that those changes can also be applied and not forgotten.
    # Workflow:
    # Event-1 is generated and lmt executes (lmt runtime could span 5-10 seconds)
    # At seventh second, 4 events generate. But Event-1 is still running.
    # We don't want to discard all the remaining 4 events, but at least honor 1 so that we can act to the changes
    # that occured in the last 7 seconds.
    # So, Event-2 acquire LMT_REQ_LOCK and waits to acquire LMT_INVOC_LOCK (which is acquire by Event-1)
    LMT_REQ_LOCK="/var/lock/lmt-req.lock"
    LMT_INVOC_LOCK="/var/lock/lmt-invoc.lock"
    FLOCK=`which flock`
    checkint ()
    # $1 arg should be the string/integer
    # that you want to check for as an integer.
    echo $1 | grep "[^0-9]" > /dev/null 2>&1
    return $?;
    # Returns 1 if it is an integer
    # Function to handle logging
    LOGGER=`which logger`;
    log ()
    # $1 should be msg type
    # $2 should be the real msg
    if [ x$LOG_TO_SYSLOG = x1 ]; then
    # NOTE: Add the check on $2 being empty, once you are confident
    # that there aren't any bugs in logging. And no bugs in executing
    # modules and logging
    if [ -x $LOGGER -a "$1" != "STATUS" ]; then
    #if [ -z $2 ]; then
    # continue
    #elif [ "$1" = "MSG" ]; then
    if [ "$1" = "MSG" ]; then
    logger -p daemon.info -t laptop-mode "$2";
    elif [ "$1" = "ERR" ]; then
    logger -p daemon.err -t laptop-mode "$2";
    elif [ "$1" = "VERBOSE" ]; then
    if [ x$VERBOSE_OUTPUT = x1 ]; then
    logger -p daemon.debug -t laptop-mode "$2";
    fi
    else
    logger -p daemon.notice -t laptop-mode "$2";
    fi
    fi
    fi
    if [ "$1" = "VERBOSE" ]; then
    $LM_VERBOSE && echo "$2" >/dev/fd/2;
    elif [ "$1" = "ERR" ]; then
    echo "$2" >/dev/fd/2;
    else
    # Message of type MSG and STATUS can go to stdout.
    echo "$2" >/dev/fd/1;
    fi
    enableDebug ()
    # Check if debug is enabled
    if [ x$(($(basename $1 | cut -d . -f1 | tr "[:lower:]" "[:upper:]" | sed 's/-/_/g')_DEBUG)) = x1 ]; then
    set -vx
    fi
    disableDebug ()
    # Check if debug is enabled
    if [ x$(($(basename $1 | cut -d . -f1 | tr "[:lower:]" "[:upper:]" | sed 's/-/_/g')_DEBUG)) = x1 ]; then
    set +vx
    fi
    # No default on these ones -- we need to detect if they have been set, for
    # backward compatibility with MINIMUM_BATTERY_MINUTES etc.
    AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT=
    MINIMUM_BATTERY_CHARGE_PERCENT=
    # Backward compatibility variable that is sometimes
    # set externally (Debian init system)
    unset VERBOSE
    lmt_load_config ()
    # Source config. Some config settings have been moved from the main config file
    # to modular configuration files, and to support existing laptop-mode.conf
    # files from earlier versions, we source the modular configuration files FIRST.
    if [ -d /etc/laptop-mode/conf.d ] ; then
    for CONF in /etc/laptop-mode/conf.d/*.conf ; do
    if [ -r "$CONF" ] ; then
    . "$CONF"
    #Handle individual module debug settings
    if [ "$DEBUG" -eq 1 ]; then
    export $(basename $CONF | cut -d . -f1 | tr "[:lower:]" "[:upper:]" | sed 's/-/_/g')_DEBUG=1
    log "VERBOSE" "Enabling debug mode for module $CONF"
    fi
    DEBUG=0
    else
    log "MSG" "Warning: Configuration file $CONF is not readable, skipping."
    fi
    done
    fi
    if [ -r /etc/laptop-mode/laptop-mode.conf ] ; then
    . /etc/laptop-mode/laptop-mode.conf
    else
    log "ERR" "$0: Configuration file /etc/laptop-mode/laptop-mode.conf not present or not readable."
    exit 1
    fi
    if [ x$ENABLE_LAPTOP_MODE_TOOLS = x0 ]; then
    log "MSG" "laptop-mode-tools is disabled in config file. Exiting"
    exit 0;
    fi
    # Add a simple bash debug mode switch
    if [ "$DEBUG" -eq 1 ]; then
    set -vx;
    fi
    # Support for old config settings
    if [ "$AC_HD" != "" ] ; then
    AC_HD_WITHOUT_LM="$AC_HD"
    AC_HD_WITH_LM="$AC_HD"
    fi
    if [ "$VERBOSE" != "" ] ; then
    VERBOSE_OUTPUT="$VERBOSE"
    fi
    if [ "$CPU_MAXFREQ" != "" ] ; then
    BATT_CPU_MAXFREQ="$CPU_MAXFREQ"
    fi
    if [ "$MAX_AGE" != "" ] ; then
    LM_BATT_MAX_LOST_WORK_SECONDS="$MAX_AGE"
    LM_AC_MAX_LOST_WORK_SECONDS="$MAX_AGE"
    fi
    if [ "$DEF_AGE" != "" ] ; then
    DEF_MAX_AGE="$DEF_AGE"
    fi
    if [ "$LAPTOP_MODE_ALWAYS_ON" != "" ] ; then
    ENABLE_LAPTOP_MODE_ALWAYS="$LAPTOP_MODE_ALWAYS_ON"
    fi
    if [ "$LM_WHEN_LID_CLOSED" != "" ] ; then
    ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED="$LM_WHEN_LID_CLOSED"
    fi
    if [ "$REMOUNT_PARTITIONS" != "" ] ; then
    PARTITIONS="$REMOUNT_PARTITIONS"
    fi
    if [ "$READAHEAD" != "" ] ; then
    LM_READAHEAD="$READAHEAD"
    fi
    if [ "$DO_REMOUNT_NOATIME" != "" ] ; then
    CONTROL_NOATIME="$DO_REMOUNT_NOATIME"
    fi
    if [ "$DO_HD" != "" ] ; then
    CONTROL_HD_IDLE_TIMEOUT="$DO_HD"
    fi
    if [ "$AC_HD_WITH_LM" != "" ] ; then
    LM_AC_HD_IDLE_TIMEOUT="$AC_HD_WITH_LM"
    fi
    if [ "$AC_HD_WITHOUT_LM" != "" ] ; then
    NOLM_HD_IDLE_TIMEOUT="$AC_HD_WITHOUT_LM"
    fi
    if [ "$BATT_HD" != "" ] ; then
    LM_BATT_HD_IDLE_TIMEOUT="$BATT_HD"
    fi
    if [ "$DO_REMOUNTS" != "" ] ; then
    CONTROL_MOUNT_OPTIONS="$DO_REMOUNTS"
    fi
    if [ "$DO_HD_POWERMGMT" != "" ] ; then
    CONTROL_HD_POWERMGMT="$DO_HD_POWERMGMT"
    fi
    if [ "$AC_HDPARM_POWERMGMT_WITH_LM" != "" ] ; then
    LM_AC_HD_POWERMGMT="$AC_HDPARM_POWERMGMT_WITH_LM"
    fi
    if [ "$AC_HDPARM_POWERMGMT_WITHOUT_LM" != "" ] ; then
    NOLM_AC_HD_POWERMGMT="$AC_HDPARM_POWERMGMT_WITHOUT_LM"
    fi
    if [ "$BATT_HDPARM_POWERMGMT" != "" ] ; then
    BATT_HD_POWERMGMT="$BATT_HDPARM_POWERMGMT"
    fi
    if [ "$DO_WRITECACHE" != "" ] ; then
    CONTROL_HD_WRITECACHE="$DO_WRITECACHE"
    fi
    if [ "$AC_WRITECACHE_WITHOUT_LM" != "" ] ; then
    NOLM_AC_HD_WRITECACHE="$AC_WRITECACHE_WITHOUT_LM"
    fi
    if [ "$BATT_WRITECACHE" != "" ] ; then
    LM_HD_WRITECACHE="$BATT_WRITECACHE"
    fi
    if [ "$DIRTY_RATIO" != "" ]; then
    LM_DIRTY_RATIO="$DIRTY_RATIO"
    fi
    if [ "$DIRTY_BACKGROUND_RATIO" != "" ] ; then
    LM_DIRTY_BACKGROUND_RATIO="$DIRTY_BACKGROUND_RATIO"
    fi
    if [ "$DEF_DIRTY_RATIO" != "" ]; then
    NOLM_DIRTY_RATIO="$DEF_DIRTY_RATIO"
    fi
    if [ "$DEF_DIRTY_BACKGROUND_RATIO" != "" ] ; then
    NOLM_DIRTY_BACKGROUND_RATIO="$DEF_DIRTY_BACKGROUND_RATIO"
    fi
    if [ "$DO_CPU" != "" ] ; then
    CONTROL_CPU_FREQUENCY="$DO_CPU"
    fi
    if [ "$CONTROL_CPU_MAXFREQ" != "" ] ; then
    CONTROL_CPU_FREQUENCY="$CONTROL_CPU_MAXFREQ"
    fi
    if [ "$AC_CPU_MAXFREQ_WITH_LM" != "" ] ; then
    LM_AC_CPU_MAXFREQ="$AC_CPU_MAXFREQ_WITH_LM"
    fi
    if [ "$AC_CPU_MAXFREQ_WITHOUT_LM" != "" ] ; then
    NOLM_AC_CPU_MAXFREQ="$AC_CPU_MAXFREQ_WITHOUT_LM"
    fi
    if [ "$DO_SYSLOG" != "" ] ; then
    CONTROL_SYSLOG_CONF="$DO_SYSLOG"
    fi
    if [ "$SYSLOG_SIGNAL_PROGRAM" != "" ] ;then
    SYSLOG_CONF_SIGNAL_PROGRAM="$SYSLOG_SIGNAL_PROGRAM"
    fi
    if [ "$AC_SYSLOG_WITH_LM" != "" ] ; then
    LM_AC_SYSLOG_CONF="$AC_SYSLOG_WITH_LM"
    fi
    if [ "$AC_SYSLOG_WITHOUT_LM" != "" ] ; then
    NOLM_AC_SYSLOG_CONF="$AC_SYSLOG_WITHOUT_LM"
    fi
    if [ "$BATT_SYSLOG" != "" ] ; then
    BATT_SYSLOG_CONF="$BATT_SYSLOG"
    fi
    if [ "$ENABLE_LAPTOP_MODE_ALWAYS" != "" ] ; then
    ENABLE_LAPTOP_MODE_ON_AC="$ENABLE_LAPTOP_MODE_ALWAYS"
    fi
    if [ "$MINIMUM_BATTERY_MINUTES" != "" -a "$MINIMUM_BATTERY_CHARGE_PERCENT" = "" ] ; then
    # Use a very conservative estimate (1% = 1 battery minute, 100 minutes in a battery)
    # for backward compatibility.
    MINIMUM_BATTERY_CHARGE_PERCENT="$MINIMUM_BATTERY_MINUTES"
    fi
    if [ -z "$MINIMUM_BATTERY_CHARGE_PERCENT" ] ; then
    # Apply the default, now that we've determined that this is the minimum.
    MINIMUM_BATTERY_CHARGE_PERCENT=3
    fi
    if [ "$AUTO_HIBERNATION_BATTERY_MINUTES" != "" -a "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" = "" ] ; then
    # Use a very conservative estimate (1% = 1 battery minute, 100 minutes in a battery)
    # for backward compatibility.
    AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT="$AUTO_HIBERNATION_BATTERY_MINUTES"
    fi
    if [ -z "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" ] ; then
    # Apply the default, now that we've determined that this is the minimum.
    AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT=2
    fi
    # Postprocessing
    if [ "$VERBOSE_OUTPUT" -ne 0 ] ; then
    OUTPUT="/dev/stdout"
    LM_VERBOSE="[ 1 = 1 ]"
    else
    OUTPUT="/dev/null"
    LM_VERBOSE="[ 1 = 0 ]"
    fi
    if [ "$PARTITIONS" = "" ] ; then
    PARTITIONS="auto /dev/mapper/*"
    fi
    # Expand shell wild cards immediately.
    PARTITIONS=$( echo $PARTITIONS )
    TERMINALS=$( echo $TERMINALS )
    # Convert seconds to hdparm -S format
    # Everything over 20 minutes is interpreted as 2 hours.
    seconds_to_hdparm_S() {
    if [ "$1" -eq 0 ] ; then
    # disable.
    echo 0
    elif [ "$1" -gt 0 -a "$1" -lt 5 ] ; then
    # 5 seconds minimum
    echo 1
    elif [ "$1" -le $((240*5)) ] ; then
    # Values between 1 and 240 signify increments of 5 seconds
    echo $(($1 / 5))
    elif [ "$1" -lt $((30*60)) ] ; then
    # Values between 20 and 30 minutes are rounded up to 30 minutes.
    echo 241
    elif [ "$1" -lt $((12*30*60)) ] ; then
    # Values between 30 minutes and 6 hours (exclusive) yield values between
    # 241 and 251, in 30-minute increments.
    echo $(( 240 + ($1 / (30*60)) ))
    else
    # Larger values effectively indicate no timeout at all.
    echo 0
    fi
    # Convert configured idle timeouts to hdparm -S format.
    if [ "$LM_AC_HD_IDLE_TIMEOUT_SECONDS" != "" ] ; then
    LM_AC_HD_IDLE_TIMEOUT=$(seconds_to_hdparm_S $LM_AC_HD_IDLE_TIMEOUT_SECONDS)
    fi
    if [ "$LM_BATT_HD_IDLE_TIMEOUT_SECONDS" != "" ] ; then
    LM_BATT_HD_IDLE_TIMEOUT=$(seconds_to_hdparm_S $LM_BATT_HD_IDLE_TIMEOUT_SECONDS)
    fi
    if [ "$NOLM_HD_IDLE_TIMEOUT_SECONDS" != "" ] ; then
    NOLM_HD_IDLE_TIMEOUT=$(seconds_to_hdparm_S $NOLM_HD_IDLE_TIMEOUT_SECONDS)
    fi
    # The main workhorse.
    lmt_main_function ()
    if [ "$1" = "status" ] ; then
    # Display a status report.
    log "STATUS" "Mounts:"
    mount | sed "s/^/ /"
    log "STATUS" " "
    log "STATUS" "Drive power status:"
    for disk in $HD; do
    if [ -r $disk ]; then
    hdparm -C $disk 2>/dev/null | sed "s/^/ /"
    else
    log "STATUS" " Cannot read $disk, permission denied - $0 needs to be run as root"
    fi
    done
    log "STATUS" " "
    log "STATUS" "(NOTE: drive settings affected by Laptop Mode cannot be retrieved.)"
    log "STATUS" " "
    log "STATUS" "Readahead states:"
    cat /etc/mtab | while read DEV MP FST OPTS DUMP PASS ; do
    # skip funny stuff
    case "$FST" in
    rootfs|unionfs|tmpfs|squashfs|sysfs|usbfs|proc|devpts) continue
    esac
    if [ -b $DEV ] ; then
    if [ -r $DEV ] ; then
    log "STATUS" " $DEV: $((`blockdev --getra $DEV` / 2)) kB"
    else
    log "STATUS" " Cannot read $DEV, permission denied - $0 needs to be run as root"
    fi
    fi
    done
    log "STATUS" " "
    if [ -e /var/run/laptop-mode-tools/enabled ] ; then
    log "STATUS" "Laptop Mode Tools is allowed to run: /var/run/laptop-mode-tools/enabled exists."
    else
    log "STATUS" "Laptop Mode Tools is NOT allowed to run: /var/run/laptop-mode-tools/enabled does not exist."
    fi
    log "STATUS" " "
    STATFILES="/proc/sys/vm/laptop_mode /proc/apm /proc/pmu/info /proc/sys/vm/bdflush /proc/sys/vm/dirty_ratio /proc/sys/fs/xfs/age_buffer /proc/sys/fs/xfs/sync_interval /proc/sys/fs/xfs/lm_age_buffer /proc/sys/fs/xfs/lm_sync_interval /proc/sys/vm/pagebuf/lm_flush_age /proc/sys/fs/xfs/xfsbufd_centisecs /proc/sys/fs/xfs/xfssyncd_centisecs /proc/sys/vm/dirty_background_ratio /proc/sys/vm/dirty_expire_centisecs /proc/sys/fs/xfs/age_buffer/centisecs /proc/sys/vm/dirty_writeback_centisecs /sys/devices/system/cpu/*/cpufreq/cpuinfo_*_freq /sys/devices/system/cpu/*/cpufreq/scaling_governor /proc/acpi/button/lid/*/state /proc/acpi/ac_adapter/*/state /proc/acpi/battery/*/state /sys/class/power_supply/*/online /sys/class/power_supply/*/state"
    for THISFILE in $STATFILES ; do
    if [ -e "$THISFILE" ] ; then
    log "STATUS" "$THISFILE:"
    if [ -r "$THISFILE" ] ; then
    cat "$THISFILE" | sed "s/^/ /"
    else
    log "STATUS" " Not accessible, permission denied - $0 needs to be run as root."
    fi
    log "STATUS" " "
    fi
    done
    elif [ "$1" != "readconfig" -a "$1" != "defaults" ] ; then
    KLEVEL="$(uname -r |
    IFS='.-' read a b c
    echo $a.$b
    KMINOR="$(uname -r |
    IFS='.-' read a b c d
    # Strip any stuff from the end -- only the initial digits are part of the KMINOR.
    echo $c | sed -e 's/\([[:digit:]]*\).*/\1/'
    # Stop exporting everything -- what we do from here is private.
    set +a
    if [ "$1" = "--version" ] ; then
    log "MSG" "Laptop Mode Tools $LMTVERSION"
    exit 0
    fi
    if [ ! -e /proc/sys/vm/laptop_mode ] ; then
    log "ERR" "Kernel does not have support for laptop mode. Please apply the laptop mode"
    log "ERR" "patch or install a newer kernel."
    exit 1
    fi
    if [ ! -w /proc/sys/vm/laptop_mode ] ; then
    log "ERR" "You do not have enough privileges to enable laptop_mode."
    exit 1
    fi
    INIT=0 # Display info in init script format?
    FORCE=0 # Force reapplying the current state?
    while [ "$1" != "" ] ; do
    case "$1" in
    init) INIT=1 ;;
    force) FORCE=1 ;;
    # Old options. We always do "auto" for any option now, but
    # we still have to accept the options.
    start) ;;
    stop) ;;
    auto) ;;
    modules=*)
    MODULES=$1
    MODULES=${MODULES#"modules="}
    devices=*)
    DEVICES=$1
    DEVICES=${DEVICES#"devices="}
    *) log "ERR" "Unrecognized option $1."
    exit 1 ;;
    esac
    shift
    done
    mkdir -p /var/run/laptop-mode-tools
    # Used to display laptop mode state later on. This is the enabled/disabled
    # state for laptop mode processing, it tells us nothing about whether laptop
    # mode is actually _active_.
    STATE=enabled
    if [ "$ENABLE_LAPTOP_MODE_ON_BATTERY" -eq 0 -a "$ENABLE_LAPTOP_MODE_ON_AC" -eq 0 -a "$ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED" -eq 0 ] ; then
    STATE=disabled
    fi
    # Determine the power state.
    # First try /sys/class/power_supply/*
    FOUND_SYS_CLASS_POWER_SUPPLY_AC=0
    ON_AC=0
    for POWER_SUPPLY in /sys/class/power_supply/* ; do
    if [ -f $POWER_SUPPLY/type ] ; then
    if [ "$(cat $POWER_SUPPLY/type)" = "Mains" ] ;then
    log "VERBOSE" "Determining power state from $POWER_SUPPLY/online."
    FOUND_SYS_CLASS_POWER_SUPPLY_AC=1
    if [ "$(cat $POWER_SUPPLY/online)" = 1 ] ; then
    ON_AC=1
    fi
    fi
    fi
    done
    if [ $FOUND_SYS_CLASS_POWER_SUPPLY_AC = 1 ] ; then
    # Already found it!
    log "VERBOSE" "Not trying other options, already found a power supply."
    elif [ -d /proc/acpi/ac_adapter ] ; then
    log "VERBOSE" "Determining power state from /proc/acpi/ac_adapter."
    ADAPTERS_FOUND=0
    ON_AC=0
    for ADAPTER in /proc/acpi/ac_adapter/* ; do
    if [ -f $ADAPTER/state ] ; then
    ADAPTERS_FOUND=1
    STATUS=`awk '/^state: / { print $2 }' $ADAPTER/state`
    if [ "$STATUS" = "on-line" ] ; then
    ON_AC=1
    fi
    fi
    done
    if [ "$ADAPTERS_FOUND" -eq 0 ] ; then
    ON_AC=1
    fi
    elif [ -f /proc/pmu/info ] ; then
    log "VERBOSE" "Determining power state from /proc/pmu/info."
    if ( grep -q "^AC Power.*0$" /proc/pmu/info ) ; then
    log "VERBOSE" "/proc/pmu/info indicates absence of AC power."
    ON_AC=0
    else
    # It is possible that there is no AC Power = 1 in the file,
    # but we always assume AC power when we're not sure.
    ON_AC=1
    log "VERBOSE" "/proc/pmu/info indicates presence of AC power."
    fi
    elif [ -f /proc/apm ] ; then
    log "VERBOSE" "Determining power state from /proc/apm."
    read D1 D2 D3 APM_AC_STATE D0 </proc/apm
    if [ "$APM_AC_STATE" = "0x00" ] ; then
    ON_AC=0
    else
    ON_AC=1
    fi
    else
    log "VERBOSE" "No /sys/class/power_supply, ACPI, APM or PMU power management information found -- assuming AC power is present."
    ON_AC=1
    fi
    # Determine whether to activate or deactivate laptop mode.
    ACTIVATE=0
    if [ "$ON_AC" -eq 1 ] ; then
    if [ "$ENABLE_LAPTOP_MODE_ON_AC" -ne 0 ] ; then
    log "VERBOSE" "On AC power: Activating, because ENABLE_LAPTOP_MODE_ON_AC is set."
    ACTIVATE=1
    else
    log "VERBOSE" "On AC power: Deactivating, because ENABLE_LAPTOP_MODE_ON_AC is not set."
    ACTIVATE=0
    fi
    else
    if [ "$ENABLE_LAPTOP_MODE_ON_BATTERY" -ne 0 ] ; then
    log "VERBOSE" "On battery power: Activating, because ENABLE_LAPTOP_MODE_ON_BATTERY is set."
    ACTIVATE=1
    else
    log "VERBOSE" "On battery power: Deactivating, because ENABLE_LAPTOP_MODE_ON_BATTERY is not set."
    ACTIVATE=0
    fi
    fi
    if [ "$ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED" -ne 0 -a "$ACTIVATE" -eq 0 ] ; then
    if [ -x "`which hal-find-by-property`" ] ; then
    HAL_LID_BUTTON=$(hal-find-by-property --key "button.type" --string "lid")
    fi
    if [ "$HAL_LID_BUTTON" != "" ] ; then
    HAL_LID_BUTTON_STATE=$(hal-get-property --udi $(hal-find-by-property --key "button.type" --string "lid") --key "button.state.value")
    if [ "$HAL_LID_BUTTON_STATE" = "true" ] ; then
    log "VERBOSE" "Setting action to \"start\" because the lid is closed (says HAL)."
    ACTIVATE=1
    fi
    elif [ -f /proc/acpi/button/lid/*/state ] ; then
    if ( grep -q "closed" /proc/acpi/button/lid/*/state ) ; then
    log "VERBOSE" 'Setting action to "start" because the lid is closed (says /proc/acpi/button/lid/*/state).'
    ACTIVATE=1
    fi
    else
    log "MSG" "Warning: ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED is set, but there is no file"
    log "MSG" "/proc/acpi/button/lid/.../state, and hal information is not available either!"
    fi
    fi
    # If the init script has not been run or has been run with the "stop"
    # argument, then we should never start laptop mode.
    if [ ! -f /var/run/laptop-mode-tools/enabled ] ; then
    log "VERBOSE" "Laptop mode disabled because /var/run/laptop-mode-tools/enabled is missing."
    STATE=disabled
    fi
    if [ "$ACTIVATE" -eq 1 -a -f /etc/default/laptop-mode ] ; then
    . /etc/default/laptop-mode
    if ! ( echo "$ENABLE_LAPTOP_MODE" |grep y ) ; then
    log "VERBOSE" "Not starting laptop mode because it is disabled in /etc/default/laptop-mode."
    STATE=disabled
    fi
    fi
    if [ "$STATE" = "disabled" ] ; then
    ACTIVATE=0
    fi
    # Check whether we are allowed to activate the data-loss-sensitive stuff.
    # If the battery charge is too low, we want to disable this, but not the
    # other power-saving stuff.
    if [ "$ACTIVATE" -eq 0 ] ; then
    ACTIVATE_WITH_POSSIBLE_DATA_LOSS=0
    elif [ "$ON_AC" = 1 ] ; then
    log "VERBOSE" "On AC, not checking minimum battery charge."
    ACTIVATE_WITH_POSSIBLE_DATA_LOSS=1
    else
    ACTIVATE_WITH_POSSIBLE_DATA_LOSS=1
    ENOUGH_CHARGE=0
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=0
    # Weird way of checking that /sys/class/power_supply is not empty -- but it works.
    if [ "$(echo /sys/class/power_supply/*)" != '/sys/class/power_supply/*' ] ; then
    log "VERBOSE" "Not on AC and we have battery information in /sys/class/power_supply/BAT* -- checking minimum battery charge."
    for BATT in /sys/class/power_supply/* ; do
    BATT_TYPE=$(cat $BATT/type)
    log "VERBOSE" "$BATT is of type $BATT_TYPE."
    if [ "$BATT_TYPE" != "Battery" ] ; then
    log "VERBOSE" "Not of type \"Battery\", skipping."
    else
    PREV_ENOUGH_CHARGE=$ENOUGH_CHARGE
    PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$ENOUGH_CHARGE_TO_PREVENT_HIBERNATION
    log "VERBOSE" "Checking levels for $BATT."
    PRESENT=$(cat $BATT/present)
    log "VERBOSE" "Present: $PRESENT."
    # Only do if the battery is present
    if [ "$PRESENT" -eq 1 ] ; then
    FOUND_AN_ENABLED_CHECK=0
    FOUND_AN_ENABLED_HIBERNATION_CHECK=0
    # Get the remaining capacity.
    IN_UAH=0
    IN_UWH=0
    if [ -f $BATT/charge_now ] ; then
    REMAINING=$(cat $BATT/charge_now)
    IN_UAH=1 # charge_* is in microAmpere-hours
    elif [ -f $BATT/energy_now ] ; then
    REMAINING=$(cat $BATT/energy_now)
    IN_UWH=1 # energy_* is in microWatt-hours
    else
    REMAINING=0
    fi
    if [ -z "$REMAINING" -o "$REMAINING" -eq 0 ] ; then
    log "VERBOSE" "Battery does not report remaining charge. Perhaps it is not present?"
    REMAINING=0
    fi
    log "VERBOSE" "Remaining charge: $REMAINING"
    if [ -f $BATT/charge_full_design ] ; then
    CAPACITY=$(cat $BATT/charge_full_design)
    elif [ -f $BATT/energy_full_design ] ; then
    CAPACITY=$(cat $BATT/energy_full_design)
    else
    CAPACITY=0
    fi
    if [ -z "$CAPACITY" -o "$CAPACITY" -eq 0 ] ; then
    log "VERBOSE" "Battery does not report design full charge, using non-design full charge."
    if [ -f $BATT/charge_full ] ; then
    CAPACITY=$(cat $BATT/charge_full)
    elif [ -f $BATT/energy_full_design ] ; then
    CAPACITY=$(cat $BATT/energy_full)
    else
    CAPACITY=0
    fi
    if [ -z "$CAPACITY" -o "$CAPACITY" -eq 0 ] ; then
    log "VERBOSE" "Battery does not report non-design full charge."
    CAPACITY=0
    fi
    fi
    log "VERBOSE" "Full capacity: $CAPACITY"
    # Check the charge percentage
    if [ "$MINIMUM_BATTERY_CHARGE_PERCENT" -ne 0 ] ; then
    FOUND_AN_ENABLED_CHECK=1
    if [ "$CAPACITY" -eq 0 ] ; then
    log "MSG" "WARNING: Battery does not report a capacity. Minimum battery"
    log "MSG" "charge checking does not work without a design capacity."
    ENOUGH_CHARGE=1
    elif [ "$(($REMAINING * 100 / $CAPACITY))" -ge "$MINIMUM_BATTERY_CHARGE_PERCENT" ] ; then
    ENOUGH_CHARGE=1
    fi
    fi
    if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" -ne 0 ] ; then
    FOUND_AN_ENABLED_HIBERNATION_CHECK=1
    if [ "$CAPACITY" -eq 0 ] ; then
    log "MSG" "WARNING: Battery does not report a design capacity. Auto hibernation"
    log "MSG" "does not work without a design capacity."
    ENOUGH_CHARGE=1
    elif [ "$(($REMAINING * 100 / $CAPACITY))" -ge "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    fi
    fi
    # $BATT/alarm is the design_capacity_warning of a battery.
    ALARM_LEVEL=$(cat $BATT/alarm)
    if [ "$ALARM_LEVEL" -ne 0 ] ; then
    if [ "$REMAINING" -le "$ALARM_LEVEL" ] ; then
    # Restore the state we had before checking this battery, so that
    # this battery does not count as having enough charge.
    ENOUGH_CHARGE=$PREV_ENOUGH_CHARGE
    elif [ "$FOUND_AN_ENABLED_CHECK" -eq 0 ] ; then
    # This is the only check that is enabled. In that case a non-critical
    # battery level counts as "enough". (If we would count non-critical
    # battery levels as enough *always*, then the other settings would
    # have no effect; this is only a final fallback.)
    ENOUGH_CHARGE=1
    fi
    fi
    if [ "$AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL" -ne 0 ] ; then
    if [ "$REMAINING" -le "$ALARM_LEVEL" ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION
    elif [ "$FOUND_AN_ENABLED_HIBERNATION_CHECK" -eq 0 ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    fi
    fi
    # Fallback: hard values
    if [ "$IN_UAH" -ne 0 ] ; then
    if [ "$MINIMUM_BATTERY_CHARGE_MAH" -ne 0 ] ; then
    FOUND_AN_ENABLED_CHECK=1
    if [ "$REMAINING" -ge $((1000*"$MINIMUM_BATTERY_CHARGE_MAH")) ] ; then
    ENOUGH_CHARGE=1
    fi
    fi
    if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_MAH" -ne 0 ] ; then
    FOUND_AN_ENABLED_HIBERNATION_CHECK=1
    if [ "$REMAINING" -ge $((1000*"$AUTO_HIBERNATION_BATTERY_CHARGE_MAH")) ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    fi
    fi
    elif [ "$IN_UWH" -ne 0 ] ; then
    if [ "$MINIMUM_BATTERY_CHARGE_MWH" -ne 0 ] ; then
    FOUND_AN_ENABLED_CHECK=1
    if [ "$REMAINING" -ge $((1000*"$MINIMUM_BATTERY_CHARGE_MWH")) ] ; then
    ENOUGH_CHARGE=1
    fi
    fi
    if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_MWH" -ne 0 ] ; then
    FOUND_AN_ENABLED_HIBERNATION_CHECK=1
    if [ "$REMAINING" -ge $((1000*"$AUTO_HIBERNATION_BATTERY_CHARGE_MWH")) ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    fi
    fi
    else
    log "ERR" "Failed to determine battery charge. Battery charge units are not in"
    log "ERR" "mWh, uWh, mAh or uAh."
    fi
    else
    log "VERBOSE" "Battery is not present."
    fi
    fi
    done
    elif [ "$(echo /proc/acpi/battery/*)" != '/proc/acpi/battery/*' ] ; then
    log "VERBOSE" "Not on AC and we have batteries in /proc/acpi/battery -- checking minimum battery charge."
    for BATT in /proc/acpi/battery/* ; do
    PREV_ENOUGH_CHARGE=$ENOUGH_CHARGE
    PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$ENOUGH_CHARGE_TO_PREVENT_HIBERNATION
    BATT_STATE=$BATT/state
    BATT_INFO=$BATT/info
    log "VERBOSE" "Checking info and state for $BATT."
    # Only do if the battery is present
    if ( grep -q 'present:.*yes' $BATT_INFO ) ; then
    FOUND_AN_ENABLED_CHECK=0
    FOUND_AN_ENABLED_HIBERNATION_CHECK=0
    # Get the remaining capacity.
    REMAINING=`grep "remaining capacity:" $BATT_STATE | sed "s/.* \([0-9][0-9]* \).*/\1/" `
    if [ -z "$REMAINING" ] ; then
    log "VERBOSE" "Battery does not report remaining charte. Perhaps it is not present?"
    REMAINING=0
    fi
    log "VERBOSE" "Remaining charge: $REMAINING"
    CAPACITY=`grep "design capacity:" $BATT_INFO | sed "s/.* \([0-9][0-9]* \).*/\1/" `
    if [ -z "$CAPACITY" ] ; then
    log "VERBOSE" "Battery does not report capacity. Perhaps it is not present?"
    CAPACITY=0
    fi
    log "VERBOSE" "Design capacity: $CAPACITY"
    # Check the charge percentage
    if [ "$MINIMUM_BATTERY_CHARGE_PERCENT" -ne 0 ] ; then
    FOUND_AN_ENABLED_CHECK=1
    if [ "$CAPACITY" -eq 0 ] ; then
    log "MSG" "WARNING: Battery does not report a design capacity. Minimum battery"
    log "MSG" "charge checking does not work without a design capacity."
    ENOUGH_CHARGE=1
    elif [ "$(($REMAINING * 100 / $CAPACITY))" -ge "$MINIMUM_BATTERY_CHARGE_PERCENT" ] ; then
    ENOUGH_CHARGE=1
    fi
    fi
    if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" -ne 0 ] ; then
    FOUND_AN_ENABLED_HIBERNATION_CHECK=1
    if [ "$CAPACITY" -eq 0 ] ; then
    log "MSG" "WARNING: Battery does not report a design capacity. Auto hibernation"
    log "MSG" "does not work without a design capacity."
    ENOUGH_CHARGE=1
    elif [ "$(($REMAINING * 100 / $CAPACITY))" -ge "$AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT" ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    fi
    fi
    # Fallback: hard values.
    # Determine the reporting unit.
    IN_MAH=0
    IN_MWH=0
    if ( grep -q mWh $BATT_INFO ) ; then
    IN_MWH=1
    elif ( grep -q mAh $BATT_INFO ) ; then
    IN_MAH=1
    fi
    if [ "$IN_MAH" -ne 0 ] ; then
    if [ "$MINIMUM_BATTERY_CHARGE_MAH" -ne 0 ] ; then
    FOUND_AN_ENABLED_CHECK=1
    if [ "$REMAINING" -ge "$MINIMUM_BATTERY_CHARGE_MAH" ] ; then
    ENOUGH_CHARGE=1
    fi
    fi
    if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_MAH" -ne 0 ] ; then
    FOUND_AN_ENABLED_HIBERNATION_CHECK=1
    if [ "$REMAINING" -ge "$AUTO_HIBERNATION_BATTERY_CHARGE_MAH" ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    fi
    fi
    elif [ "$IN_MWH" -ne 0 ] ; then
    if [ "$MINIMUM_BATTERY_CHARGE_MWH" -ne 0 ] ; then
    FOUND_AN_ENABLED_CHECK=1
    if [ "$REMAINING" -ge "$MINIMUM_BATTERY_CHARGE_MWH" ] ; then
    ENOUGH_CHARGE=1
    fi
    fi
    if [ "$AUTO_HIBERNATION_BATTERY_CHARGE_MWH" -ne 0 ] ; then
    FOUND_AN_ENABLED_HIBERNATION_CHECK=1
    if [ "$REMAINING" -ge "$AUTO_HIBERNATION_BATTERY_CHARGE_MWH" ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    fi
    fi
    else
    log "ERR" "Failed to determine battery charge. Battery charge units are not in"
    log "ERR" "mWh or mAh."
    fi
    CAP_STATE=`sed -r 's/^capacity state:\s*(.*)\s*$/\1/;t;d' "$BATT_STATE"`
    if [ "$DISABLE_LAPTOP_MODE_ON_CRITICAL_BATTERY_LEVEL" -ne 0 ] ; then
    if [ "$CAP_STATE" = "critical" ] ; then
    # Restore the state we had before checking this battery, so that
    # this battery does not count as having enough charge.
    ENOUGH_CHARGE=$PREV_ENOUGH_CHARGE
    elif [ "$FOUND_AN_ENABLED_CHECK" -eq 0 ] ; then
    # This is the only check that is enabled. In that case a non-critical
    # battery level counts as "enough". (If we would count non-critical
    # battery levels as enough *always*, then the other settings would
    # have no effect; this is only a final fallback.)
    ENOUGH_CHARGE=1
    fi
    fi
    if [ "$AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL" -ne 0 ] ; then
    if [ "$CAP_STATE" = "critical" ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=$PREV_ENOUGH_CHARGE_TO_PREVENT_HIBERNATION
    elif [ "$FOUND_AN_ENABLED_HIBERNATION_CHECK" -eq 0 ] ; then
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    fi
    fi
    else
    log "VERBOSE" "Battery is not present."
    fi
    done
    else
    ENOUGH_CHARGE=1
    ENOUGH_CHARGE_TO_PREVENT_HIBERNATION=1
    log "VERBOSE" "Not on AC and could not check battery state -- data loss sensitive features stay enabled and auto-hibernation will not work."
    fi
    if [ "$ENABLE_AUTO_HIBERNATION" -ne 0 -a "$ENOUGH_CHARGE_TO_PREVENT_HIBERNATION" -eq 0 ] ; then
    log "VERBOSE" "None of the batteries have a charge above the auto-hibernation level."
    log "VERBOSE" "Starting hibernation."
    if [ -x $HIBERNATE_COMMAND ]; then
    $HIBERNATE_COMMAND
    elif [ -f /sys/power/state ]; then
    grep -q disk /sys/power/state && echo disk > /sys/power/state
    fi
    # Don't continue -- if things are configured correctly, then we
    # will be called on resume.
    exit 0
    fi
    if [ "$ENOUGH_CHARGE" -eq 0 ] ; then
    log "VERBOSE" "None of the batteries have a charge above the minimum level."
    log "VERBOSE" "Deactivating data loss sensitive features."
    ACTIVATE_WITH_POSSIBLE_DATA_LOSS=0
    fi
    fi
    if [ "$INIT" -eq 0 ] ; then
    log "MSG" "Laptop mode "
    fi
    # WAS_ACTIVE is used later on. If there is no /var/run/laptop-mode-tools/state, then
    # we know that laptop mode wasn't active before.
    WAS_ACTIVE=0
    log "VERBOSE" "Checking if desired state is different from current state."
    if [ -f /var/run/laptop-mode-tools/state ] ; then
    read WAS_ACTIVE WAS_ON_AC WAS_ACTIVATE_WITH_POSSIBLE_DATA_LOSS WAS_STATE < /var/run/laptop-mode-tools/state
    if [ "$WAS_STATE" != "" ] ; then
    if [ "$WAS_ACTIVE" -eq "$ACTIVATE" -a "$WAS_ON_AC" -eq "$ON_AC" -a "$WAS_ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -eq "$ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -a "$WAS_STATE" = "$STATE" -a "$FORCE" -eq 0 ] ; then
    log "MSG" "$STATE, "
    if [ "$WAS_ACTIVE" -eq 1 ] ; then
    log "MSG" "active [unchanged]"
    if [ "$ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -eq 0 ] ; then
    log "MSG" " (Data-loss sensitive features disabled.)"
    fi
    else
    log "MSG" "not active [unchanged]"
    fi
    exit 0
    fi
    fi
    else
    log "VERBOSE" "/var/run/laptop-mode-tools/state does not exist, no previous state."
    fi
    echo "$ACTIVATE $ON_AC $ACTIVATE_WITH_POSSIBLE_DATA_LOSS $STATE" > /var/run/laptop-mode-tools/state
    if [ "$ACTIVATE" -eq 1 ] ; then
    log "MSG" "$STATE, active"
    if [ "$ACTIVATE_WITH_POSSIBLE_DATA_LOSS" -eq 0 ] ; then
    log "MSG" " (Data-loss sensitive features disabled.)"
    fi
    else
    log "MSG" "$STATE, not active"
    fi
    # Finally, call laptop-mode-tools modules. The modules can use the settings
    # from the config files, but they may NOT assume the settings actually exist,
    # as no defaults have been given for them.
    # Note that the /usr/local/lib path is deprecated.
    export FORCE STATE ON_AC ACTIVATE ACTIVATE_WITH_POSSIBLE_DATA_LOSS KLEVEL KMINOR WAS_ACTIVE LM_VERBOSE DEVICES
    for SCRIPT in /usr/share/laptop-mode-tools/modules/* /usr/local/lib/laptop-mode-tools/modules/* /usr/local/share/laptop-mode-tools/modules/* /etc/laptop-mode/modules/* ; do
    if [ -z "$MODULES" ] ; then
    # If a module list has not been provided, execute all modules
    EXECUTE_SCRIPT=1
    else
    # If a module list has been provided, execute only the listed
    # modules.
    EXECUTE_SCRIPT=0
    for MODULE in $MODULES; do
    # Attempt to remove the module name from the end of the
    # full script path. If the module name matches the
    # script, the name will be removed from the end of the
    # full file path, leaving the path to the script. If
    # there was not a match made, the module name would not
    # be removed from the path, and $PATH_TO_SCRIPT would
    # be the same as $SCRIPT.
    PATH_TO_SCRIPT=${SCRIPT%%$MODULE}
    # Execute the script if a match was found (module name
    # was removed from the script path, making it shorter.
    if [ $PATH_TO_SCRIPT != $SCRIPT ] ; then
    EXECUTE_SCRIPT=1
    fi
    done
    fi
    if [ -x "$SCRIPT" -a $EXECUTE_SCRIPT -eq 1 ] ; then
    log "VERBOSE" "Invoking module $SCRIPT."
    SCRIPT_DEBUG=$SCRIPT; # We do this because in start-stop-programs module a $SCRIPT variable is used. That
    # changes the whole meaning when passed to disableDebug ()
    enableDebug $SCRIPT_DEBUG;
    . $SCRIPT
    disableDebug $SCRIPT_DEBUG;
    else
    log "VERBOSE" "Module $SCRIPT is not executable or is to be skipped."
    fi
    done
    exit 0
    # This fi closes the if for "readconfig". If I would have indented this one
    # I would have indented the whole file. :)
    fi
    lmt_load_config
    lock_retry ()
    ( $FLOCK -n -x -w 1 8 || exit 0;
    i=10;
    while [ $i -ge 1 ]
    do
    log "ERR" "Couldn't acquire lock. Retrying.... PID is $$\n"
    $FLOCK -x -w 1 9 && lmt_main_function "$@" && break;
    i=$(( $i - 1 ))
    done
    ) 8>$LMT_REQ_LOCK
    # Check and acquire locks and then exec.
    ( $FLOCK -n -x -w 1 8; ) 8>$LMT_REQ_LOCK
    ($FLOCK -n -x -w 1 9 && lmt_main_function "$@";) || lock_retry "$@"
    ) 9<>$LMT_INVOC_LOCK
    # We do a special run of battery polling daemon here so that it does not get
    # plagued by the lock. We need the polling daemon to be independent of any locks
    if [ x$ENABLE_BATTERY_LEVEL_POLLING = x1 ] && [ x$BLACKLIST_IN_FLOCK = x1 ]; then
    log "VERBOSE" "Battery level polling is enabled."
    if [ x$ON_AC = x1 ] ; then
    log "VERBOSE" "On AC, stopping the polling daemon."
    # In AC mode we disable the polling daemon.
    killall -q lm-polling-daemon
    else
    if ! pidof -x lm-polling-daemon ; then
    log "VERBOSE" "On battery and there was no polling daemon yet, starting the polling daemon."
    # If there is no polling daemon, we start one.
    /usr/share/laptop-mode-tools/module-helpers/lm-polling-daemon < /dev/null > /dev/null 2> /dev/null &
    fi
    fi
    else
    log "VERBOSE" "Battery level polling is disabled."
    fi
    exit 0;
    and here is the lines which archwiki mentions
    case "$KLEVEL" in
    "2.4" ) ;;
    "2.6" ) ;;
    log "ERR" "Unhandled kernel version: $KLEVEL ('uname -r' = '$(uname -r)')" >&2
    exit 1
    esac

    I had the problem but edited the line in /usr/sbin/laptop_mode and it worked. But thoes lines are not there anymore. I guess they changed it at the recent update of laptop-mode-tools.
    Regarding your heat problem; is there any other thing you use to cut down power usage (from AUR  maybe)? I use acpi_call from AUR had to edit lines there aswell, but it should be updated by now.

  • Disk still wakes up with laptop-mode-tools

    Hi all,
    I have a Thinkpad x61 and I'm trying to manage power use with laptop-mode-tools, but I'm having trouble with the harddrive waking up too much. I have it configured so that lm-tools activates when the power is disconnected, and sure enough, a few seconds later the harddrive spins down. But 1-2 seconds later it spins back up! iotop indicates that dhcpcd is writing to the drive, and thus waking it up.
    I thought lm-tools was set so that I could "potentially lose up to 10 minutes of work." Shouldn't that mean that up to 10 minutes of writes get buffered in ram instead of waking up the harddrive? If I disable the network, dhcpcd stops waking things up, but if I save a buffer from emacs, the harddrive instantly wakes up, so it looks like there's no buffering going on...
    Here are some relevant settings while in laptop-mode:
    $ dmesg|tail
    [15425.800826] EXT4-fs (sda1): re-mounted. Opts: data=ordered,commit=600
    [15425.982220] EXT4-fs (sda2): re-mounted. Opts: data=ordered,commit=600
    $ cat /proc/sys/vm/dirty_writeback_centisecs
    60000
    $ cat /proc/sys/vm/dirty_expire_centisecs
    60000
    $ cat /proc/sys/vm/dirty_bytes
    0
    $ cat /proc/sys/vm/dirty_background_bytes
    0
    $ cat /proc/sys/vm/dirty_background_ratio
    1
    It looks like dirty_writeback is getting set to 10 minutes and the journal commit rate is also set to 10 minutes. Should dirty_background_bytes and dirty_bytes be nonzero?
    Here are some relevant lines from /etc/laptop-mode/laptop-mode.conf:
    LM_BATT_MAX_LOST_WORK_SECONDS=600
    CONTROL_READAHEAD=1
    LM_READAHEAD=3072
    CONTROL_NOATIME=0
    USE_RELATIME=1
    CONTROL_HD_IDLE_TIMEOUT=1
    LM_BATT_HD_IDLE_TIMEOUT_SECONDS=10
    BATT_HD_POWERMGMT=1
    CONTROL_HD_WRITECACHE=1
    NOLM_AC_HD_WRITECACHE=1
    NOLM_BATT_HD_WRITECACHE=0
    LM_HD_WRITECACHE=0
    Any ideas what I'm missing?
    Thanks in advance for any suggestions!

    kaczoanoker wrote:I noticed that vim and emacs wake up the HD in laptop mode, but something like "dd if=/dev/zero of=~/test bs=1M count=1" doesn't. Does it mean that editors typically force-flush the buffers, which defeats the point of laptop-mode?
    Vim calls fsync(2) when writing files and swap files per default. One can control this behavior with the fsync and swapsync options.
    I don't know if Emacs has similar options.

  • Trouble with Laptop-Mode-Tools, AC Plug-In

    I can't get Laptop-Mode-Tools to recognize when I plug my AC in, I have options for "AC_" as it says are allowed in the man page and ArchWiki, although there are no examples of just having the prefix "AC_".
    However, it says it should behave in the same way as "BATT_" does, independant of the laptop-mode status.
    I have LM enabled for AC in laptop-mode.conf, and acpi_listen has output for the AC in/out.   My current workaround is to have it as it is, with "LM_AC_*", but having entries for exclusively battery and AC is easier for me as I plan to always keep Laptop-Mode-Tools enabled.
    Is there something I misconfigured, or may I have misunderstood the manual/wiki?
    Alternatively, how would I go about debugging? I noticed there was a variable enabling debugging, but I couldn't find where the debugging output occurs.  I am a little new with regards to standard debugging practice.
    Last edited by mellowmaroon (2012-10-03 06:23:05)

    I'm terribly sorry, I fixed everything I had made bold.  I was trying to make the technical things stand out for people that were just glancing at the post. But you're absolutely right, I should have used more discretion.
    As for the configuration, I did not expect it to magically do what I want.  I will provide a more concrete example of what I am talking about, if it helps.
    In /etc/laptop-mode/conf.d/lcd-brightness.conf, I have BATT_BRIGHTNESS_COMMAND="echo 0".  This works: when I unplug AC, 0 gets output to /sys/class/backlight/acpi_video0/brightness.
    However, when I attempt AC_BRIGHTNESS_COMMAND="echo 15" (less than /sys/class/backlight/acpi_video0/max_brightness, hopefully demonstrating my reading of laptop-mode.conf), it is unsuccessful.  Instead, I currently use LM_AC_BRIGHTNESS_COMMAND="echo 15" as a workaround.  BATT_BRIGHTNESS_COMMAND works without editing /etc/acpid/handler.sh, I was simply wondering why the AC counterpart does not.
    I hope I have now supplied enough information now allows us to be on the same page, and I apologize again for the offensive formatting.

  • I Need advise with laptop-mode-tools

    Hello,
    I installed the laptop-mode-tools to control my external harddrive. I followed closely the wiki and I managed to configure the
    /etc/laptop-mode/conf.d/usb-autosuspend.conf
    exactly, it is explained in the wiki.
    It works (kind of) but I don't know this is the right behaviour. It powers off my external harddrive, but after a while it powers it on again even if I don't touch the external harddrive. I thought when once the harddrive powered off it remains so until I use it.
    Is this the proper behavior of the laptop-mode-tools program?
    These are my configuration settings (Exactly the same suggested in the wiki).
    DEBUG=0
    CONTROL_USB_AUTOSUSPEND=1
    BATT_SUSPEND_USB=1
    LM_AC_SUSPEND_USB=1
    NOLM_AC_SUSPEND_USB=0
    AUTOSUSPEND_TIMEOUT=2
    Thanks,
    jmak

    Some DE have index services (e.g. gnome) in the background. Maybe it is one of those which wakes it up again. To check you can install something like "iotop" and have a look at the processes when the drive gets woken up.
    Another avenue is that the drive itself has powermanagement options to be set additionally. You can check on them with hdparm.

  • TuxonIce and laptop-mode?

    I've got the tuxonice-patched kernel running on my laptop. Been using it without any problem for hibernate and restart. Just today, my system was running slowly and it turned out my processor was stuck in powersave mode (0.8 GHz on a 2.4GHz machine), so since I was in a rush, I did `echo performance > /sys/devices/system/cpu/cpu0/scaling_governer` (excuse any typos).
    Thing is, I believe this happened because I hibernated while in powersave (not plugged in) and started my laptop plugged in. Does anyone know whether this is how its supposed to behave, and what I can do so that laptop-mode sets the governers properly however I hibernate and start up. Probably some services I need to restart?

    cant help you there as i dont use it, but heres the relevant part in pm-utils:
    #!/bin/sh
    # 99laptop-mode: Re-apply laptop mode tools settings
    if [ -f /etc/pm/sleep.d/99laptop-mode ]; then
    continue
    else
    case "$1" in
    hibernate|suspend)
    # Stopping is not required.
    thaw|resume)
    # Make laptop mode tools forcibly re-apply the hardware settings
    # that laptop mode tools applies.
    if [ -e /usr/sbin/laptop_mode ] ; then
    /usr/sbin/laptop_mode auto force
    fi
    *) exit $NA
    esac
    fi
    have you tried troubleshooting with pm-utils?

  • Slow Boot Times after installing new SSD and Lion

    Can anyone please help interpret why I'm having slow boot times?  I have copied my console printout during the boot and it seems to be doing a repetitive action while booting.
    Thanks
    13-01-04 2:50:24.000 AM bootlog: BOOT_TIME 1357293024 0
    13-01-04 2:50:25.000 AM kernel: Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64
    13-01-04 2:50:25.000 AM kernel: vm_page_bootstrap: 942160 free pages and 32688 wired pages
    13-01-04 2:50:25.000 AM kernel: kext submap [0xffffff7f80736000 - 0xffffff8000000000], kernel text [0xffffff8000200000 - 0xffffff8000736000]
    13-01-04 2:50:25.000 AM kernel: zone leak detection enabled
    13-01-04 2:50:25.000 AM kernel: standard timeslicing quantum is 10000 us
    13-01-04 2:50:25.000 AM kernel: mig_table_max_displ = 73
    13-01-04 2:50:25.000 AM kernel: AppleACPICPU: ProcessorId=0 LocalApicId=0 Enabled
    13-01-04 2:50:25.000 AM kernel: AppleACPICPU: ProcessorId=1 LocalApicId=1 Enabled
    13-01-04 2:50:25.000 AM kernel: calling mpo_policy_init for TMSafetyNet
    13-01-04 2:50:25.000 AM kernel: Security policy loaded: Safety net for Time Machine (TMSafetyNet)
    13-01-04 2:50:25.000 AM kernel: calling mpo_policy_init for Sandbox
    13-01-04 2:50:25.000 AM kernel: Security policy loaded: Seatbelt sandbox policy (Sandbox)
    13-01-04 2:50:25.000 AM kernel: calling mpo_policy_init for Quarantine
    13-01-04 2:50:25.000 AM kernel: Security policy loaded: Quarantine policy (Quarantine)
    13-01-04 2:50:25.000 AM kernel: Copyright (c) 1982, 1986, 1989, 1991, 1993
    13-01-04 2:50:25.000 AM kernel: The Regents of the University of California. All rights reserved.
    13-01-04 2:50:25.000 AM kernel: MAC Framework successfully initialized
    13-01-04 2:50:25.000 AM kernel: using 16384 buffer headers and 10240 cluster IO buffer headers
    13-01-04 2:50:25.000 AM kernel: IOAPIC: Version 0x11 Vectors 64:87
    13-01-04 2:50:25.000 AM kernel: ACPI: System State [S0 S3 S4 S5]
    13-01-04 2:50:25.000 AM kernel: PFM64 (36 cpu) 0xf10000000, 0xf0000000
    13-01-04 2:50:25.000 AM kernel: [ PCI configuration begin ]
    13-01-04 2:50:25.000 AM kernel: console relocated to 0xf10010000
    13-01-04 2:50:25.000 AM kernel: PCI configuration changed (bridge=1 device=1 cardbus=0)
    13-01-04 2:50:25.000 AM kernel: [ PCI configuration end, bridges 5 devices 24 ]
    13-01-04 2:50:25.000 AM kernel: AppleIntelCPUPowerManagement: (built 16:32:09 Aug 23 2012) initialization complete
    13-01-04 2:50:25.000 AM kernel: mbinit: done [64 MB total pool size, (42/21) split]
    13-01-04 2:50:25.000 AM kernel: Pthread support ABORTS when sync kernel primitives misused
    13-01-04 2:50:25.000 AM kernel: TBIOBlockStorageDriver: super::probe failed
    13-01-04 2:50:25.000 AM kernel: TBIOBlockStorageDriver: super::probe failed
    13-01-04 2:50:25.000 AM kernel: com.apple.AppleFSCompressionTypeZlib kmod start
    13-01-04 2:50:25.000 AM kernel: com.apple.AppleFSCompressionTypeDataless kmod start
    13-01-04 2:50:25.000 AM kernel: com.apple.AppleFSCompressionTypeZlib load succeeded
    13-01-04 2:50:25.000 AM kernel: com.apple.AppleFSCompressionTypeDataless load succeeded
    13-01-04 2:50:25.000 AM kernel: AppleIntelCPUPowerManagementClient: ready
    13-01-04 2:50:25.000 AM kernel: BTCOEXIST off
    13-01-04 2:50:25.000 AM kernel: wl0: Broadcom BCM432b 802.11 Wireless Controller
    13-01-04 2:50:25.000 AM kernel: 5.106.198.19
    13-01-04 2:50:25.000 AM kernel: FireWire (OHCI) Lucent ID 5901 built-in now active, GUID e80688fffec0e9d0; max speed s800.
    13-01-04 2:50:25.000 AM kernel: USBMSC Identifier (non-unique): 000000009833 0x5ac 0x8403 0x9833
    13-01-04 2:50:25.000 AM kernel: com_seagate_IOPowSec00_10_5: GetVendorAndModelIDInfo failed
    13-01-04 2:50:25.000 AM kernel: com_maxtor_IOPowSec00_10_5: GetVendorAndModelIDInfo failed
    13-01-04 2:50:25.000 AM kernel: rooting via boot-uuid from /chosen: 1052015E-B101-3046-8932-5C6B1E6A7995
    13-01-04 2:50:25.000 AM kernel: Waiting on <dict ID="0"><key>IOProviderClass</key><string ID="1">IOResources</string><key>IOResourceMatch</key><string ID="2">boot-uuid-media</string></dict>
    13-01-04 2:50:25.000 AM kernel: Got boot device = IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SATA@A/AppleMCP89AHCI/PR T1@1/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice/IOBlockStorageD river/M4-CT256M4SSD2 Media/IOGUIDPartitionScheme/Imipenem (SSD)@2
    13-01-04 2:50:25.000 AM kernel: BSD root: disk0s2, major 14, minor 2
    13-01-04 2:50:25.000 AM kernel: Kernel is LP64
    13-01-04 2:50:25.000 AM kernel: [IOBluetoothHCIController::setConfigState] calling registerService
    13-01-04 2:50:25.133 AM com.apple.launchd: *** launchd[1] has started up. ***
    13-01-04 2:50:25.491 AM com.apple.launchd: (com.apple.powerd) Unknown value for key POSIXSpawnType: Interactive
    13-01-04 2:50:25.491 AM com.apple.launchd: (com.apple.sandboxd) Unknown value for key POSIXSpawnType: Interactive
    13-01-04 2:50:25.987 AM UserEventAgent: starting CaptiveNetworkSupport as SystemEventAgent built May 25 2011 12:27:35
    13-01-04 2:50:25.990 AM UserEventAgent: CaptiveNetworkSupport:CreateInterfaceWatchList:2788 WiFi Devices Found.
    13-01-04 2:50:25.991 AM UserEventAgent: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - PreProbe
    13-01-04 2:50:25.991 AM UserEventAgent: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order
    13-01-04 2:50:25.991 AM UserEventAgent: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order
    13-01-04 2:50:25.991 AM UserEventAgent: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - PreProbe
    13-01-04 2:50:25.992 AM UserEventAgent: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order
    13-01-04 2:50:25.992 AM UserEventAgent: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order
    13-01-04 2:50:26.000 AM kernel: BCM5701Enet: Ethernet address c4:2c:03:01:22:c1
    13-01-04 2:50:26.000 AM kernel: AirPort_Brcm4331: Ethernet address f8:1e:df:eb:b4:37
    13-01-04 2:50:26.000 AM kernel: IO80211Controller::dataLinkLayerAttachComplete():  adding AppleEFINVRAM notification
    13-01-04 2:50:26.000 AM kernel: IO80211Interface::efiNVRAMPublished(): 
    13-01-04 2:50:27.025 AM airportd: _processDLILEvent: en1 attached (down)
    13-01-04 2:50:27.274 AM com.apple.SecurityServer: Session 100000 created
    13-01-04 2:50:27.000 AM kernel: in func createVirtualInterface ifRole = 1
    13-01-04 2:50:27.000 AM kernel: Created virtif 0xffffff800bdffa00 p2p0
    13-01-04 2:50:27.349 AM UserEventAgent: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - PreProbe
    13-01-04 2:50:27.607 AM com.apple.SecurityServer: Entering service
    13-01-04 2:50:27.749 AM UserEventAgent: ServermgrdRegistration cannot load config data
    13-01-04 2:50:27.779 AM UserEventAgent: get_backup_share_points no AFP
    13-01-04 2:50:28.000 AM kernel: NVDANV50HAL loaded and registered.
    13-01-04 2:50:28.000 AM kernel: Previous Shutdown Cause: 5
    13-01-04 2:50:28.000 AM kernel: SMC::smcInitHelper ERROR: MMIO regMap == NULL - fall back to old SMC mode
    13-01-04 2:50:28.000 AM kernel: AirPort: Link Down on en1. Reason 8 (Disassociated because station leaving).
    13-01-04 2:50:28.332 AM com.apple.launchd: (com.sec.faxdb[73]) open("/Library/Logs/Samsung/MacFax/FaxDB.log", ...): No such file or directory
    13-01-04 2:50:28.333 AM com.apple.launchd: (com.sec.faxdb[73]) open("/Library/Logs/Samsung/MacFax/FaxDB.log", ...): No such file or directory
    13-01-04 2:50:28.347 AM com.apple.pfctl: No ALTQ support in kernel
    13-01-04 2:50:28.347 AM com.apple.pfctl: ALTQ related functions disabled
    13-01-04 2:50:28.363 AM com.apple.launchd: (com.sec.faxdb[73]) posix_spawn("/Library/Printers/Samsung/Fax/FaxDB/faxdbd", ...): No such file or directory
    13-01-04 2:50:28.385 AM com.apple.ucupdate.plist: ucupdate: Checked 1 update, no match found.
    13-01-04 2:50:28.385 AM com.apple.launchd: (com.sec.faxdb[73]) Exited with code: 1
    13-01-04 2:50:28.385 AM com.apple.launchd: (com.sec.faxdb) Throttling respawn: Will start in 300 seconds
    13-01-04 2:50:28.606 AM mDNSResponder: mDNSResponder mDNSResponder-320.16 (Jul 19 2012 21:07:07) starting OSXVers 11
    13-01-04 2:50:28.704 AM com.apple.revisiond: 2013-01-04 02:50 revisiond[52] (CarbonCore.framework) implementation_callback_rpc: ERROR: CFDictionaryGetValue(FSEvents_streamDict, cfPortNumber) => NULL
    13-01-04 2:50:28.705 AM com.apple.usbmuxd: usbmuxd-296.3 on Jul 25 2012 at 00:28:37, running 64 bit
    13-01-04 2:50:28.814 AM configd: bootp_session_transmit: bpf_write(en1) failed: Network is down (50)
    13-01-04 2:50:28.814 AM configd: DHCP en1: INIT-REBOOT transmit failed
    13-01-04 2:50:28.837 AM systemkeychain: done file: /var/run/systemkeychaincheck.done
    13-01-04 2:50:28.880 AM mds: (Normal) FMW: FMW 0 0
    13-01-04 2:50:28.938 AM mDNSResponder: D2D_IPC: Loaded
    13-01-04 2:50:28.938 AM mDNSResponder: D2DInitialize succeeded
    13-01-04 2:50:28.990 AM configd: setting hostname to "Karr-Hong-Lees-MacBook-Pro.local"
    13-01-04 2:50:29.000 AM kernel: SMC::smcReadKeyAction ERROR: smcReadData8 failed for key MOTP (kSMCKeyNotFound)
    13-01-04 2:50:29.000 AM kernel: DSMOS has arrived
    13-01-04 2:50:29.000 AM kernel: macx_swapon SUCCESS
    13-01-04 2:50:29.031 AM configd: network configuration changed.
    13-01-04 2:50:29.984 AM loginwindow: Login Window Application Started
    13-01-04 2:50:30.091 AM com.apple.launchd: (com.sec.faxdb) Throttling respawn: Will start in 299 seconds
    13-01-04 2:50:30.142 AM netbiosd: Unable to start NetBIOS name service:
    13-01-04 2:50:31.000 AM loginwindow: **DMPROXY** Found `/System/Library/CoreServices/DMProxy'.
    13-01-04 2:50:31.000 AM kernel: en1: 802.11d country code set to 'US'.
    13-01-04 2:50:31.000 AM kernel: en1: Supported channels 1 2 3 4 5 6 7 8 9 10 11 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140 149 153 157 161 165
    13-01-04 2:50:31.282 AM loginwindow:
    O3REQUIRE FAILED: ret == 0
       - file: /SourceCache/BezelServices/BezelServices-232.3/Utilities/Utilities.c
       - line: 91
    13-01-04 2:50:31.282 AM loginwindow: Failed to lookup Bezel UI Server port: Bootstrap Unknown Service.
    13-01-04 2:50:31.315 AM com.apple.SecurityServer: Session 100004 created
    13-01-04 2:50:31.317 AM loginwindow: Login Window Started Security Agent
    13-01-04 2:50:31.347 AM com.apple.launchctl.LoginWindow: com.apple.findmymacmessenger: Already loaded
    13-01-04 2:50:31.542 AM SecurityAgent: Echo enabled
    13-01-04 2:50:31.542 AM SecurityAgent: Echo enabled
    13-01-04 2:50:31.574 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:31.574 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:31.575 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 10)
    13-01-04 2:50:31.575 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 10)
    13-01-04 2:50:32.000 AM kernel: MacAuthEvent en1   Auth result for: a8:39:44:57:2c:50  MAC AUTH succeeded
    13-01-04 2:50:32.000 AM kernel: wlEvent: en1 en1 Link UP virtIf = 0
    13-01-04 2:50:32.000 AM kernel: AirPort: Link Up on en1
    13-01-04 2:50:32.000 AM kernel: en1: BSSID changed to a8:39:44:57:2c:50
    13-01-04 2:50:32.530 AM airportd: _doAutoJoin: Already associated to “TELUS3939”. Bailing on auto-join.
    13-01-04 2:50:33.000 AM kernel: AirPort: RSN handshake complete on en1
    13-01-04 2:50:34.579 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:34.579 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:34.579 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 9)
    13-01-04 2:50:34.579 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 9)
    13-01-04 2:50:35.093 AM configd: network configuration changed.
    13-01-04 2:50:35.113 AM UserEventAgent: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - Probe
    13-01-04 2:50:35.114 AM UserEventAgent: CaptiveNetworkSupport:CNSPreferences:60 Creating new preferences
    13-01-04 2:50:35.114 AM UserEventAgent: CaptiveNetworkSupport:CaptiveStartDetect:2343 Bypassing probe on TELUS3939 because it is protected and not on the exception list
    13-01-04 2:50:35.116 AM UserEventAgent: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - Unknown
    13-01-04 2:50:35.118 AM configd: network configuration changed.
    13-01-04 2:50:35.991 AM ntpd: proto: precision = 1.000 usec
    13-01-04 2:50:37.270 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:37.271 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:37.271 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 8)
    13-01-04 2:50:37.271 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 8)
    13-01-04 2:50:40.276 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:40.276 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:40.276 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 7)
    13-01-04 2:50:40.276 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 7)
    13-01-04 2:50:43.281 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:43.281 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:43.281 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 6)
    13-01-04 2:50:43.282 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 6)
    13-01-04 2:50:46.286 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:46.286 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:46.286 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 5)
    13-01-04 2:50:46.286 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 5)
    13-01-04 2:50:49.291 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:49.291 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:49.291 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 4)
    13-01-04 2:50:49.291 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 4)
    13-01-04 2:50:52.296 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:52.296 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:52.296 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 3)
    13-01-04 2:50:52.296 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 3)
    13-01-04 2:50:55.301 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:55.301 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:55.301 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 2)
    13-01-04 2:50:55.301 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 2)
    13-01-04 2:50:58.307 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:58.307 AM SecurityAgent: Could not get the user record from OpenDirectory.
    13-01-04 2:50:58.307 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 1)
    13-01-04 2:50:58.307 AM SecurityAgent: Will sleep 3 seconds and try again (retryCount = 1)

    Fixed it!
    Just changed my settings to auto log on.
    Hooray!

Maybe you are looking for

  • "Home" and "End" keys in FCP on MacBook Pro (2008/09)

    I just started using my new MacBook Pro 17. While I was in FCP and tried to move the playhead to the "Home" position, I realized that my keyboard doesn't have a "Home" or an "End" key. What keys/functions do I need to use in this case? When I tried t

  • JDBC--XI---ABAP Proxy

    Dear Experts, I have a scenario from DB system I am given a stored procedure that gives me the contents for creating sales orders in SAP ECC system. Now I have written a ABAP proxy code, internally I have used BAPI for sales order creation,  the sale

  • Error message when trying to save

    When I try and save a file in dreamweaver CS4 I get the error message: While executing onLoad in MF Auto Title_beforeSave.htm, the following Javascript error(s) occured: In file " MF Auto Title_beforeSave": beforeSave is not defined I then click on t

  • Automatic Shutdown Of Photoshop CS6

    When I try to print an image, Photshop completely shuts dow.  What is going on? Bruce

  • Filter TOP query so that a result cannot be in the top if the column value is already present in a previous row

    Hi, Any help would be appreciated. I have a query that is the top(5) but I want them to be distinct on only one column value, not on the entire row. Any help would be really appreciated. Regards,    Seamus