At the last Chicago meet, I mentioned I wanted a way to pause my music when I turn my key off and automatically restart when the key is turned back on. Well I was in Atlanta all last week with family who decided to go shopping two days - ALL DAY. My system is setup to turn the screen off 1 minute after losing AC power and in 2 hours suspend. Needless to say we were never in a store long enough for it to suspend, but having to manually PAUSE/RESUME music everytime we got out of the car got old fast. So I got serious about automating this task.
I already have a timer setup that fires every 15 seconds for audiosource label updates and I figured that interval was sufficient for PAUSE/RESUME also. But how? I googled for an external program to do it to no avail. I tried to figure out if a plugin like POWERMON could be modified to do it (unfortunately POWERMON is no longer supported). I tried to create something with RRCode, but didn't get far. I tried EVAL, but that required too much setup and only worked intermittently. Then I looked at RREXTENDED mated with POWERMON. And here is my code:
In EXECTBL.INI add to ONSKINSTART: "SETVARBYCODE;pstate;powermon_powersrc"
//This resets the variables
In EXECTBL.INI add a timer:
Code:
"TIMER","SETVAR;PSTATE1;$PSTATE$||SETVARBYCODE;pstate;powermon_powersrc||SETVAR;ONBATTERY;$PSTATE1$+$PSTATE$||BYSTR;$ONBATTERY$;External+Battery<PAUSE><<Battery+External<RESUME><<<RELOADLIST"
What this does is copy the Power Source label from POWERMON (Battery or External) and creates a variable, ONBATTERY that is a record of the last two states of that label. There are four possible combinations:
External+External - No change still on AC
Battery+Battery - No change still on Battery
External+Battery - Just changed from AC to Battery
Battery+External - Just changed from Battery to AC
The first two fall under the "Else" statement of the BYSTR and fire the RELOADLIST.
Changing from AC to battery means I cut the car off and fires a PAUSE.
Changing from Battery to AC means the key is back on and fires the RESUME.
NO MORE INTERVENTION FROM ME FOR QUICK STOPS. I'm sure this would be helpful to others with laptop installs also. Thanks again Blue ZX3, Festy, and Sal R.