GNOME Bugzilla – Bug 777994
AutostartCondition does not support absolute paths
Last modified: 2017-02-05 10:17:31 UTC
I was trying to write a autostart desktop file (to be placed in /etc/xdg/autostart) today and I found out that lines like the following one: AutostartCondition=unless-exists my-stamp-file ...will look for that file using the user's configuration directory as the base for the search (see https://git.gnome.org/browse/gnome-session/tree/gnome-session/gsm-autostart-app.c#n844), which is a big inconvenient for my case as I was trying to monitor under /var/lib/my-package/my-stamp-file instead. I understand that supporting absolute paths could be problematic if such path points to a different volume (it could make the file monitor slow) but I still think it would be interesting to support this feature as it might be still useful in some less general cases, as it could be of our downstream case in Endless, for instance. Comments?
I thought I added Ray to CC, but seems I didn't. Adding now...
I actually already cc to all g-s bugs by gmail... I'd take a patch that does a g_path_is_absolute check
Oops, sorry for spamming then. Thanks for considering this, I'll try to come up with a patch soon then.
Created attachment 344870 [details] [review] Patch proposal See the proposed patch attached. I've tested it and seems to do exactly what I need,without regressing the currently expected functionality. Please review, thanks!
Review of attachment 344870 [details] [review]: yea sure. one suggestion that you can take or leave before pushing... ::: gnome-session/gsm-autostart-app.c @@ +518,3 @@ + file_path = g_path_is_absolute (key) ? g_strdup (key) + : g_build_filename (g_get_user_config_dir (), key, NULL); this is a little noisy ^. Not a big deal, but the noise gets repeated several times. maybe have static char * resolve_conditional_file_path (const char *file) { if (g_path_is_absolute (file)) return g_strdup (file); return g_build_filename (…); } Anyway, just an idea, push it either way.
Thanks for the review, Ray. Yes, I agree it's noisy, but I was not sure which way you'd prefer to have it so I wrote it in that way as a first proposal. But I can change it before pushing, sure.
Pushed now to master at https://git.gnome.org/browse/gnome-session/commit/?id=21690a7f09bd477ecdefe31f547081d3b1bb1d99 Resolving, thanks!