rm the old guile stuff. let the user specify the path for the startup script. dont hardcode it to my home dir.

This commit is contained in:
Dana Jansens 2002-12-24 23:57:59 +00:00
parent 70aa4b20d9
commit 053bb2d100
2 changed files with 28 additions and 34 deletions

View file

@ -42,10 +42,6 @@ extern "C" {
# include <sys/select.h> # include <sys/select.h>
#endif // HAVE_SYS_SELECT_H #endif // HAVE_SYS_SELECT_H
//#include <guile/gh.h>
//extern void SWIG_init();
#include <Python.h> #include <Python.h>
// The initializer in openbox_wrap.cc // The initializer in openbox_wrap.cc
@ -100,6 +96,7 @@ Openbox::Openbox(int argc, char **argv)
_argv0 = argv[0]; _argv0 = argv[0];
_doshutdown = false; _doshutdown = false;
_rcfilepath = otk::expandTilde("~/.openbox/rc3"); _rcfilepath = otk::expandTilde("~/.openbox/rc3");
_scriptfilepath = otk::expandTilde("~/.openbox/user.py");
parseCommandLine(argc, argv); parseCommandLine(argc, argv);
@ -146,6 +143,22 @@ Openbox::Openbox(int argc, char **argv)
_cursors.ul_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ul_angle); _cursors.ul_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ul_angle);
_cursors.ur_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ur_angle); _cursors.ur_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ur_angle);
// start up python and run the user's startup script
Py_SetProgramName(argv[0]);
Py_Initialize();
init_otk();
init_openbox();
// i wish...
//PyRun_String("from _otk import *; from _openbox import *;", Py_file_input,
// Py_None, Py_None);
FILE *rcpyfd = fopen(_scriptfilepath.c_str(), "r");
if (!rcpyfd) {
printf("failed to load python file %s\n", _scriptfilepath.c_str());
} else {
PyRun_SimpleFile(rcpyfd, _scriptfilepath.c_str());
fclose(rcpyfd);
}
// initialize all the screens // initialize all the screens
OBScreen *screen; OBScreen *screen;
screen = new OBScreen(0, _config); screen = new OBScreen(0, _config);
@ -161,36 +174,6 @@ Openbox::Openbox(int argc, char **argv)
::exit(1); ::exit(1);
} }
/*
// make our guile interfaces exist
SWIG_init();
// run the guile of d3th
FILE *rcpyfd = fopen("/home/natas/.openbox/user.scm", "r");
if (!rcpyfd) {
printf("failed to load guile script /home/natas/.openbox/user.scm\n");
} else {
fclose(rcpyfd);
gh_load("/home/natas/.openbox/user.scm");
}
*/
Py_SetProgramName(argv[0]);
Py_Initialize();
init_otk();
init_openbox();
// i wish...
//PyRun_String("from _otk import *; from _openbox import *;", Py_file_input,
// Py_None, Py_None);
FILE *rcpyfd = fopen("/home/natas/.openbox/user.py", "r");
if (!rcpyfd) {
printf("failed to load python file /home/natas/.openbox/user.py\n");
} else {
PyRun_SimpleFile(rcpyfd, "/home/natas/.openbox/user.py");
fclose(rcpyfd);
}
_state = State_Normal; // done starting _state = State_Normal; // done starting
} }
@ -228,6 +211,11 @@ void Openbox::parseCommandLine(int argc, char **argv)
err = true; err = true;
else else
_menufilepath = argv[i]; _menufilepath = argv[i];
} else if (arg == "-script") {
if (++i >= argc)
err = true;
else
_scriptfilepath = argv[i];
} else if (arg == "-version") { } else if (arg == "-version") {
showVersion(); showVersion();
::exit(0); ::exit(0);
@ -262,6 +250,7 @@ void Openbox::showHelp()
-display <string> use display connection.\n\ -display <string> use display connection.\n\
-rc <string> use alternate resource file.\n\ -rc <string> use alternate resource file.\n\
-menu <string> use alternate menu file.\n\ -menu <string> use alternate menu file.\n\
-script <string> use alternate startup script file.\n\
-version display version and exit.\n\ -version display version and exit.\n\
-help display this help text and exit.\n\n"), _argv0); -help display this help text and exit.\n\n"), _argv0);

View file

@ -87,6 +87,11 @@ private:
Defaults to $(HOME)/.openbox/menu3 Defaults to $(HOME)/.openbox/menu3
*/ */
std::string _menufilepath; std::string _menufilepath;
//! Path to the script file to execute on startup
/*!
Defaults to $(HOME)/.openbox/user.py
*/
std::string _scriptfilepath;
//! The display requested by the user, or null to use the DISPLAY env var //! The display requested by the user, or null to use the DISPLAY env var
char *_displayreq; char *_displayreq;
//! The value of argv[0], i.e. how this application was executed //! The value of argv[0], i.e. how this application was executed