- char *session_display = (char *) 0;
- char *rc_file = (char *) 0;
- char *menu_file = (char *) 0;
-
- i18n.openCatalog("openbox.cat");
-
- for (int i = 1; i < argc; ++i) {
- if (! strcmp(argv[i], "-rc")) {
- // look for alternative rc file to use
-
- if ((++i) >= argc) {
- fprintf(stderr,
- i18n(mainSet, mainRCRequiresArg,
- "error: '-rc' requires and argument\n"));
-
- ::exit(1);
- }
-
- rc_file = argv[i];
- } else if (! strcmp(argv[i], "-menu")) {
- // look for alternative menu file to use
-
- if ((++i) >= argc) {
- fprintf(stderr,
- i18n(mainSet, mainMENURequiresArg,
- "error: '-menu' requires and argument\n"));
-
- ::exit(1);
- }
-
- menu_file = argv[i];
- } else if (! strcmp(argv[i], "-display")) {
- // check for -display option... to run on a display other than the one
- // set by the environment variable DISPLAY
-
- if ((++i) >= argc) {
- fprintf(stderr,
- i18n(mainSet, mainDISPLAYRequiresArg,
- "error: '-display' requires an argument\n"));
-
- ::exit(1);
- }
-
- session_display = argv[i];
- string dtmp = "DISPLAY=";
- dtmp += session_display;
-
- if (putenv(const_cast<char*>(dtmp.c_str()))) {
- fprintf(stderr, i18n(mainSet, mainWarnDisplaySet,
- "warning: couldn't set environment variable 'DISPLAY'\n"));
- perror("putenv()");
- }
- } else if (! strcmp(argv[i], "-version")) {
- // print current version string
- printf("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
- " 2001 - 2002 Sean 'Shaleh' Perry\n"
- " 1997 - 2000, 2002 Brad Hughes\n\n",
- OPENBOX_VERSION);
-
- ::exit(0);
- } else if (! strcmp(argv[i], "-help")) {
- showHelp(0);
- } else { // invalid command line option
- showHelp(-1);
+ // initialize the locale
+ if (!setlocale(LC_ALL, ""))
+ printf("Couldn't set locale from environment.\n");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
+ textdomain(PACKAGE);
+
+ ob::Openbox *openbox = new ob::Openbox(argc, argv);
+ openbox->eventLoop();
+
+ if (openbox->doRestart()) {
+ std::string prog = openbox->restartProgram();
+
+ delete openbox; // shutdown the current one!
+
+ if (!prog.empty()) {
+ execl("/bin/sh", "/bin/sh", "-c", prog.c_str(), NULL);
+ perror(prog.c_str());