From 48a11352bc8d46724f49268c693ca9bcc8274fe6 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 26 Feb 2002 22:42:23 +0000 Subject: added setupConfigFiles, removed debug stuff and added SENDTOWORKSPACE key action --- src/fluxbox.cc | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 113 insertions(+), 8 deletions(-) diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 5690b6e..fbeb860 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.35 2002/02/20 23:12:07 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.36 2002/02/26 22:42:23 fluxgen Exp $ //Use some GNU extensions #ifndef _GNU_SOURCE @@ -315,7 +315,9 @@ key(0) singleton = this; BaseDisplay::GrabGuard gg(*this); gg.grab(); - + + setupConfigFiles(); + if (! XSupportsLocale()) fprintf(stderr, "X server does not support locale\n"); @@ -331,7 +333,7 @@ key(0) windowSearchList = new LinkedList; menuSearchList = new LinkedList; -#ifdef SLIT + #ifdef SLIT slitSearchList = new LinkedList; #ifdef KDE //For KDE dock applets @@ -339,7 +341,7 @@ key(0) kwm2_dockwindow = XInternAtom(getXDisplay(), "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False); //KDE v2.x #endif //KDE -#endif // SLIT + #endif // SLIT toolbarSearchList = new LinkedList; tabSearchList = new LinkedList; @@ -434,6 +436,109 @@ Fluxbox::~Fluxbox(void) { #endif // SLIT } +//---------- setupConfigFiles ----------- +// setup the configutation files in +// home directory +//--------------------------------------- +void Fluxbox::setupConfigFiles() { + + bool createInit, createKeys, createMenu; + createInit = createKeys = createMenu = false; + + string dirname = getenv("HOME")+string("/.")+string(RC_PATH) + "/"; + string initFile, keysFile, menuFile; + initFile = dirname+RC_INIT_FILE; + keysFile = dirname+"keys"; + menuFile = dirname+"menu"; + + struct stat buf; + + // is file/dir already there? + if (! stat(dirname.c_str(), &buf)) { + /*TODO: this + if (! (buf.st_mode & S_IFDIR)) { + cerr << dirname.c_str() << "!" << endl; + return 1; + } + */ + + // check if anything with those name exists, if not create new + if (stat(initFile.c_str(), &buf)) + createInit = true; + if (stat(keysFile.c_str(), &buf)) + createKeys = true; + if (stat(menuFile.c_str(), &buf)) + createMenu = true; + + } else { + #ifdef DEBUG + cerr <<__FILE__<<"("<<__LINE__<<"): Creating dir: " << dirname.c_str() << endl; + #endif // DEBUG + + // create directory with perm 700 + if (mkdir(dirname.c_str(), 0700)) { + cerr << "Can't create " << dirname << " directory!" << endl; + return; + } + + //mark creation of files + createInit = createKeys = createMenu = true; + } + + + // should we copy key configuraion? + if (createKeys) { + ifstream from(DEFAULTKEYSFILE); + ofstream to(keysFile.c_str()); + + if (! to.good()) { + cerr << "Can't write file" << endl; + } else if (from.good()) { + #ifdef DEBUG + cerr << "Copying file: " << DEFAULTKEYSFILE << endl; + #endif // DEBUG + to<changeWorkspaceID(key->getParam()-1); break; + case Keys::SENDTOWORKSPACE: + // Workspace1 has id 0, hence -1 + screen->sendToWorkspace(key->getParam()-1); + break; // NOTE!!! The WORKSPACEn commands are not needed anymore case Keys::WORKSPACE1: screen->changeWorkspaceID(0); -- cgit v0.11.2