+
+static void print_version()
+{
+ g_print("Openbox %s\n\n", PACKAGE_VERSION);
+ g_print("This program comes with ABSOLUTELY NO WARRANTY.\n");
+ g_print("This is free software, and you are welcome to redistribute it\n");
+ g_print("under certain conditions. See the file COPYING for details.\n\n");
+}
+
+static void print_help()
+{
+ print_version();
+ g_print("Syntax: openbox [options]\n\n");
+ g_print("Options:\n\n");
+#ifdef USE_SM
+ g_print(" --sm-disable Disable connection to session manager\n");
+ g_print(" --sm-client-id ID Specify session management ID\n");
+ g_print(" --sm-save-file FILE Specify file to load a saved session\n"
+ " from\n");
+#endif
+ g_print(" --replace Replace the currently running window "
+ "manager\n");
+ g_print(" --help Display this help and exit\n");
+ g_print(" --version Display the version and exit\n");
+ g_print(" --sync Run in synchronous mode (this is slow and\n"
+ " meant for debugging X routines)\n");
+ g_print(" --debug Display debugging output\n");
+ g_print("\nPlease report bugs at %s\n", PACKAGE_BUGREPORT);
+}
+
+static void parse_args(int argc, char **argv)
+{
+ int i;
+
+ for (i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "--version")) {
+ print_version();
+ exit(0);
+ } else if (!strcmp(argv[i], "--help")) {
+ print_help();
+ exit(0);
+ } else if (!strcmp(argv[i], "--g-fatal-warnings")) {
+ g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
+ } else if (!strcmp(argv[i], "--replace")) {
+ ob_replace_wm = TRUE;
+ } else if (!strcmp(argv[i], "--sync")) {
+ xsync = TRUE;
+ } else if (!strcmp(argv[i], "--debug")) {
+ ob_debug_show_output(TRUE);
+#ifdef USE_SM
+ } else if (!strcmp(argv[i], "--sm-client-id")) {
+ if (i == argc - 1) /* no args left */
+ g_printerr(_("--sm-client-id requires an argument\n"));
+ else
+ ob_sm_id = g_strdup(argv[++i]);
+ } else if (!strcmp(argv[i], "--sm-save-file")) {
+ if (i == argc - 1) /* no args left */
+ g_printerr(_("--sm-save-file requires an argument\n"));
+ else
+ sm_save_file = argv[++i];
+ } else if (!strcmp(argv[i], "--sm-disable")) {
+ ob_sm_use = FALSE;
+#endif
+ } else {
+ g_printerr("Invalid option: '%s'\n\n", argv[i]);
+ print_help();
+ exit(1);
+ }
+ }
+}
+
+void ob_exit_with_error(gchar *msg)
+{
+ g_critical(msg);
+ session_shutdown();
+ exit(EXIT_FAILURE);
+}
+
+void ob_restart_other(const gchar *path)
+{
+ restart_path = g_strdup(path);
+ ob_restart();
+}
+
+void ob_restart()
+{
+ restart = TRUE;
+ ob_exit();
+}
+
+void ob_exit()
+{
+ shutdown = TRUE;
+}
+
+Cursor ob_cursor(ObCursor cursor)
+{
+ g_assert(cursor < OB_NUM_CURSORS);
+ return cursors[cursor];
+}
+
+KeyCode ob_keycode(ObKey key)
+{
+ g_assert(key < OB_NUM_KEYS);
+ return keys[key];
+}
+
+ObState ob_state()
+{
+ return state;
+}