2002-05-25 00:29:44 +00:00
|
|
|
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
extern "C" {
|
2002-04-11 03:20:38 +00:00
|
|
|
#ifdef HAVE_STDIO_H
|
|
|
|
# include <stdio.h>
|
|
|
|
#endif // HAVE_STDIO_H
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#ifdef HAVE_STDLIB_H
|
2002-04-11 03:20:38 +00:00
|
|
|
# include <stdlib.h>
|
2002-04-16 06:25:00 +00:00
|
|
|
#endif // HAVE_STDLIB_H
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
2002-04-11 03:20:38 +00:00
|
|
|
# include <string.h>
|
2002-04-16 06:25:00 +00:00
|
|
|
#endif // HAVE_STRING_H
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif // HAVE_UNISTD_H
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
# include <sys/param.h>
|
|
|
|
#endif // HAVE_SYS_PARAM_H
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-11-01 11:18:32 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
#define _(str) gettext(str)
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#include <string>
|
|
|
|
using std::string;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#include "blackbox.hh"
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
static void showHelp(int exitval) {
|
|
|
|
// print program usage and command line options
|
2002-11-01 11:18:32 +00:00
|
|
|
printf(_("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"),
|
2002-08-22 03:53:17 +00:00
|
|
|
OPENBOX_VERSION);
|
2002-11-01 11:18:32 +00:00
|
|
|
printf(_(" -display <string> use display connection.\n\
|
|
|
|
-rc <string> use alternate resource file.\n\
|
|
|
|
-menu <string> use alternate menu file.\n\
|
|
|
|
-version display version and exit.\n\
|
|
|
|
-help display this help text and exit.\n\n"));
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
// some people have requested that we print out compile options
|
|
|
|
// as well
|
2002-11-01 11:18:32 +00:00
|
|
|
printf(_("Compile time options:\n\
|
|
|
|
Debugging:\t\t\t%s\n\
|
|
|
|
Shape:\t\t\t%s\n\
|
|
|
|
Xft:\t\t\t\t%s\n\
|
|
|
|
Xinerama:\t\t\t%s\n\
|
|
|
|
8bpp Ordered Dithering:\t%s\n\n"),
|
2002-04-11 03:20:38 +00:00
|
|
|
#ifdef DEBUG
|
2002-11-01 11:18:32 +00:00
|
|
|
_("yes"),
|
2002-04-11 03:20:38 +00:00
|
|
|
#else // !DEBUG
|
2002-11-01 11:18:32 +00:00
|
|
|
_("no"),
|
2002-04-11 03:20:38 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
|
|
|
|
#ifdef SHAPE
|
2002-11-01 11:18:32 +00:00
|
|
|
_("yes"),
|
2002-04-11 03:20:38 +00:00
|
|
|
#else // !SHAPE
|
2002-11-01 11:18:32 +00:00
|
|
|
_("no"),
|
2002-04-11 03:20:38 +00:00
|
|
|
#endif // SHAPE
|
|
|
|
|
2002-07-21 17:58:03 +00:00
|
|
|
#ifdef XFT
|
2002-11-01 11:18:32 +00:00
|
|
|
_("yes"),
|
2002-07-21 17:58:03 +00:00
|
|
|
#else // !XFT
|
2002-11-01 11:18:32 +00:00
|
|
|
_("no"),
|
2002-07-21 17:58:03 +00:00
|
|
|
#endif // XFT
|
|
|
|
|
|
|
|
#ifdef XINERAMA
|
2002-11-01 11:18:32 +00:00
|
|
|
_("yes"),
|
2002-07-21 17:58:03 +00:00
|
|
|
#else // !XINERAMA
|
2002-11-01 11:18:32 +00:00
|
|
|
_("no"),
|
2002-07-21 17:58:03 +00:00
|
|
|
#endif // XINERAMA
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
#ifdef ORDEREDPSEUDO
|
2002-11-01 11:18:32 +00:00
|
|
|
_("yes")
|
2002-04-11 03:20:38 +00:00
|
|
|
#else // !ORDEREDPSEUDO
|
2002-11-01 11:18:32 +00:00
|
|
|
_("no")
|
2002-04-11 03:20:38 +00:00
|
|
|
#endif // ORDEREDPSEUDO
|
2002-05-25 00:29:44 +00:00
|
|
|
);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
::exit(exitval);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
char *session_display = (char *) 0;
|
|
|
|
char *rc_file = (char *) 0;
|
2002-05-25 02:24:30 +00:00
|
|
|
char *menu_file = (char *) 0;
|
2002-05-25 00:29:44 +00:00
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
if (! strcmp(argv[i], "-rc")) {
|
|
|
|
// look for alternative rc file to use
|
|
|
|
|
|
|
|
if ((++i) >= argc) {
|
2002-11-01 11:18:32 +00:00
|
|
|
fprintf(stderr, _("error: '-rc' requires and argument\n"));
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
::exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc_file = argv[i];
|
2002-05-25 02:24:30 +00:00
|
|
|
} else if (! strcmp(argv[i], "-menu")) {
|
|
|
|
// look for alternative menu file to use
|
|
|
|
|
|
|
|
if ((++i) >= argc) {
|
2002-11-01 11:18:32 +00:00
|
|
|
fprintf(stderr, _("error: '-menu' requires and argument\n"));
|
2002-05-25 02:24:30 +00:00
|
|
|
|
|
|
|
::exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu_file = argv[i];
|
2002-04-11 03:20:38 +00:00
|
|
|
} else if (! strcmp(argv[i], "-display")) {
|
|
|
|
// check for -display option... to run on a display other than the one
|
|
|
|
// set by the environment variable DISPLAY
|
|
|
|
|
|
|
|
if ((++i) >= argc) {
|
2002-11-01 11:18:32 +00:00
|
|
|
fprintf(stderr, _("error: '-display' requires an argument\n"));
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-16 22:35:59 +00:00
|
|
|
::exit(1);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
session_display = argv[i];
|
2002-05-25 00:29:44 +00:00
|
|
|
string dtmp = "DISPLAY=";
|
|
|
|
dtmp += session_display;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (putenv(const_cast<char*>(dtmp.c_str()))) {
|
2002-10-31 08:42:45 +00:00
|
|
|
fprintf(stderr,
|
2002-11-01 11:18:32 +00:00
|
|
|
_("warning: couldn't set environment variable 'DISPLAY'\n"));
|
2002-05-16 22:35:59 +00:00
|
|
|
perror("putenv()");
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
} else if (! strcmp(argv[i], "-version")) {
|
|
|
|
// print current version string
|
2002-11-01 11:18:32 +00:00
|
|
|
printf(_("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"),
|
2002-08-22 03:53:17 +00:00
|
|
|
OPENBOX_VERSION);
|
2002-11-01 11:18:32 +00:00
|
|
|
printf("\n");
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
::exit(0);
|
|
|
|
} else if (! strcmp(argv[i], "-help")) {
|
|
|
|
showHelp(0);
|
|
|
|
} else { // invalid command line option
|
|
|
|
showHelp(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __EMX__
|
|
|
|
_chdir2(getenv("X11ROOT"));
|
|
|
|
#endif // __EMX__
|
|
|
|
|
2002-10-31 08:42:45 +00:00
|
|
|
Blackbox blackbox(argv, session_display, rc_file);
|
2002-05-25 00:29:44 +00:00
|
|
|
blackbox.eventLoop();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|