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 627923 - GtkApplication could help with enabling application autostart
GtkApplication could help with enabling application autostart
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gapplication
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-08-25 10:27 UTC by John Stowers
Modified: 2018-05-24 12:42 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description John Stowers 2010-08-25 10:27:00 UTC
It would be good if GtkApplication could provide an easy means to enable/disable the starting of an application at login. Quite a few apps include logic similar to [1][2] that copies the desktop file from /usr/share/applications to ~/.config/autostart/

Does GtkApplication have knowledge of the desktop file (or GDesktopAppInfo) that belongs to it so it could install itself into the autostart dir (at least on Unix?)

[1] http://git.gnome.org/browse/conduit/tree/conduit/utils/AutostartManager.py
Comment 1 Dan Winship 2010-08-25 13:33:36 UTC
Moving .desktop files around is the wrong way to do this, because the user/sysadmin/distro might add the application's .desktop file to one of the system autostart directories, in which case the application *would* be autostarted, but it would believe that it *wasn't* being autostarted (because it wouldn't see a .desktop file in ~/.config/autostart), and it would offer a broken "enable/disable autostart" checkbox that had no effect.

The right way to do this is for the application to always install a .desktop file into /etc/xdg/autostart, containing:

    OnlyShowIn=GNOME
    AutostartCondition=GNOME /path/to/gconf/key

and then have the "enable/disable autostart" checkbox be keyed to that GConf key. gnome-session will then autostart the app if and only if that key is set true. (So set its default value in the schema to false if you want the app to not be autostarted by default. And then if the sysadmin/distro wants to change the app to be autostarted by default, they just override the schema, but that will be visible to the app.)
Comment 2 John Stowers 2010-08-25 13:45:35 UTC
(In reply to comment #1)
> Moving .desktop files around is the wrong way to do this, because the
> user/sysadmin/distro might add the application's .desktop file to one of the
> system autostart directories, in which case the application *would* be
> autostarted, but it would believe that it *wasn't* being autostarted (because
> it wouldn't see a .desktop file in ~/.config/autostart), and it would offer a
> broken "enable/disable autostart" checkbox that had no effect.
> 
> The right way to do this is for the application to always install a .desktop
> file into /etc/xdg/autostart, containing:
> 
>     OnlyShowIn=GNOME
>     AutostartCondition=GNOME /path/to/gconf/key

If applications wishing to autostart must *always* install such a desktop file in addition to their main desktop file, isn't that redundant?

Why not skip requiring the AutostartCondition=GNOME foo line, and get gnome session look in /path/to/gsettings-list-of-apps/desktopfilename by default? If desktopfilename exists, start it...

Anyway, I'm just surprised that it doesn't seem easy to autostart and app on a per user basis without admin rights (or requiring apps to install two desktop files).

Thanks for the advice though. Perhaps a recipe for this should be written down somewhere, google codesearch reveals quite a few apps implementing the desktop file copying approach.
Comment 3 Dan Winship 2010-08-25 13:58:11 UTC
(In reply to comment #2)
> If applications wishing to autostart must *always* install such a desktop file
> in addition to their main desktop file, isn't that redundant?

Yes, but that's how the freedesktop autostart spec says to do it, and this was originally supposed to have been a cross-desktop feature (http://lists.freedesktop.org/archives/xdg/2007-January/007436.html). Of course, that didn't pan out, so we could just change it. Shrug.
Comment 4 Matthias Clasen 2010-10-30 02:13:35 UTC
Moving this to GApplication
Comment 5 John Stowers 2011-06-02 07:50:24 UTC
The latest version of the logic for managing this lives here (python, in gnome-tweak-tool)

http://git.gnome.org/browse/gnome-tweak-tool/tree/gtweak/utils.py#n62

It accepts the application desktop file, and the application autostart desktop file (if different). The class currently
 * creates an autostart file in ~/.local if needed. This is typically a copy of the application desktop file with the exec argument (optionally modified)
 * doesnt fight with those autostart files that have AutostartCondition stanzas
 * plays well with gnome-session-properties (which writes X-GNOME-Autostart-enabled=false to the ~/.local autostart file if manually disabled
Comment 6 GNOME Infrastructure Team 2018-05-24 12:42:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/337.