provide capabilities to execute a command

This commit is contained in:
Dana Jansens 2003-01-03 16:06:10 +00:00
parent a4a8d09f4b
commit 105bd729e8
3 changed files with 53 additions and 0 deletions

View file

@ -326,5 +326,26 @@ void Openbox::setFocusedClient(OBClient *c)
} }
} }
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__
}
} }

View file

@ -240,6 +240,9 @@ public:
manager can be destroyed. manager can be destroyed.
*/ */
inline void shutdown() { _doshutdown = true; } inline void shutdown() { _doshutdown = true; }
//! Executes a command on a screen
void execute(int screen, const std::string &bin);
}; };
} }

View file

@ -1309,6 +1309,34 @@ static PyObject *_wrap_Openbox_shutdown(PyObject *self, PyObject *args) {
} }
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) { static PyObject * Openbox_swigregister(PyObject *self, PyObject *args) {
PyObject *obj; PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
@ -2604,6 +2632,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Openbox_setFocusedClient", _wrap_Openbox_setFocusedClient, METH_VARARGS }, { (char *)"Openbox_setFocusedClient", _wrap_Openbox_setFocusedClient, METH_VARARGS },
{ (char *)"Openbox_focusedScreen", _wrap_Openbox_focusedScreen, METH_VARARGS }, { (char *)"Openbox_focusedScreen", _wrap_Openbox_focusedScreen, METH_VARARGS },
{ (char *)"Openbox_shutdown", _wrap_Openbox_shutdown, 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 *)"Openbox_swigregister", Openbox_swigregister, METH_VARARGS },
{ (char *)"OBScreen_client", _wrap_OBScreen_client, METH_VARARGS }, { (char *)"OBScreen_client", _wrap_OBScreen_client, METH_VARARGS },
{ (char *)"OBScreen_clientCount", _wrap_OBScreen_clientCount, METH_VARARGS }, { (char *)"OBScreen_clientCount", _wrap_OBScreen_clientCount, METH_VARARGS },