all repos — fluxbox @ 6eae743582c8fb4d95895f82ed809762b32898c5

custom fork of the fluxbox windowmanager

added run() for ExecuteCmd, which returns pid of the child process
fluxgen fluxgen
commit

6eae743582c8fb4d95895f82ed809762b32898c5

parent

3ceb311a322081cd17b449df373d366dde2fad47

2 files changed, 37 insertions(+), 25 deletions(-)

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

@@ -113,34 +113,42 @@ }

void ExecuteCmd::execute() { #ifndef __EMX__ - if (! fork()) { - std::string displaystring("DISPLAY="); - displaystring += DisplayString(FbTk::App::instance()->display()); - char intbuff[64]; - int screen_num = m_screen_num; - if (screen_num < 0) { - if (Fluxbox::instance()->mouseScreen() == 0) - screen_num = 0; - else - screen_num = Fluxbox::instance()->mouseScreen()->screenNumber(); - } - - sprintf(intbuff, "%d", screen_num); - - // remove last number of display and add screen num - displaystring.erase(displaystring.size()-1); - displaystring += intbuff; - setsid(); - putenv(const_cast<char *>(displaystring.c_str())); - execl("/bin/sh", "/bin/sh", "-c", m_cmd.c_str(), static_cast<void*>(NULL)); - exit(0); - } + run(); #else // __EMX__ spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", m_cmd.c_str(), static_cast<void*>(NULL)); #endif // !__EMX__ } +int ExecuteCmd::run() { + pid_t pid = fork(); + if (pid) + return pid; + + std::string displaystring("DISPLAY="); + displaystring += DisplayString(FbTk::App::instance()->display()); + char intbuff[64]; + int screen_num = m_screen_num; + if (screen_num < 0) { + if (Fluxbox::instance()->mouseScreen() == 0) + screen_num = 0; + else + screen_num = Fluxbox::instance()->mouseScreen()->screenNumber(); + } + + sprintf(intbuff, "%d", screen_num); + + // remove last number of display and add screen num + displaystring.erase(displaystring.size()-1); + displaystring += intbuff; + setsid(); + putenv(const_cast<char *>(displaystring.c_str())); + execl("/bin/sh", "/bin/sh", "-c", m_cmd.c_str(), static_cast<void*>(NULL)); + exit(0); + + return pid; // compiler happy -> we are happy ;) +} + ExportCmd::ExportCmd(const std::string& name, const std::string& value) : m_name(name), m_value(value) { }

@@ -214,7 +222,7 @@ void SetStyleCmd::execute() {

Fluxbox::instance()->saveStyleFilename(m_filename.c_str()); Fluxbox::instance()->save_rc(); FbTk::ThemeManager::instance().load(m_filename, - Fluxbox::instance()->getStyleOverlayFilename()); + Fluxbox::instance()->getStyleOverlayFilename()); } void ShowRootMenuCmd::execute() {

@@ -339,7 +347,7 @@ case ALLWORKSPACE:

for(; it != itend; it++) { old_workspace_num= (*it)->workspaceNumber(); if (m_mode == ALL || old_workspace_num == workspace_num || - (*it)->isStuck()) { + (*it)->isStuck()) { if (m_dest == ORIGIN || m_dest == ORIGINQUIET) screen->sendToWorkspace(old_workspace_num, (*it), change_ws); else

@@ -354,7 +362,7 @@ default:

for (; it != itend; it++) { old_workspace_num= (*it)->workspaceNumber(); if(m_mode == LAST || old_workspace_num == workspace_num || - (*it)->isStuck()) { + (*it)->isStuck()) { if ((m_dest == ORIGIN || m_dest == ORIGINQUIET) && m_mode != LASTWORKSPACE) screen->sendToWorkspace(old_workspace_num, (*it), change_ws);
M src/FbCommands.hhsrc/FbCommands.hh

@@ -37,6 +37,10 @@ class ExecuteCmd: public FbTk::Command {

public: ExecuteCmd(const std::string &cmd, int screen_num = -1); void execute(); + /** + * same as execute but returns pid + */ + int run(); private: std::string m_cmd; const int m_screen_num;