summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/openbox.cc57
-rw-r--r--src/openbox.hh5
2 files changed, 28 insertions, 34 deletions
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 <sys/select.h>
#endif // HAVE_SYS_SELECT_H
-//#include <guile/gh.h>
-
-//extern void SWIG_init();
-
#include <Python.h>
// 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 <string> use display connection.\n\
-rc <string> use alternate resource file.\n\
-menu <string> use alternate menu file.\n\
+ -script <string> 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