Comment 8 for bug 74394

Fixing hdparm parameter value and laptop-mode issue when switching power supply (AC/battery)

Bug feature : When plugging on and off the ac adapter the laptop-mode parameters are not taken into account.
- Even if the command "cat /proc/sys/vm/laptop_mode" give a correct value (2 or more) the hdparm parameter are not set in agreement with /etc/laptop-mode/laptop-mode.conf settings.

Consequence :
- the Load_Cycle_Count is not controled anymore by user settings (laptop-mode.conf)
- setting "ENABLE_LAPTOP_MODE = true" in "/etc/acpi/acpi-support" corresponds to a laptop mode controled by the script (during supply switching, the boot seems to be ok), not by laptop-mode-tools.
- the setting "ENABLE_LAPTOP_MODE_ON_AC=1" in "laptop-mode.conf" is not taken into account when switching AC/battery

Cause : The /etc/acpi/ script is called at each power event notification (acpi event).
The hdparm parameters are overwritten by this script, which doesn't reload laptop-mode.conf settings.

Solution : Modification of : the solution 2 is the more efficient, it works for me

solution 1 :
- set the good values of hdparm -S and -B in, without any other modification
BUT : the boot values seems to be always controled by laptop-mode.conf and ENABLE_LAPTOP_MODE_ON_AC=1" is not taken into account after switching.

solution 2 : see the first attachment
- "ENABLE_LAPTOP_MODE = true" call systematically laptop-mode : "/usr/sbin/laptop_mode auto"
- "ENABLE_LAPTOP_MODE = false" means laptop-mode on battery and no laptop-mode on AC with the hdparm parameters are controled by (it is OK for a laptop, but there is no way shutdown completely laptop mode)

solution 3 : not tested
If laptop-mode-tools are installed by default, the best solution could be to load laptop-mode.conf setting and to test ENABLE_LAPTOP_MODE_ON_BATTERY and ENABLE_LAPTOP_MODE_ON_AC in

thus, "ENABLE_LAPTOP_MODE=true" could recover it's real meaning (?) :

 - by default laptop-mode is disabled on AC, and enabled on battery, using default setting present in
 - if laptop-mode tools are intalled : reloads laptop-mode each time occurs an acpi event
2. if "ENABLE_LAPTOP_MODE=false"
 - just executing the script in /etc/acpi/ac.d or /etc/acpi/battery.d,

- I don't know if laptop-mode package is installed by default
- It would simpler to add hdparm settings in acpi-support...
- the solution 2 works well, it's enougth for me, I have no more time to do this...

Useful command : testing current hdparm setting
sudo hdparm -I /dev/sda | grep 'Advanced'