]> Dogcows Code - chaz/openbox/blob - src/main.cc
signed ints instead of unsigned ints again. less pain. pain bad.
[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 = new ob::Openbox(argc, argv);
40 openbox->eventLoop();
41
42 if (openbox->doRestart()) {
43 std::string prog = openbox->restartProgram();
44
45 delete openbox; // shutdown the current one!
46
47 if (!prog.empty()) {
48 execl("/bin/sh", "/bin/sh", "-c", prog.c_str(), NULL);
49 perror(prog.c_str());
50 }
51
52 // fall back in case the above execlp doesn't work
53 execvp(argv[0], argv);
54 execvp(otk::basename(argv[0]).c_str(), argv);
55 }
56
57 delete openbox; // shutdown
58 }
This page took 0.035287 seconds and 4 git commands to generate.