fix for multi-head DISPLAY problem
[bbkeys.git] / src / main.cc
blobc278ab275e1e16b8836bd99bdbd3d504426f56ec
1 // Basewindow.cc for bbtools.
2 //
3 // Copyright (c) 1998-1999 by John Kennis, jkennis@chello.nl
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 // (See the included file COPYING / GPL-2.0)
21 // $Id$
23 #include "bbkeys.hh"
24 #include "main.hh"
26 void Usage()
28 fprintf(stderr, "\n%s version %s \n", BBTOOL, BBTOOL_VERSION);
29 fprintf(stderr, "Usage: %s [options]\n", BBTOOL);
30 fprintf(stderr, "Options:\n"
31 " -display <display name> X server to connect to\n"
32 " -c[onfig] <filename> Alternate 'look and feel' config file\n"
33 " -rc[file] <filename> Alternate keygrab definition file. \n"
34 " (default is ~/.bbkeysrc)\n"
35 " -n[obb] Fall back on default configuration\n"
36 " -v[ersion] Display version number\n"
37 " -h[elp] Display this help\n"
38 " -geom[etry] <geometry> Set geometry of window\n"
39 " -d[ecorated] Show 'normal' decorated window\n"
40 " -w[ithdrawn] Place bbtool in the Slit\n"
41 " -i[conic] Start bbkeys in a minimized state\n"
42 " (will override -withdrawn directive)\n"
43 " -s[hape] Don't display groundplate\n"
44 " -no[qt] Use non-qt configuration tool.\n"
45 " -m[iniMe] Like Austin Powers 2. bbkeys, but smaller.\n"
46 " -t[inyMe] All you can see is his keyhole *sniff*.\n\n");
50 int main(int argc, char **argv)
52 int i;
53 struct CMDOPTIONS options;
54 options.display_name = NULL;
55 options.geometry = NULL;
56 options.withdrawn = False;
57 options.iconic = False;
58 options.shape = False;
59 options.config_file = NULL;
60 options.nobb_config = False;
61 options.decorated = False;
62 options.noQt = False;
63 options.miniMe = False;
64 options.tinyMe = False;
65 options.bbkeysrc = NULL;
67 for (i = 1; i < argc; i++) {
68 if ((!strcmp(argv[i], "-display"))) {
69 if (++i == argc) {
70 Usage();
71 exit(2);
73 options.display_name = argv[i];
75 // Applications we exec will need the proper display
76 setenv("DISPLAY", options.display_name,true);
78 } else if ((!strcmp(argv[i], "-config")) |
79 (!strcmp(argv[i], "-c"))) {
80 if (++i == argc) {
81 Usage();
82 exit(2);
84 options.config_file = argv[i];
85 } else if((!strcmp(argv[1], "-rcfile"))||
86 (!strcmp(argv[i], "-rc"))){
87 if(++i == argc){
88 Usage();
89 exit(2);
91 options.bbkeysrc=argv[i];
92 } else if ((!strcmp(argv[i], "-nobb")) || (!strcmp(argv[i], "-n"))) {
93 options.nobb_config = True;
94 } else if ((!strcmp(argv[i], "-v"))
95 || (!strcmp(argv[i], "-version"))) {
96 fprintf(stderr, " %s version %s\n", BBTOOL, BBTOOL_VERSION);
97 exit(2);
98 } else if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help"))) {
99 Usage();
100 exit(2);
101 } else if ((!strcmp(argv[i], "-geometry"))
102 || (!strcmp(argv[i], "-geom"))) {
103 if (++i == argc) {
104 Usage();
105 exit(2);
107 options.geometry = argv[i];
108 } else if ((!strcmp(argv[i], "-withdrawn"))
109 || (!strcmp(argv[i], "-w"))) {
110 options.withdrawn = True;
111 } else if ((!strcmp(argv[i], "-iconic"))
112 || (!strcmp(argv[i], "-i"))) {
113 options.iconic = True;
114 } else if ((!strcmp(argv[i], "-shape"))
115 || (!strcmp(argv[i], "-s"))) {
116 options.shape = True;
117 } else if ((!strcmp(argv[i], "-decorated"))
118 || (!strcmp(argv[i], "-d"))) {
119 options.decorated = True;
120 } else if ((!strcmp(argv[i], "-noqt"))
121 || (!strcmp(argv[i], "-no"))) {
122 options.noQt = True;
123 } else if ((!strcmp(argv[i], "-miniMe"))
124 || (!strcmp(argv[i], "-m"))) {
125 options.miniMe = True;
126 options.tinyMe = False;
127 } else if ((!strcmp(argv[i], "-tinyMe"))
128 || (!strcmp(argv[i], "-t"))) {
129 options.tinyMe = True;
130 options.miniMe = False;
131 } else {
132 Usage();
133 exit(2);
137 if (options.iconic) {
138 options.withdrawn = False;
141 ToolWindow bbkeys(argc, argv, &options);