Re: [Vala] problem using sleep
- From: Frederik <scumm_fredo gmx net>
- To: vala-list <vala-list gnome org>
- Subject: Re: [Vala] problem using sleep
- Date: Sat, 10 Oct 2009 18:38:49 +0200
a a wrote:
Hello.
I'd like to sleep for X minutes and then run a command as root.
I've tried this with no success:
Process.spawn_command_line_async("sleep "+time_min+"m ; gksudo
'/etc/acpi/hibernate.sh'");
(in the terminal it works)
How should I do it?
Thanks :)
Hi,
you can't concatenate commands as you would do it in a shell.
If your program is running a GLib main loop (e.g. a GTK+ program or if
you're using GLib.MainLoop directly) then you can set a timeout:
-----------------------------------------------------------------
int time_min = 5;
Timeout.add (time_min * 1000 * 60, () => {
try {
Process.spawn_command_line_async ("gksudo '/etc/acpi/hibernate.sh'");
} catch (Error e) {
stderr.printf ("%s\n", e.message);
}
return false;
});
-----------------------------------------------------------------
If you're returning 'true' instead of 'false' the process will be
spawned repeatedly every x minutes.
Best regards,
Frederik
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]