Thanks for hanging in there Jay_Bee, and don't worry about the number of edits. It's obvious that you are starting to piece this together in your own mind, and that is good. (I have no idea whether you've had any experience with shell scripts before and I've asked you to do things that would scare some people.) If we can get this solved, and if nobody else has already file a bug report, I hope to file a bug report referencing this thread.
Just so you know, that statement I had you add should not change what the script actually does. It just causes the script to show each line that it executes (sort of) so we can tell what is happening. (And I didn't think about all of the lines that would be spit out as a result of it "sourcing" laptop-mode.conf. :-/ )
I am a bit surprised, because in Edgy (the reference I have) the default was 0. But as I pointed out in post #23 I think the script needs to be modified to not even check that unless lapt-mode is running. But we shouldn't need to worry about that to get you up and running.
Originally Posted by Jay_Bee
Just to double check that we understand each other, let me recap ...
I changed the CONTROL_HD_POWERMGMT to 0 and after resuming the value remained 128 but running your script did the trick. ...
Now... how to make the script actually run on resume?
After changing CONTROL_HD_POWERMGMT to 0 (in laptop-mode.conf), manually running the modified script gives the expected result. That means the unmodified script should work also. You can easily verify this:
(You should start whith the disk's APM not set to 254 just to make sure the script actually did something!)
sudo hdparm -I /dev/sda | grep -i power
My belief is that copies of that script (90-hdparm.sh) exist in the following directories:
Could you double check that for me? If you want to make sure the files are in fact identical, you can use commands like:
which will compare those two files. If the command produces no outptut, the files are the same. (See note below about "tab completion" if you don't already know about it.)
cmp /etc/acpi/resume.d/90-hdparm.sh /etc/acpi/start.d/90-hdparm.sh
So if the unmodified script works (when run manually) and if it is in all of the locations I just mentioned, then I would think it should handle things correctly at start, when resuming from suspend or hibernate, and when switching to/from battery. If it does not, I may not be able to help you troubleshoot further. Please post back when you know for sure whether that is where we are.
If there is anybody else following this thread who has an idea about this, please post! Otherwise I might just need to file the bug report w/o the complete solution and see what the developers come up with.
You can save yourself a great deal of effort with commands that involve long path/filenames (and commands to!) like the cmp command above by using "tab completion." In that example, it you start typing "/etc/ac" and then hit the tab key, it will (at least partially) complete the rest if there is no ambiguity. In this case it will get you to "/etc/acpi/". You can type some more, hit tab again, etc., until finished with the parameter. If there is an ambiguity when you hit tab, it will beep. Just type another character or two and hit tab again. You can do this as many times in a command line as wish. And save yourself a lot of typing!
If you are going to run a series of commands that are almost the same, such as the three commands to compare those four files above, you can hit the "up arrow" on your keyboard to recall the previous command and then use left/right arrows, backspace and delete keys to make minor alterations. This is another great way to avoid typing.