1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // main.cc for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000, 2002 - 2005
5 // Bradley T Hughes <bhughes at trolltech.com>
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the "Software"),
9 // to deal in the Software without restriction, including without limitation
10 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 // and/or sell copies of the Software, and to permit persons to whom the
12 // Software is furnished to do so, subject to the following conditions:
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 // DEALINGS IN THE SOFTWARE.
25 // #define PRINT_SIZES
27 #if defined(PRINT_SIZES)
30 # include "Toolbar.hh"
34 #include "blackbox.hh"
35 #include "../version.h"
40 static void showHelp(int exitval
) {
41 // print version - this should not be localized!
42 printf("Blackbox %s\n"
43 "Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry\n"
44 "Copyright (c) 1997 - 2000, 2002 - 2005 Bradley T Hughes\n",
47 // print program usage and command line options
48 printf(" -display <string>\t\tuse display connection.\n"
49 " -single <string>\t\tmanage the default screen only\n"
50 " -rc <string>\t\t\tuse alternate resource file.\n"
51 " -version\t\t\tdisplay version and exit.\n"
52 " -help\t\t\t\tdisplay this help text and exit.\n\n");
54 // some people have requested that we print out compile options
56 printf("Compile time options:\n"
57 " Debugging:\t\t\t%s\n"
59 " Xft:\t\t\t\t%s\n\n",
81 int main(int argc
, char **argv
) {
82 const char *dpy_name
= 0;
84 bool multi_head
= true;
86 for (int i
= 1; i
< argc
; ++i
) {
87 if (! strcmp(argv
[i
], "-help")) {
89 } else if (! strcmp(argv
[i
], "-version")) {
90 // print current version string, this should not be localized!
91 printf("Blackbox %s\n"
92 "Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry\n"
93 "Copyright (c) 1997 - 2000, 2002 - 2005 Bradley T Hughes\n",
97 } else if (! strcmp(argv
[i
], "-rc")) {
98 // look for alternative rc file to use
101 fprintf(stderr
, "error: '-rc' requires and argument\n");
106 } else if (! strcmp(argv
[i
], "-display")) {
107 // check for -display option... to run on a display other than the one
108 // set by the environment variable DISPLAY
111 fprintf(stderr
, "error: '-display' requires an argument\n");
116 std::string dtmp
= "DISPLAY=";
119 if (putenv(const_cast<char*>(dtmp
.c_str()))) {
121 "warning: couldn't set environment variable 'DISPLAY'\n");
124 } else if (! strcmp(argv
[i
], "-single")) {
126 } else { // invalid command line option
132 _chdir2(getenv("X11ROOT"));
136 rc_file
= "~/.blackboxrc";
137 rc_file
= bt::expandTilde(rc_file
);
139 #if defined(PRINT_SIZES)
140 printf("Blackbox : %4d bytes\n"
141 "BScreen : %4d bytes\n"
142 "BlackboxWindow: %4d bytes\n"
143 "Toolbar : %4d bytes\n"
144 "Slit : %4d bytes\n",
147 sizeof(BlackboxWindow
),
152 Blackbox
blackbox(argv
, dpy_name
, rc_file
, multi_head
);