- if ((++i) >= argc) {
- fprintf(stderr, _("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,
- _("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"),
- OPENBOX_VERSION);
- printf("\n");
-
- ::exit(0);
- } else if (! strcmp(argv[i], "-help")) {
- showHelp(0);
- } else { // invalid command line option
- showHelp(-1);
+int main(int argc, char **argv) {
+ // 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());