- for (int i = 1; i < argc; ++i) {
- if (! strcmp(argv[i], "-rc")) {
- // look for alternative rc file to use
-
- if ((++i) >= argc) {
- fprintf(stderr, _("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, _("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, _("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(argc, argv);
+ openbox.eventLoop();
+
+ if (openbox.doRestart()) {
+ const std::string &prog = openbox.restartProgram();
+ if (!prog.empty()) {
+ execl("/bin/sh", "/bin/sh", "-c", prog.c_str(), NULL);
+ perror(prog.c_str());