After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 608402 - Add support for delaying autostart applications
Add support for delaying autostart applications
Status: RESOLVED OBSOLETE
Product: gnome-session
Classification: Core
Component: general
2.29.x
Other Linux
: Low enhancement
: ---
Assigned To: Session Maintainers
Session Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-01-29 00:55 UTC by Chris Coulson
Modified: 2021-06-14 18:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add support for AutostartDelay (10.39 KB, patch)
2010-01-29 00:55 UTC, Chris Coulson
reviewed Details | Review
libegg patch (1.80 KB, patch)
2010-01-29 01:30 UTC, Chris Coulson
committed Details | Review
current version of the patch (9.41 KB, application/x-shellscript)
2012-04-20 14:40 UTC, Sebastien Bacher
  Details
GSMAutostartApp: Add support for autostarting applications after a delay (10.51 KB, patch)
2013-06-01 00:54 UTC, darkxst
none Details | Review

Description Chris Coulson 2010-01-29 00:55:53 UTC
Created attachment 152536 [details] [review]
Add support for AutostartDelay

In Ubuntu, we have quite a few things start in the session now which we start after a delay. This is currently achieved by specifying something like 'sh -c "sleep 30; exec <app>' on the Exec line in the autostart desktop file for each particular application we want to delay.

This solution is far from elegant, as it still spawns a shell which sits there until the sleep delay expires.

When gnome-screensaver was started from g-s-d, it was started after a delay. This is not the case anymore since it is started as a normal autostart app.

I think it would make sense to support something like this natively in gnome-session. I've attached a patch which implements this feature, by supporting a new key called "AutostartDelay" in the desktop files. The feature only permits applications which start in the APPLICATION phase to specify an autostart delay (it doesn't make sense having a delay in earlier phases)
Comment 1 Vincent Untz 2010-01-29 01:03:03 UTC
Please prefix the key name with X-GNOME. Also, the egg* changes should go to libegg first, I guess.

(didn't really review the patch, though)
Comment 2 Chris Coulson 2010-01-29 01:30:39 UTC
Created attachment 152541 [details] [review]
libegg patch

Here is a patch for libegg for reading integers from desktop files
Comment 3 Vincent Untz 2010-01-29 11:14:32 UTC
Review of attachment 152536 [details] [review]:

::: gnome-session/gsm-autostart-app.c
@@ +462,3 @@
+                if (app->priv->autostart_delay < 0) {
+                        g_warning ("Invalid autostart delay of %d for %s", app->priv->autostart_delay,
+                                   gsm_app_peek_id (GSM_APP (app)));

Probably better to set it to -1 again if it's invalid (just in case someone adds some "== -1" check later).

::: gnome-session/gsm-manager.c
@@ +330,2 @@
                         error = NULL;
+                        if (gsm_app_is_running (app)) {

Shouldn't this check be done in gsm_app_stop?

@@ +585,3 @@
+        }
+
+        return FALSE;

Wouldn't it be simpler to call _start_app again (without the check for autostart delay)?

This would imply calling gsm_app_peek_autostart_delay first in _start_app, I guess, and splitting the code in _start_app and _start_app_internal, or something like this.

@@ +618,3 @@
+                g_timeout_add_seconds (delay, 
+                                       (GSourceFunc)_autostart_delay_timeout,
+                                       app);

You want to ref the app, to be 100% sure it still exists on timeout.
Comment 4 Vincent Untz 2010-01-29 11:16:07 UTC
Review of attachment 152541 [details] [review]:

Probably okay to go in. Dan?

::: libegg/smclient/eggdesktopfile.c
@@ +435,3 @@
+egg_desktop_file_get_integer (EggDesktopFile *desktop_file,
+						const char		*key,
+    					GError		   **error)

Interesting indentation :-)

::: libegg/smclient/eggdesktopfile.h
@@ +128,3 @@
 						   const char      *key,
 						   GError         **error);
+int	      egg_desktop_file_get_integer            (EggDesktopFile  *desktop_file,

And here too ;-)
Comment 5 Dan Winship 2010-01-29 14:35:04 UTC
(In reply to comment #4)
> Review of attachment 152541 [details] [review]:
> 
> Probably okay to go in. Dan?

yeah, fix the indentation though.
Comment 6 Chris Coulson 2010-01-29 14:51:03 UTC
Thanks, I've committed the libegg change now, with the fixed indentation
Comment 7 Martin Pitt 2010-02-12 16:02:39 UTC
Just for the record, this is working wonderfully. Thanks Chris!
Comment 8 Ray Strode [halfline] 2010-02-15 14:59:33 UTC
This is a little bit of a tangent from this bug report, but for the screensaver case specifically, another idea would be to have screensaver get d-bus activated when

1) the session goes idle
2) the user tries to lock the screen

and then not bother starting it at login at all.
Comment 9 Ray Strode [halfline] 2010-02-15 15:02:24 UTC
(to do comment 8 "right" we'd need to get a feature into D-Bus where it can activate services on signal emission, I think)
Comment 10 Pacho Ramos 2010-06-19 19:21:32 UTC
Was this fixed finally? (I would like to start to add delays for some apps I run at startup)

Thanks
Comment 11 Vincent Untz 2011-05-26 09:24:49 UTC
Comment on attachment 152541 [details] [review]
libegg patch

This got committed a while ago.
Comment 12 Vincent Untz 2011-05-26 10:53:05 UTC
Review of attachment 152536 [details] [review]:

I reread the patch, and came with additional comments :-)

::: gnome-session/gsm-autostart-app.c
@@ +455,3 @@
         setup_condition_monitor (app);
 
+        if (phase == GSM_MANAGER_PHASE_APPLICATION) {

I wouldn't do this check here, but in gsm-manager.c (see other comment). So, always read AutostartDelay.

@@ +458,3 @@
+                /* Only accept an autostart delay for the application phase */
+                app->priv->autostart_delay = egg_desktop_file_get_integer (app->priv->desktop_file,
+                                                                           "AutostartDelay",

Hrm, btw, shouldn't this key be prefixed with X-GNOME?

::: gnome-session/gsm-manager.c
@@ +568,3 @@
 static gboolean
+_autostart_delay_timeout (GsmApp *app)
+{

This should do nothing if we're in a phase > GSM_MANAGER_PHASE_RUNNING.

@@ +614,3 @@
         }
 
+        delay = gsm_app_peek_autostart_delay (app);

This is where the check for GSM_MANAGER_PHASE_APPLICATION should be done, imho.

@@ +618,3 @@
+                g_timeout_add_seconds (delay, 
+                                       (GSourceFunc)_autostart_delay_timeout,
+                                       app);

The other thing I'm wondering is whether we should track those timeouts and properly cancel them on logout. Would be cleaner, but this means yet another list to keep around.
Comment 13 Sebastien Bacher 2012-04-20 14:40:55 UTC
Created attachment 212425 [details]
current version of the patch

the patch we have currently in Ubuntu (gnome-session 3.2), I don't think it addresses the previous review comments
Comment 14 darkxst 2013-06-01 00:54:47 UTC
Created attachment 245793 [details] [review]
GSMAutostartApp: Add support for autostarting applications after a delay

Make it possible to delay autostarting an application for a time
period defined by the "AutostartDelay" key in the applications
desktop file

Updated for gnome-session 3.8/3.9 and reworked to address the review comments
(except for the last comment about keeping track of the timeouts)
Comment 15 André Klapper 2021-06-14 18:20:21 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version of gnome-session, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/gnome-session/-/issues/

Thank you for your understanding and your help.