- if (ob_display == NULL) {
- /* print a message and exit */
- g_critical("Failed to open the display.");
- exit(1);
- }
- if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1) {
- /* print a message and exit */
- g_critical("Failed to set display as close-on-exec.");
- exit(1);
- }
+ if (ob_display == NULL)
+ exit_with_error("Failed to open the display.");
+ if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1)
+ 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, NULL, &sm_id, SM_ERR_LEN, sm_err);
+ if (ob_sm_conn == NULL)
+ g_warning("Failed to connect to session manager: %s", sm_err);
+ else
+ g_message("Connected to session manager with id %s", sm_id);
+ g_free (sm_id);