- // fall back in case the above execlp doesn't work
- execvp(argv[0], argv);
- execvp(basename(argv[0]), argv);
-}
-
-
-void Openbox::shutdown(void) {
- BaseDisplay::shutdown();
-
- XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
-
- LinkedListIterator<BScreen> it(screenList);
- for (BScreen *s = it.current(); s; it++, s = it.current())
- s->shutdown();
-
- XSync(getXDisplay(), False);
-
- save_rc();
-}
-
-
-void Openbox::save_rc(void) {
- XrmDatabase new_openboxrc = (XrmDatabase) 0;
- char rc_string[1024];
-
- load_rc();
-
- sprintf(rc_string, "session.menuFile: %s", resource.menu_file);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.colorsPerChannel: %d",
- resource.colors_per_channel);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.titlebarLayout: %s",
- resource.titlebar_layout);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.doubleClickInterval: %lu",
- resource.double_click_interval);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.autoRaiseDelay: %lu",
- ((resource.auto_raise_delay.tv_sec * 1000) +
- (resource.auto_raise_delay.tv_usec / 1000)));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.cacheLife: %lu", resource.cache_life / 60000);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.cacheMax: %lu", resource.cache_max);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- LinkedListIterator<BScreen> it(screenList);
- for (BScreen *screen = it.current(); screen; it++, screen = it.current()) {
- int screen_number = screen->getScreenNumber();
-
-#ifdef SLIT
- char *slit_placement = (char *) 0;
-
- switch (screen->getSlitPlacement()) {
- case Slit::TopLeft: slit_placement = "TopLeft"; break;
- case Slit::CenterLeft: slit_placement = "CenterLeft"; break;
- case Slit::BottomLeft: slit_placement = "BottomLeft"; break;
- case Slit::TopCenter: slit_placement = "TopCenter"; break;
- case Slit::BottomCenter: slit_placement = "BottomCenter"; break;
- case Slit::TopRight: slit_placement = "TopRight"; break;
- case Slit::BottomRight: slit_placement = "BottomRight"; break;
- case Slit::CenterRight: default: slit_placement = "CenterRight"; break;
- }
-
- sprintf(rc_string, "session.screen%d.slit.placement: %s", screen_number,
- slit_placement);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.slit.direction: %s", screen_number,
- ((screen->getSlitDirection() == Slit::Horizontal) ? "Horizontal" :
- "Vertical"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- const char *rootcmd;
- if ((rootcmd = screen->getRootCommand()) != NULL) {
- sprintf(rc_string, "session.screen%d.rootCommand: %s", screen_number,
- rootcmd);
- XrmPutLineResource(&new_openboxrc, rc_string);
- }
-
- sprintf(rc_string, "session.screen%d.slit.onTop: %s", screen_number,
- ((screen->getSlit()->isOnTop()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.slit.autoHide: %s", screen_number,
- ((screen->getSlit()->doAutoHide()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-#endif // SLIT
-
- sprintf(rc_string, "session.opaqueMove: %s",
- ((screen->doOpaqueMove()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.imageDither: %s",
- ((screen->getImageControl()->doDither()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.fullMaximization: %s", screen_number,
- ((screen->doFullMax()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.focusNewWindows: %s", screen_number,
- ((screen->doFocusNew()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.focusLastWindow: %s", screen_number,
- ((screen->doFocusLast()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s",
- screen_number,
- ((screen->getRowPlacementDirection() == BScreen::LeftRight) ?
- "LeftToRight" : "RightToLeft"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.colPlacementDirection: %s",
- screen_number,
- ((screen->getColPlacementDirection() == BScreen::TopBottom) ?
- "TopToBottom" : "BottomToTop"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- char *placement = (char *) 0;
- switch (screen->getPlacementPolicy()) {
- case BScreen::CascadePlacement:
- placement = "CascadePlacement";
- break;
-
- case BScreen::ColSmartPlacement:
- placement = "ColSmartPlacement";
- break;
-
- case BScreen::RowSmartPlacement:
- default:
- placement = "RowSmartPlacement";
- break;
- }
- sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number,
- placement);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.windowZones: %i", screen_number,
- screen->getWindowZones());
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number,
- ((screen->isSloppyFocus()) ?
- ((screen->doAutoRaise()) ? "AutoRaiseSloppyFocus" :
- "SloppyFocus") :
- "ClickToFocus"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.workspaces: %d", screen_number,
- screen->getCount());
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.toolbar.onTop: %s", screen_number,
- ((screen->getToolbar()->isOnTop()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.toolbar.autoHide: %s", screen_number,
- ((screen->getToolbar()->doAutoHide()) ? "True" : "False"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- char *toolbar_placement = (char *) 0;
-
- switch (screen->getToolbarPlacement()) {
- case Toolbar::TopLeft: toolbar_placement = "TopLeft"; break;
- case Toolbar::BottomLeft: toolbar_placement = "BottomLeft"; break;
- case Toolbar::TopCenter: toolbar_placement = "TopCenter"; break;
- case Toolbar::TopRight: toolbar_placement = "TopRight"; break;
- case Toolbar::BottomRight: toolbar_placement = "BottomRight"; break;
- case Toolbar::BottomCenter: default:
- toolbar_placement = "BottomCenter"; break;
- }
-
- sprintf(rc_string, "session.screen%d.toolbar.placement: %s", screen_number,
- toolbar_placement);
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- load_rc(screen);
-
- // these are static, but may not be saved in the users .openbox/rc,
- // writing these resources will allow the user to edit them at a later
- // time... but loading the defaults before saving allows us to rewrite the
- // users changes...
-
-#ifdef HAVE_STRFTIME
- sprintf(rc_string, "session.screen%d.strftimeFormat: %s", screen_number,
- screen->getStrftimeFormat());
- XrmPutLineResource(&new_openboxrc, rc_string);
-#else // !HAVE_STRFTIME
- sprintf(rc_string, "session.screen%d.dateFormat: %s", screen_number,
- ((screen->getDateFormat() == B_EuropeanDate) ?
- "European" : "American"));
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.clockFormat: %d", screen_number,
- ((screen->isClock24Hour()) ? 24 : 12));
- XrmPutLineResource(&new_openboxrc, rc_string);
-#endif // HAVE_STRFTIME
-
- sprintf(rc_string, "session.screen%d.edgeSnapThreshold: %d", screen_number,
- screen->getEdgeSnapThreshold());
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- sprintf(rc_string, "session.screen%d.toolbar.widthPercent: %d",
- screen_number, screen->getToolbarWidthPercent());
- XrmPutLineResource(&new_openboxrc, rc_string);
-
- // write out the users workspace names
- int i, len = 0;
- for (i = 0; i < screen->getCount(); i++)
- len += strlen((screen->getWorkspace(i)->getName()) ?
- screen->getWorkspace(i)->getName() : "Null") + 1;
-
- char *resource_string = new char[len + 1024],
- *save_string = new char[len], *save_string_pos = save_string,
- *name_string_pos;
- if (save_string) {
- for (i = 0; i < screen->getCount(); i++) {
- len = strlen((screen->getWorkspace(i)->getName()) ?
- screen->getWorkspace(i)->getName() : "Null") + 1;
- name_string_pos =
- (char *) ((screen->getWorkspace(i)->getName()) ?
- screen->getWorkspace(i)->getName() : "Null");
-
- while (--len) *(save_string_pos++) = *(name_string_pos++);
- *(save_string_pos++) = ',';
- }
- }
-
- *(--save_string_pos) = '\0';
-
- sprintf(resource_string, "session.screen%d.workspaceNames: %s",
- screen_number, save_string);
- XrmPutLineResource(&new_openboxrc, resource_string);