Bug 93533 - klaptopdaemon does not invoke script but calls ACPI directly
Summary: klaptopdaemon does not invoke script but calls ACPI directly
Status: RESOLVED FIXED
Alias: None
Product: klaptopdaemon
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Campbell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-18 20:19 UTC by Sebastian Kügler
Modified: 2005-04-05 23:10 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Workaround proposal which runs a script instead of writing into /proc directly (3.16 KB, patch)
2005-01-14 02:09 UTC, Sebastian Kügler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Kügler 2004-11-18 20:19:14 UTC
Version:           1.4 (using KDE KDE 3.3.1)
Installed from:    Debian testing/unstable Packages
Compiler:          gcc 3.3 
OS:                Linux

Suspend-to{disk|RAM} is currently mostly used from a script to workaround some glitches (like unloading incompatible drivers, switching to a textconsole e.g.). It seems though, that klaptopdaemon does not recognize that there's a script that has to do some work before the sleep-state is invoked and directly tells the kernel to get into said sleep state. That breaks systems on which the work to be done by the hibernate script is necessary. It worked for me pretty well in the first place, but for some time now, switching of VTs is not any more done by software suspend but has to be done in userspace. That broke klaptopdaemons 'hibernate' features. :( 

I'd very much appreciate an option to call a script instead of invoking the sleep state directly (the one used on most systems is called 'hibernate'), so I'll be able to choose the behaviour of the hibernate options. 

Otherwise klaptopdaemon is a great tool, thanks for it!
Comment 1 Nigel Cunningham 2004-11-18 23:44:52 UTC
Hi.

Sebastian didn't make it too clear, but he's referring to the suspend2 patches (softwaresuspend.berlios.de) when he talks about vt switching needing to be done from userspace. The implementation in the vanilla kernel will need userspace help with unloading modules too, so I want to support his plea for klaptopdaemon to run a script instead of directly echoing to /proc/acpi/sleep.

Regards,

Nigel
Comment 2 Paul Campbell 2004-11-18 23:53:20 UTC
I'm back from my hiatus travelling the world and will soon be spending more time on klaptopdaemon (just need to do some simple things like find a house etc) - this has been on my list of things to do for a while
Comment 3 Robert 2005-01-07 13:28:10 UTC
I second this feature request. klaptop(daemon) seems like a very useful application but this is something that unfortunately renders hibernate etc. unusable to me.
There only needs to be a simple input thingy where you can define a "hibernate script".
I'm voting here :)
Comment 4 Sebastian Kügler 2005-01-14 02:09:43 UTC
Created attachment 9078 [details]
Workaround proposal which runs a script instead of writing into /proc directly

Attached patch fixes the problem for me, S3 and S4 work together properly with
klaptopd. 

The patch changes the parts where /proc is written to directly to run a script.
The scripts that are now called are:
/usr/sbin/suspend for suspend-to-ram (S3)
/usr/sbin/hibernate (S4)
/usr/sbin/software-suspend (S4)

(The latter two might be merged, though.)

But ... this patch can break existing setups, since the scripts called might
not be installed on systems where writing (1|3|4) into /proc/acpi/sleep
actually works.

The patch was kindly prepared by Thunfisch@thunfisch.org and applies cleanly to
the version of klaptopd in 3.3.2 and current CVS.
Comment 5 groot 2005-04-05 23:10:55 UTC
CVS commit by adridg: 

Prefer scripts suspend or hibernate over direct access to
/proc/acpi/sleep, as noted in the patch attached to the bug report.
The patch has been munged somewhat, though.
BUGS:93533


  M +3 -0      acpi_helper.cpp   1.19


--- kdeutils/klaptopdaemon/acpi_helper.cpp  #1.18:1.19
@@ -115,4 +115,6 @@ main(int argc, char **argv)
         for (i = 1; i < argc; i++)
         if (strcmp(argv[i], "--suspend") == 0 || strcmp(argv[i], "-suspend") == 0) {
+                /* Returns only if suspend does not exist. */
+                run_program("/usr/sbin/suspend");
                 write_to_proc_sleep(3);
                 exit(0);
@@ -127,4 +129,5 @@ main(int argc, char **argv)
         } else
         if (strcmp(argv[i], "--hibernate") == 0 || strcmp(argv[i], "-hibernate") == 0) {
+                run_program("/usr/sbin/hibernate");
                 write_to_proc_sleep(4);
                 exit(0);