Skip to content

Commit d797072

Browse files
committed
Respect XDG autostart paths
1 parent 33fdde1 commit d797072

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

src/lightdm-gtk-greeter.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,46 @@ reassign_menu_item_accel (GtkWidget *item)
15071507
gtk_container_foreach (GTK_CONTAINER (submenu), (GtkCallback)reassign_menu_item_accel, NULL);
15081508
}
15091509

1510+
gboolean
1511+
greeter_g_key_file_load_from_config_dirs (GKeyFile *key_file,
1512+
const gchar *file,
1513+
gchar **full_path,
1514+
GKeyFileFlags flags,
1515+
GError **error)
1516+
{
1517+
gchar **all_config_dirs;
1518+
const gchar * user_config_dir;
1519+
const gchar * const * system_config_dirs;
1520+
gsize i, j;
1521+
gboolean found_file;
1522+
1523+
g_return_val_if_fail (key_file != NULL, FALSE);
1524+
g_return_val_if_fail (!g_path_is_absolute (file), FALSE);
1525+
1526+
user_config_dir = g_get_user_config_dir ();
1527+
system_config_dirs = g_get_system_config_dirs ();
1528+
all_config_dirs = g_new (gchar *, g_strv_length ((gchar **)system_config_dirs) + 2);
1529+
1530+
i = 0;
1531+
all_config_dirs[i++] = g_strdup (user_config_dir);
1532+
1533+
j = 0;
1534+
while (system_config_dirs[j] != NULL)
1535+
all_config_dirs[i++] = g_strdup (system_config_dirs[j++]);
1536+
all_config_dirs[i] = NULL;
1537+
1538+
found_file = g_key_file_load_from_dirs (key_file,
1539+
file,
1540+
(const gchar **)all_config_dirs,
1541+
full_path,
1542+
flags,
1543+
error);
1544+
1545+
g_strfreev (all_config_dirs);
1546+
1547+
return found_file;
1548+
}
1549+
15101550
static gchar*
15111551
find_indicator_exec (const gchar *name)
15121552
{
@@ -1521,10 +1561,10 @@ find_indicator_exec (const gchar *name)
15211561
indicator = g_strdup_printf ("ayatana-indicator-%s", name);
15221562
#endif
15231563

1524-
desktop = g_strdup_printf ("/etc/xdg/autostart/%s.desktop", indicator);
1564+
desktop = g_strdup_printf ("autostart/%s.desktop", indicator);
15251565

15261566
keyfile = g_key_file_new ();
1527-
if (g_key_file_load_from_file (keyfile, desktop, G_KEY_FILE_NONE, NULL)) {
1567+
if (greeter_g_key_file_load_from_config_dirs (keyfile, desktop, NULL, G_KEY_FILE_NONE, NULL)) {
15281568
exec = g_key_file_get_string (keyfile, "Desktop Entry", "Exec", NULL);
15291569
} else {
15301570
g_free (desktop);

0 commit comments

Comments
 (0)