From a3c69f66110df1d2c254a363dcb68c370284519b Mon Sep 17 00:00:00 2001 From: rathnor Date: Thu, 10 Jul 2003 13:23:09 +0000 Subject: add [startup] to remember --- ChangeLog | 7 ++++++ RoadMap | 2 +- src/Remember.cc | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/Remember.hh | 7 +++++- 4 files changed, 87 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07bf2d5..6b7af00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ (Format: Year/Month/Day) Changes for 0.9.4: *03/07/10: + * Add [startup] to Remember (Simon) + Can now add entries to apps file like: + [startup] {xterm} + Then "xterm" will be launched on fluxbox startup. + Can also give a screen option: + [startup] (screen=1) {xterm} + will start it on screen 1 rather than the default 0. * Added new shape theme items (Henrik) * toolbar.shape: this will make the toolbar shape the corners that are towards center of the screen diff --git a/RoadMap b/RoadMap index d817512..9e8c49a 100644 --- a/RoadMap +++ b/RoadMap @@ -139,7 +139,7 @@ Key Features: * Improved screen object placement (Henrik) (will fix Maximize over slit/toolbar) Other Minor Features: - - Add some sort of program launch function (Simon) + * Add some sort of program launch function (Simon) - nls code - layers, remember, new stuff... (Both) Bugfixes/lower priority: * Titlebar sometimes doesn't redraw properly diff --git a/src/Remember.cc b/src/Remember.cc index 0b4b248..883d00e 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -21,7 +21,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Remember.cc,v 1.26 2003/07/04 14:06:20 rathnor Exp $ +// $Id: Remember.cc,v 1.27 2003/07/10 13:23:09 rathnor Exp $ #include "Remember.hh" #include "ClientPattern.hh" @@ -32,6 +32,7 @@ #include "FbMenu.hh" #include "MenuItem.hh" #include "App.hh" +#include "FbCommands.hh" #include @@ -127,8 +128,63 @@ FbTk::Menu *createRememberMenu(Remember &remember, FluxboxWindow &win) { return menu; }; +// offset is the offset in the string that we start looking from +// return true if all ok, false on error +bool handleStartupItem(string line, int offset) { + int next = 0; + string str; + int screen = 0; + + // accept some options, for now only "screen=NN" + // these option are given in parentheses before the command + next = FbTk::StringUtil::getStringBetween(str, + line.c_str() + offset, + '(', ')'); + if (next > 0) { + // there are some options + string option; + int pos = str.find('='); + bool error = false; + if (pos > 0) { + option = str.substr(0, pos); + if (option == "screen") { + istringstream iss(str.c_str() + pos + 1); + iss >> screen; + } else { + error = true; + } + } else { + error = true; + } + if (error) { + cerr<<"Error parsing startup options."<execute(); + delete tmp_exec_cmd; + return true; + } +}; + }; // end anonymous namespace + Application::Application(bool grouped) : is_grouped(grouped), group(0) @@ -350,6 +406,12 @@ void Remember::load() { } else { grouped_pats.push_back(pat); } + } else if (pos > 0 && key == "startup") { + if (!handleStartupItem(line, pos)) { + cerr<<"Error reading apps file at line "< 0 && key == "group") { in_group = true; } else if (in_group) { @@ -389,6 +451,14 @@ void Remember::save() { string apps_string; Fluxbox::instance()->getDefaultDataFilename("apps", apps_string); ofstream apps_file(apps_string.c_str()); + + // first of all we output all the startup commands + Startups::iterator sit = m_startups.begin(); + Startups::iterator sit_end = m_startups.end(); + for (; sit != sit_end; ++sit) { + apps_file<<"[startup] "<<(*sit)<second->group == a.group) { + if (git->second == &a) { apps_file << " [app]"<first->toString()< Clients; + // we have to remember any startups we did so that they are saved again + typedef std::list Startups; + Remember(); ~Remember(); @@ -196,6 +199,8 @@ private: Patterns m_pats; Clients m_clients; + Startups m_startups; + }; #endif // REMEMBER_HH -- cgit v0.11.2