]> Dogcows Code - chaz/openbox/blob - src/main.cc
move the restart into main.cc, so the openbox class can clean up properly before...
[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 #ifdef HAVE_CONFIG_H
8 # include "../config.h"
9 #endif // HAVE_CONFIG_H
10
11 extern "C" {
12 #ifdef HAVE_LOCALE_H
13 # include <locale.h>
14 #endif // HAVE_LOCALE_H
15
16 #ifdef HAVE_STDIO_H
17 # include <stdio.h>
18 #endif // HAVE_STDIO_H
19
20 #ifdef HAVE_UNISTD_H
21 # include <sys/types.h>
22 # include <unistd.h>
23 #endif // HAVE_UNISTD_H
24
25 #include "gettext.h"
26 }
27
28 #include "openbox.hh"
29 #include "otk/util.hh"
30
31 int main(int argc, char **argv) {
32 // initialize the locale
33 if (!setlocale(LC_ALL, ""))
34 printf("Couldn't set locale from environment.\n");
35 bindtextdomain(PACKAGE, LOCALEDIR);
36 bind_textdomain_codeset(PACKAGE, "UTF-8");
37 textdomain(PACKAGE);
38
39 ob::Openbox openbox(argc, argv);
40 openbox.eventLoop();
41
42 if (openbox.doRestart()) {
43 const std::string &prog = openbox.restartProgram();
44 if (!prog.empty()) {
45 execl("/bin/sh", "/bin/sh", "-c", prog.c_str(), NULL);
46 perror(prog.c_str());
47 }
48
49 // fall back in case the above execlp doesn't work
50 execvp(argv[0], argv);
51 execvp(otk::basename(argv[0]).c_str(), argv);
52 }
53 }
This page took 0.034969 seconds and 4 git commands to generate.