]> Dogcows Code - chaz/openbox/blob - src/main.cc
add cvsignores
[chaz/openbox] / src / main.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 /*! @file main.cc
4 @brief Main entry point for the application
5 */
6
7 #include "config.h"
8
9 extern "C" {
10 #ifdef HAVE_UNISTD_H
11 # include <sys/types.h>
12 # include <unistd.h>
13 #endif // HAVE_UNISTD_H
14
15 #include "gettext.h"
16 }
17
18 #include "openbox.hh"
19 #include "otk/util.hh"
20
21 #include <clocale>
22 #include <cstdio>
23
24 int main(int argc, char **argv) {
25 // initialize the locale
26 if (!setlocale(LC_ALL, ""))
27 printf("Couldn't set locale from environment.\n");
28 bindtextdomain(PACKAGE, LOCALEDIR);
29 bind_textdomain_codeset(PACKAGE, "UTF-8");
30 textdomain(PACKAGE);
31
32 ob::Openbox *openbox = new ob::Openbox(argc, argv);
33 openbox->eventLoop();
34
35 if (openbox->doRestart()) {
36 std::string prog = openbox->restartProgram();
37
38 delete openbox; // shutdown the current one!
39
40 if (!prog.empty()) {
41 execl("/bin/sh", "/bin/sh", "-c", prog.c_str(), NULL);
42 perror(prog.c_str());
43 }
44
45 // fall back in case the above execlp doesn't work
46 execvp(argv[0], argv);
47 execvp(otk::basename(argv[0]).c_str(), argv);
48 }
49
50 delete openbox; // shutdown
51 }
This page took 0.034074 seconds and 4 git commands to generate.