From fbfed4e39984e645ff8b2f298dc9d1e6bdb2cbb2 Mon Sep 17 00:00:00 2001
From: c4pp4
Date: Sun, 28 Dec 2025 15:48:28 +0100
Subject: [PATCH 1/1] Use gnome-online-accounts-gtk as the fallback

Try to use gnome-online-accounts-gtk as the fallback
when gnome-control-center is not available.

Signed-off-by: c4pp4
---
 src/utils/gcal-utils.c | 57 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/src/utils/gcal-utils.c b/src/utils/gcal-utils.c
index c9e7b25..650d108 100644
--- a/src/utils/gcal-utils.c
+++ b/src/utils/gcal-utils.c
@@ -980,6 +980,46 @@ create_dbus_proxy (GDBusConnection *connection,
                                 NULL);
 }
 
+static gboolean
+in_desktop (const gchar *name)
+{
+  const gchar *desktop_name_list;
+  gchar **names;
+  gboolean in_list = FALSE;
+  gint i;
+
+  desktop_name_list = g_getenv ("XDG_CURRENT_DESKTOP");
+  if (!desktop_name_list)
+    return FALSE;
+
+  names = g_strsplit (desktop_name_list, ":", -1);
+  for (i = 0; names[i] && !in_list; i++)
+    if (strcmp (names[i], name) == 0) {
+      in_list = TRUE;
+      break;
+    }
+  g_strfreev (names);
+
+  return in_list;
+}
+
+static void
+spawn_goa_gtk (void)
+{
+  const gchar* const command[] = { "gnome-online-accounts-gtk", NULL };
+  GError *error = NULL;
+
+  g_spawn_async (NULL, (gchar**) command,
+                 NULL,
+                 G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL,
+                 NULL, NULL, NULL, &error);
+
+  if (error) {
+    g_warning ("Couldn't open GNOME Online Accounts GTK: %s", error->message);
+    g_error_free (error);
+  }
+}
+
 void
 gcal_utils_launch_gnome_settings (GDBusConnection *connection,
                                   const gchar     *panel_id,
@@ -989,6 +1029,7 @@ gcal_utils_launch_gnome_settings (GDBusConnection *connection,
   GVariantBuilder builder;
   GVariant *params[3];
   GVariant *array[1];
+  GError *error = NULL;
 
   g_variant_builder_init (&builder, G_VARIANT_TYPE ("av"));
 
@@ -1017,7 +1058,11 @@ gcal_utils_launch_gnome_settings (GDBusConnection *connection,
 
   if (!proxy)
     {
-      g_warning ("Couldn't open panel '%s'", panel_id);
+      if (in_desktop("Unity"))
+        spawn_goa_gtk ();
+      else
+        g_warning ("Couldn't open panel '%s'", panel_id);
+
       return;
     }
 
@@ -1027,7 +1072,15 @@ gcal_utils_launch_gnome_settings (GDBusConnection *connection,
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
                           NULL,
-                          NULL);
+                          &error);
+  if (error) {
+    if (in_desktop("Unity"))
+      spawn_goa_gtk ();
+    else
+      g_warning ("Couldn't open panel '%s': %s", panel_id, error->message);
+
+    g_error_free (error);
+  }
 }
 
 gchar*
-- 
2.51.2

