- exit_with_error("Failed to set display as close-on-exec.");
-
- cb.save_yourself.callback = sm_save_yourself;
- cb.save_yourself.client_data = NULL;
-
- cb.die.callback = sm_die;
- cb.die.client_data = NULL;
-
- cb.save_complete.callback = sm_save_complete;
- cb.save_complete.client_data = NULL;
-
- cb.shutdown_cancelled.callback = sm_shutdown_cancelled;
- cb.shutdown_cancelled.client_data = NULL;
-
- ob_sm_conn = SmcOpenConnection(NULL, NULL, 1, 0,
- SmcSaveYourselfProcMask |
- SmcDieProcMask |
- SmcSaveCompleteProcMask |
- SmcShutdownCancelledProcMask,
- &cb, ob_sm_id, &ob_sm_id,
- SM_ERR_LEN, sm_err);
- if (ob_sm_conn == NULL)
- g_warning("Failed to connect to session manager: %s", sm_err);
- else {
- SmPropValue val_cmd;
- SmPropValue val_res;
- SmPropValue val_prog;
- SmPropValue val_uid;
- SmProp prop_cmd = { SmCloneCommand, "SmLISTofARRAY8", 1, };
- SmProp prop_res = { SmRestartCommand, "SmLISTofARRAY8", 1, };
- SmProp prop_prog = { SmProgram, "SmARRAY8", 1, };
- SmProp prop_uid = { SmUserID, "SmARRAY8", 1, };
- SmProp *props[4];
- gchar *user;
-
- val_cmd.value = argv[0];
- val_cmd.length = strlen(argv[0]);
- val_res.value = argv[0];
- val_res.length = strlen(argv[0]); /* XXX -id foo */
- val_prog.value = argv[0];
- val_prog.length = strlen(argv[0]);
-
- user = g_strdup_printf("%ld", (long)getuid());
- val_uid.value = user;
- val_uid.length = strlen(user);
-
- prop_cmd.vals = &val_cmd;
- prop_res.vals = &val_res;
- prop_prog.vals = &val_prog;
- prop_uid.vals = &val_uid;
-
- props[0] = &prop_cmd;
- props[1] = &prop_res;
- props[2] = &prop_prog;
- props[3] = &prop_uid;
-
- SmcSetProperties(ob_sm_conn, 3, props);
-
- g_free(user);
-
- g_message("Connected to session manager with id %s", ob_sm_id);
- }
- g_free (ob_sm_id);