]> Dogcows Code - chaz/openbox/blob - src/main.cc
rename, remove bullshit. ya
[chaz/openbox] / src / main.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // main.cc for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #include "../version.h"
25
26 #ifdef HAVE_CONFIG_H
27 # include "../config.h"
28 #endif // HAVE_CONFIG_H
29
30 extern "C" {
31 #ifdef HAVE_STDIO_H
32 # include <stdio.h>
33 #endif // HAVE_STDIO_H
34
35 #ifdef HAVE_STDLIB_H
36 # include <stdlib.h>
37 #endif // HAVE_STDLIB_H
38
39 #ifdef HAVE_STRING_H
40 # include <string.h>
41 #endif // HAVE_STRING_H
42
43 #ifdef HAVE_UNISTD_H
44 #include <sys/types.h>
45 #endif // HAVE_UNISTD_H
46
47 #ifdef HAVE_SYS_PARAM_H
48 # include <sys/param.h>
49 #endif // HAVE_SYS_PARAM_H
50 }
51
52 #include <string>
53 using std::string;
54
55 #include "blackbox.hh"
56
57
58 I18n i18n; // initialized in main
59
60 static void showHelp(int exitval) {
61 // print program usage and command line options
62 printf(i18n(mainSet, mainUsage,
63 "Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
64 " 2001 - 2002 Sean 'Shaleh' Perry\n"
65 " 1997 - 2000, 2002 Brad Hughes\n\n"
66 " -display <string>\t\tuse display connection.\n"
67 " -rc <string>\t\t\tuse alternate resource file.\n"
68 " -menu <string>\t\tuse alternate menu file.\n"
69 " -version\t\t\tdisplay version and exit.\n"
70 " -help\t\t\t\tdisplay this help text and exit.\n\n"),
71 OPENBOX_VERSION);
72
73 // some people have requested that we print out compile options
74 // as well
75 printf(i18n(mainSet, mainCompileOptions,
76 "Compile time options:\n"
77 " Debugging:\t\t\t%s\n"
78 " Shape:\t\t\t%s\n"
79 " Xft:\t\t\t\t%s\n"
80 " Xinerama:\t\t\t%s\n"
81 " 8bpp Ordered Dithering:\t%s\n\n"),
82 #ifdef DEBUG
83 i18n(CommonSet, CommonYes, "yes"),
84 #else // !DEBUG
85 i18n(CommonSet, CommonNo, "no"),
86 #endif // DEBUG
87
88 #ifdef SHAPE
89 i18n(CommonSet, CommonYes, "yes"),
90 #else // !SHAPE
91 i18n(CommonSet, CommonNo, "no"),
92 #endif // SHAPE
93
94 #ifdef XFT
95 i18n(CommonSet, CommonYes, "yes"),
96 #else // !XFT
97 i18n(CommonSet, CommonNo, "no"),
98 #endif // XFT
99
100 #ifdef XINERAMA
101 i18n(CommonSet, CommonYes, "yes"),
102 #else // !XINERAMA
103 i18n(CommonSet, CommonNo, "no"),
104 #endif // XINERAMA
105
106 #ifdef ORDEREDPSEUDO
107 i18n(CommonSet, CommonYes, "yes")
108 #else // !ORDEREDPSEUDO
109 i18n(CommonSet, CommonNo, "no")
110 #endif // ORDEREDPSEUDO
111 );
112
113 ::exit(exitval);
114 }
115
116 int main(int argc, char **argv) {
117 char *session_display = (char *) 0;
118 char *rc_file = (char *) 0;
119 char *menu_file = (char *) 0;
120
121 i18n.openCatalog("openbox.cat");
122
123 for (int i = 1; i < argc; ++i) {
124 if (! strcmp(argv[i], "-rc")) {
125 // look for alternative rc file to use
126
127 if ((++i) >= argc) {
128 fprintf(stderr,
129 i18n(mainSet, mainRCRequiresArg,
130 "error: '-rc' requires and argument\n"));
131
132 ::exit(1);
133 }
134
135 rc_file = argv[i];
136 } else if (! strcmp(argv[i], "-menu")) {
137 // look for alternative menu file to use
138
139 if ((++i) >= argc) {
140 fprintf(stderr,
141 i18n(mainSet, mainMENURequiresArg,
142 "error: '-menu' requires and argument\n"));
143
144 ::exit(1);
145 }
146
147 menu_file = argv[i];
148 } else if (! strcmp(argv[i], "-display")) {
149 // check for -display option... to run on a display other than the one
150 // set by the environment variable DISPLAY
151
152 if ((++i) >= argc) {
153 fprintf(stderr,
154 i18n(mainSet, mainDISPLAYRequiresArg,
155 "error: '-display' requires an argument\n"));
156
157 ::exit(1);
158 }
159
160 session_display = argv[i];
161 string dtmp = "DISPLAY=";
162 dtmp += session_display;
163
164 if (putenv(const_cast<char*>(dtmp.c_str()))) {
165 fprintf(stderr, i18n(mainSet, mainWarnDisplaySet,
166 "warning: couldn't set environment variable 'DISPLAY'\n"));
167 perror("putenv()");
168 }
169 } else if (! strcmp(argv[i], "-version")) {
170 // print current version string
171 printf("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
172 " 2001 - 2002 Sean 'Shaleh' Perry\n"
173 " 1997 - 2000, 2002 Brad Hughes\n\n",
174 OPENBOX_VERSION);
175
176 ::exit(0);
177 } else if (! strcmp(argv[i], "-help")) {
178 showHelp(0);
179 } else { // invalid command line option
180 showHelp(-1);
181 }
182 }
183
184 #ifdef __EMX__
185 _chdir2(getenv("X11ROOT"));
186 #endif // __EMX__
187
188 Blackbox blackbox(argv, session_display, rc_file, menu_file);
189 blackbox.eventLoop();
190
191 return(0);
192 }
This page took 0.050594 seconds and 5 git commands to generate.