Author Topic: Run Something On Suspend/resume  (Read 2369 times)

louigi600

  • Sr. Member
  • ****
  • Posts: 471
    • View Profile
Run Something On Suspend/resume
« on: March 08, 2007, 03:03:56 am »
I'd like to run some custom scripts upon suspend/resume but it appears that the stuff in /etc/apm/.... is ither no longer used or disabled by default under r121.

Anyone know where I should be looking to get started ?

With kernel 2.6 how are the power/screen rotate buttons events detected and where are the actions, that should take place respectively, configured ?
« Last Edit: March 08, 2007, 03:05:11 am by louigi600 »
Regards
David

SL-c760*  pdaXrom latest
SL-c860    pdaXrom latest ;-)
SL-c1000  pdaXrom Latest
Acer Aspire One running slackware and Clash
Toshiba AC100 running ARMedslack and Clash

*with some hardware problems but good for testing

Ikkakujyu

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • http://ikkakujyu.googlepages.com
Run Something On Suspend/resume
« Reply #1 on: March 08, 2007, 11:48:28 am »
Well, the hinge stuff is handled by a daemon called switchevd... apparently it's part of a package from OpenZaurus called zaurusd. There's configuration scripts for it in /etc/sysconfig/clamshell, should be pretty easy to figure out if you've played with the APM scripts.

(Time to edit the Wiki, I guess.)

For suspend/resume, well, I haven't found any of that yet. There's a lot of power-related patches to the kernel - it might not even be user-configurable. I'll keep poking around. However, the APM scripts still work if you call the apm command to handle suspend/resume.

Switchevd certainly does NOT handle the power switch... it's somewhere in the kernel, I'm pretty sure.
Etched Marble Experiment - pushing the Zaurus to its limit - blog - wiki

louigi600

  • Sr. Member
  • ****
  • Posts: 471
    • View Profile
Run Something On Suspend/resume
« Reply #2 on: March 08, 2007, 04:57:29 pm »
Quote
Well, the hinge stuff is handled by a daemon called switchevd... apparently it's part of a package from OpenZaurus called zaurusd. There's configuration scripts for it in /etc/sysconfig/clamshell, should be pretty easy to figure out if you've played with the APM scripts.

(Time to edit the Wiki, I guess.)

For suspend/resume, well, I haven't found any of that yet. There's a lot of power-related patches to the kernel - it might not even be user-configurable. I'll keep poking around. However, the APM scripts still work if you call the apm command to handle suspend/resume.

Switchevd certainly does NOT handle the power switch... it's somewhere in the kernel, I'm pretty sure.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=155774\"][{POST_SNAPBACK}][/a][/div]
I figured out that switchevd could have something to do with the rotation stull ... maybe with a little fiddling I can also get the display to turn off when I close the lid.

For the power switch the goal was to have something done when I suspend/resume trough the power button ... not the other way round. Maybe when I'll be more experienced I could modify kernel so that before suspending some user customizable stuff can be done too. For the moment I'll just stick the way it is.

Thanks anyway for the hints.
« Last Edit: March 08, 2007, 05:02:31 pm by louigi600 »
Regards
David

SL-c760*  pdaXrom latest
SL-c860    pdaXrom latest ;-)
SL-c1000  pdaXrom Latest
Acer Aspire One running slackware and Clash
Toshiba AC100 running ARMedslack and Clash

*with some hardware problems but good for testing

Ikkakujyu

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • http://ikkakujyu.googlepages.com
Run Something On Suspend/resume
« Reply #3 on: March 08, 2007, 06:20:24 pm »
Quote
... maybe with a little fiddling I can also get the display to turn off when I close the lid.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=155789\"][{POST_SNAPBACK}][/a][/div]

The display -does- turn off when you close the lid, at least ideally. I've only ever gotten it working consistently by blocking out the lightnpower.py lines in the home dir's xinitrc. Of course, then the system won't suspend automatically. I'm looking into how OpenZaurus handles it right now.
Etched Marble Experiment - pushing the Zaurus to its limit - blog - wiki

louigi600

  • Sr. Member
  • ****
  • Posts: 471
    • View Profile
Run Something On Suspend/resume
« Reply #4 on: March 09, 2007, 04:54:58 am »
Quote
The display -does- turn off when you close the lid, at least ideally. I've only ever gotten it working consistently by blocking out the lightnpower.py lines in the home dir's xinitrc. Of course, then the system won't suspend automatically. I'm looking into how OpenZaurus handles it right now.[div align=\"right\"][a href=\"index.php?act=findpost&pid=155796\"][{POST_SNAPBACK}][/a][/div]
Yea .... ideally it should ... but when it's dark and I close the lid, by peeping in the gap I can see that it's not off (at least not untill the "screen off" timeout is reached ... which is not the way it should work).

Some time ago while looking at the lightnpower.py script I noticed that it understabds several long options and that it may be possible to add some more ... like maybe "--backlightoff" .

It may then be possible to have lightnpower run with "--backlightoff" when the "lid closed" condition is detected and with "--loadnquit" when the "lid opened" condition is detected ... supposing it is possible to detect bothe conditions.
I'm supposing that when you open the lid landscape.sh is called, when you rotate it portrate.sh is called and when you close it close.sh is called.
If this is right then if you open it and rotate it you must go trough  the landscape status first. So essentially it should be possible to detect bothe conditions.
Regards
David

SL-c760*  pdaXrom latest
SL-c860    pdaXrom latest ;-)
SL-c1000  pdaXrom Latest
Acer Aspire One running slackware and Clash
Toshiba AC100 running ARMedslack and Clash

*with some hardware problems but good for testing

louigi600

  • Sr. Member
  • ****
  • Posts: 471
    • View Profile
Run Something On Suspend/resume
« Reply #5 on: March 09, 2007, 10:24:54 am »
That was too complicated ... I've found a much easier way to get the screen off when you close the lid (not suspend ... I want mp3 playback with lid closed).

Here's what I did:
edit the /etc/sysconfig/clamshell/scripts.d/x11scr
go down to the closed function and comment the line that has the
/usr/X11R6/bin/xset dpms force suspend
command and replace it with this
/usr/X11R6/bin/xset s activate

save 'n exit script, exit X, restart switchevd and restart X.
Now close the lid and peep in the gap, the display should be off.
On my C860 it works as long as switchevd is working.

Still have not found anything to let me execute custom scripts upon suspend/esume though.
Regards
David

SL-c760*  pdaXrom latest
SL-c860    pdaXrom latest ;-)
SL-c1000  pdaXrom Latest
Acer Aspire One running slackware and Clash
Toshiba AC100 running ARMedslack and Clash

*with some hardware problems but good for testing