Codebase list xapp / 9349913
xapp-util: Add a function to check whether the session is fully active. Michael Webster 3 years ago
2 changed file(s) with 61 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
4343
4444 return g_strstr_len (contents, -1, "on-demand") != NULL;
4545 }
46
47 // Copied from cinnamon:main.c
48 /**
49 * xapp_util_get_session_is_running:
50 *
51 * Check if the Session Manager is currently in the "Running" phase.
52 *
53 * Returns: %TRUE if the session is running.
54 *
55 * Since: 2.0
56 */
57 gboolean
58 xapp_util_get_session_is_running (void)
59 {
60 GDBusConnection *session_bus;
61 GError *error;
62 GVariant *session_result;
63 gboolean session_running;
64
65 error = NULL;
66
67 session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION,
68 NULL,
69 &error);
70
71 if (error != NULL)
72 {
73 g_critical ("Unable to determine if session is running, could not get session bus: %s\n", error->message);
74 g_clear_error (&error);
75
76 return FALSE;
77 }
78
79 session_result = g_dbus_connection_call_sync (session_bus,
80 "org.gnome.SessionManager",
81 "/org/gnome/SessionManager",
82 "org.gnome.SessionManager",
83 "IsSessionRunning",
84 NULL,
85 G_VARIANT_TYPE ("(b)"),
86 G_DBUS_CALL_FLAGS_NONE,
87 1000,
88 NULL,
89 &error);
90
91 if (session_result != NULL)
92 {
93 g_variant_get (session_result, "(b)", &session_running);
94 g_variant_unref (session_result);
95 }
96 else
97 {
98 session_running = FALSE;
99 g_clear_error (&error);
100 }
101
102 g_object_unref (session_bus);
103
104 return session_running;
105 }
55 G_BEGIN_DECLS
66
77 gboolean xapp_util_gpu_offload_supported (void);
8 gboolean xapp_util_get_session_is_running (void);
89
910 G_END_DECLS
1011 #endif /* __XAPP_UTIL_H__ */