summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakir <akir>2004-10-06 11:40:28 (GMT)
committerakir <akir>2004-10-06 11:40:28 (GMT)
commit6f96757fc4e9ed3aa7d77681b8401521a1a681a9 (patch)
tree34550002f4659dcafef7749a444eae321e8ccb6a
parent997d7d72244911c7224775f2e4c0f62a1dcd32ef (diff)
downloadfluxbox_lack-6f96757fc4e9ed3aa7d77681b8401521a1a681a9.zip
fluxbox_lack-6f96757fc4e9ed3aa7d77681b8401521a1a681a9.tar.bz2
added :Export / :Setenv command
-rw-r--r--src/FbCommandFactory.cc19
-rw-r--r--src/FbCommands.cc11
-rw-r--r--src/FbCommands.hh12
3 files changed, 38 insertions, 4 deletions
diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc
index 7dc7fc8..4e6adf9 100644
--- a/src/FbCommandFactory.cc
+++ b/src/FbCommandFactory.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: FbCommandFactory.cc,v 1.35 2004/09/16 14:58:28 rathnor Exp $ 23// $Id: FbCommandFactory.cc,v 1.36 2004/10/06 11:40:28 akir Exp $
24 24
25#include "FbCommandFactory.hh" 25#include "FbCommandFactory.hh"
26 26
@@ -66,6 +66,7 @@ FbCommandFactory::FbCommandFactory() {
66 "commanddialog", 66 "commanddialog",
67 "deiconify", 67 "deiconify",
68 "detachclient", 68 "detachclient",
69 "export",
69 "exec", 70 "exec",
70 "execcommand", 71 "execcommand",
71 "execute", 72 "execute",
@@ -116,6 +117,7 @@ FbCommandFactory::FbCommandFactory() {
116 "rightworkspace", 117 "rightworkspace",
117 "rootmenu", 118 "rootmenu",
118 "saverc", 119 "saverc",
120 "setenv",
119 "sendtoworkspace", 121 "sendtoworkspace",
120 "sendtonextworkspace", 122 "sendtonextworkspace",
121 "sendtoprevworkspace", 123 "sendtoprevworkspace",
@@ -176,8 +178,21 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
176 return new SaveResources(); 178 return new SaveResources();
177 else if (command == "execcommand" || command == "execute" || command == "exec") 179 else if (command == "execcommand" || command == "execute" || command == "exec")
178 return new ExecuteCmd(arguments); // execute command on key screen 180 return new ExecuteCmd(arguments); // execute command on key screen
179 else if (command == "exit") 181 else if (command == "exit")
180 return new ExitFluxboxCmd(); 182 return new ExitFluxboxCmd();
183 else if (command == "setenv" || command == "export") {
184
185 std::string name = arguments;
186 FbTk::StringUtil::removeFirstWhitespace(name);
187 FbTk::StringUtil::removeTrailingWhitespace(name);
188 size_t pos = name.find_first_of(command == "setenv" ? " \t" : "=");
189 if (pos == std::string::npos || pos == name.size())
190 return 0;
191
192 std::string value = name.substr(pos + 1);
193 name = name.substr(0, pos);
194 return new ExportCmd(name, value);
195 }
181 else if (command == "quit") 196 else if (command == "quit")
182 return new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(), &Fluxbox::shutdown); 197 return new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(), &Fluxbox::shutdown);
183 else if (command == "commanddialog") // run specified fluxbox command 198 else if (command == "commanddialog") // run specified fluxbox command
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index 6a9c548..b57534c 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbCommands.cc,v 1.27 2004/09/11 20:28:35 fluxgen Exp $ 22// $Id: FbCommands.cc,v 1.28 2004/10/06 11:40:28 akir Exp $
23 23
24#include "FbCommands.hh" 24#include "FbCommands.hh"
25#include "fluxbox.hh" 25#include "fluxbox.hh"
@@ -123,6 +123,15 @@ void ExecuteCmd::execute() {
123 123
124} 124}
125 125
126ExportCmd::ExportCmd(const std::string& name, const std::string& value) :
127 m_name(name), m_value(value) {
128}
129
130void ExportCmd::execute() {
131 setenv(m_name.c_str(), m_value.c_str(), 1);
132}
133
134
126void ExitFluxboxCmd::execute() { 135void ExitFluxboxCmd::execute() {
127 Fluxbox::instance()->shutdown(); 136 Fluxbox::instance()->shutdown();
128} 137}
diff --git a/src/FbCommands.hh b/src/FbCommands.hh
index bc67610..46b3465 100644
--- a/src/FbCommands.hh
+++ b/src/FbCommands.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbCommands.hh,v 1.19 2004/04/22 21:12:33 fluxgen Exp $ 22// $Id: FbCommands.hh,v 1.20 2004/10/06 11:40:28 akir Exp $
23 23
24// \file contains basic commands to restart, reconfigure, execute command and exit fluxbox 24// \file contains basic commands to restart, reconfigure, execute command and exit fluxbox
25 25
@@ -42,6 +42,16 @@ private:
42 const int m_screen_num; 42 const int m_screen_num;
43}; 43};
44 44
45/// sets environment
46class ExportCmd : public FbTk::Command {
47public:
48 ExportCmd(const std::string& name, const std::string& value);
49 void execute();
50private:
51 std::string m_name;
52 std::string m_value;
53};
54
45/// exit fluxbox 55/// exit fluxbox
46class ExitFluxboxCmd: public FbTk::Command { 56class ExitFluxboxCmd: public FbTk::Command {
47public: 57public: