From: Dana Jansens Date: Tue, 24 Dec 2002 23:57:59 +0000 (+0000) Subject: rm the old guile stuff. let the user specify the path for the startup script. dont... X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=053bb2d100c3db55a68a09f25ba96e6b1a149a96;p=chaz%2Fopenbox rm the old guile stuff. let the user specify the path for the startup script. dont hardcode it to my home dir. --- diff --git a/src/openbox.cc b/src/openbox.cc index ca631d82..75d56041 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -42,10 +42,6 @@ extern "C" { # include #endif // HAVE_SYS_SELECT_H -//#include - -//extern void SWIG_init(); - #include // The initializer in openbox_wrap.cc @@ -100,6 +96,7 @@ Openbox::Openbox(int argc, char **argv) _argv0 = argv[0]; _doshutdown = false; _rcfilepath = otk::expandTilde("~/.openbox/rc3"); + _scriptfilepath = otk::expandTilde("~/.openbox/user.py"); parseCommandLine(argc, argv); @@ -146,6 +143,22 @@ Openbox::Openbox(int argc, char **argv) _cursors.ul_angle = XCreateFontCursor(otk::OBDisplay::display, XC_ul_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 OBScreen *screen; screen = new OBScreen(0, _config); @@ -161,36 +174,6 @@ Openbox::Openbox(int argc, char **argv) ::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 } @@ -228,6 +211,11 @@ void Openbox::parseCommandLine(int argc, char **argv) err = true; else _menufilepath = argv[i]; + } else if (arg == "-script") { + if (++i >= argc) + err = true; + else + _scriptfilepath = argv[i]; } else if (arg == "-version") { showVersion(); ::exit(0); @@ -262,6 +250,7 @@ void Openbox::showHelp() -display use display connection.\n\ -rc use alternate resource file.\n\ -menu use alternate menu file.\n\ + -script use alternate startup script file.\n\ -version display version and exit.\n\ -help display this help text and exit.\n\n"), _argv0); diff --git a/src/openbox.hh b/src/openbox.hh index b632cecf..40eb1804 100644 --- a/src/openbox.hh +++ b/src/openbox.hh @@ -87,6 +87,11 @@ private: Defaults to $(HOME)/.openbox/menu3 */ 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 char *_displayreq; //! The value of argv[0], i.e. how this application was executed