]> Dogcows Code - chaz/openbox/commitdiff
provide capabilities to execute a command
authorDana Jansens <danakj@orodu.net>
Fri, 3 Jan 2003 16:06:10 +0000 (16:06 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 3 Jan 2003 16:06:10 +0000 (16:06 +0000)
src/openbox.cc
src/openbox.hh
src/openbox_wrap.cc

index 655fe0d53bd7a3d0e43fbd7d8b5b90885d3b7a67..4d2f102479c266d781d580d2d24f9fb657e440cd 100644 (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__
+}
+
 }
 
index 1a537dcd7dfc1c387a9f18bb8d815e192bf4c97f..a141ae2b3f5ba1603a5678bfb8357bc3a7b0abeb 100644 (file)
@@ -240,6 +240,9 @@ public:
     manager can be destroyed.
   */
   inline void shutdown() { _doshutdown = true; }
+
+  //! Executes a command on a screen
+  void execute(int screen, const std::string &bin);
 };
 
 }
index 90cd3a97b35a8c38c2b43fe4ee3e1cc76c2822b8..bbdbaa8608ae8089086233191872a306557fd79e 100644 (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) {
     PyObject *obj;
     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_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 },
This page took 0.037274 seconds and 4 git commands to generate.