all repos — openbox @ 105bd729e8341bacce630f2780f0a9a5a0102526

openbox fork - make it a bit more like ryudo

provide capabilities to execute a command
Dana Jansens danakj@orodu.net
commit

105bd729e8341bacce630f2780f0a9a5a0102526

parent

a4a8d09f4b9431d6d831cb7aa220e6c952802c95

3 files changed, 53 insertions(+), 0 deletions(-)

jump to
M src/openbox.ccsrc/openbox.cc

@@ -326,5 +326,26 @@ RevertToNone, CurrentTime);

} } +void Openbox::execute(int screen, const std::string &bin) +{ +#ifdef __EMX__ + // XXX: whats this for? windows? + spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", bin.c_str(), NULL); +#else // __EMX__ + if (screen >= ScreenCount(otk::OBDisplay::display)) + screen = 0; + const std::string &dstr = + otk::OBDisplay::screenInfo(screen)->displayString(); + + if (! fork()) { + setsid(); + int ret = putenv(const_cast<char *>(dstr.c_str())); + assert(ret != -1); + ret = execl("/bin/sh", "/bin/sh", "-c", bin.c_str(), NULL); + exit(ret); + } +#endif // __EMX__ +} + }
M src/openbox.hhsrc/openbox.hh

@@ -240,6 +240,9 @@ Causes the Openbox::eventLoop function to stop looping, so that the window

manager can be destroyed. */ inline void shutdown() { _doshutdown = true; } + + //! Executes a command on a screen + void execute(int screen, const std::string &bin); }; }
M src/openbox_wrap.ccsrc/openbox_wrap.cc

@@ -1309,6 +1309,34 @@ return NULL;

} +static PyObject *_wrap_Openbox_execute(PyObject *self, PyObject *args) { + PyObject *resultobj; + ob::Openbox *arg1 = (ob::Openbox *) 0 ; + int arg2 ; + std::string *arg3 = 0 ; + std::string temp3 ; + PyObject * obj0 = 0 ; + PyObject * obj2 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"OiO:Openbox_execute",&obj0,&arg2,&obj2)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__Openbox,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; + { + if (PyString_Check(obj2)) { + temp3 = std::string(PyString_AsString(obj2)); + arg3 = &temp3; + }else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + (arg1)->execute(arg2,(std::string const &)*arg3); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + static PyObject * Openbox_swigregister(PyObject *self, PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;

@@ -2604,6 +2632,7 @@ { (char *)"Openbox_focusedClient", _wrap_Openbox_focusedClient, METH_VARARGS },

{ (char *)"Openbox_setFocusedClient", _wrap_Openbox_setFocusedClient, METH_VARARGS }, { (char *)"Openbox_focusedScreen", _wrap_Openbox_focusedScreen, METH_VARARGS }, { (char *)"Openbox_shutdown", _wrap_Openbox_shutdown, METH_VARARGS }, + { (char *)"Openbox_execute", _wrap_Openbox_execute, METH_VARARGS }, { (char *)"Openbox_swigregister", Openbox_swigregister, METH_VARARGS }, { (char *)"OBScreen_client", _wrap_OBScreen_client, METH_VARARGS }, { (char *)"OBScreen_clientCount", _wrap_OBScreen_clientCount, METH_VARARGS },