+static void session_setup_user()
+{
+ char *user = g_strdup(g_get_user_name());
+
+ SmPropValue vals = {
+ .value = user,
+ .length = strlen(user) + 1
+ };
+ SmProp prop = {
+ .name = g_strdup(SmUserID),
+ .type = g_strdup(SmARRAY8),
+ .num_vals = 1,
+ .vals = &vals
+ };
+ SmProp *list = ∝
+ ob_debug_type(OB_DEBUG_SM, "Setting user: %s\n", user);
+ SmcSetProperties(sm_conn, 1, &list);
+ g_free(prop.name);
+ g_free(prop.type);
+ g_free(user);
+}
+
+static void session_setup_restart_style(gboolean restart)
+{
+ gchar restart_hint = restart ? SmRestartImmediately : SmRestartIfRunning;
+
+ SmPropValue vals = {
+ .value = &restart_hint,
+ .length = 1
+ };
+ SmProp prop = {
+ .name = g_strdup(SmRestartStyleHint),
+ .type = g_strdup(SmCARD8),
+ .num_vals = 1,
+ .vals = &vals
+ };
+ SmProp *list = ∝
+ ob_debug_type(OB_DEBUG_SM, "Setting restart: %d\n", restart);
+ SmcSetProperties(sm_conn, 1, &list);
+ g_free(prop.name);
+ g_free(prop.type);
+}
+
+static void session_setup_pid()
+{
+ gchar *pid = g_strdup_printf("%ld", (glong) getpid());
+
+ SmPropValue vals = {
+ .value = pid,
+ .length = strlen(pid) + 1
+ };
+ SmProp prop = {
+ .name = g_strdup(SmProcessID),
+ .type = g_strdup(SmARRAY8),
+ .num_vals = 1,
+ .vals = &vals
+ };
+ SmProp *list = ∝
+ ob_debug_type(OB_DEBUG_SM, "Setting pid: %s\n", pid);
+ SmcSetProperties(sm_conn, 1, &list);
+ g_free(prop.name);
+ g_free(prop.type);
+ g_free(pid);
+}
+
+/*! This is a gnome-session-manager extension */
+static void session_setup_priority()
+{
+ gchar priority = 20; /* 20 is a lower prioity to run before other apps */
+
+ SmPropValue vals = {
+ .value = &priority,
+ .length = 1
+ };
+ SmProp prop = {
+ .name = g_strdup("_GSM_Priority"),
+ .type = g_strdup(SmCARD8),
+ .num_vals = 1,
+ .vals = &vals
+ };
+ SmProp *list = ∝
+ ob_debug_type(OB_DEBUG_SM, "Setting priority: %d\n", priority);
+ SmcSetProperties(sm_conn, 1, &list);
+ g_free(prop.name);
+ g_free(prop.type);
+}