unexpandTilde()

Bernhard Kepplinger bkeppl at cosy.sbg.ac.at
Tue Feb 25 08:37:20 EST 2003


Hi!

Just wrote a patch that makes openbox store the stylefilepath relative to
~ (if possible).
thus one can use the same rc file in different home directories (/home/gcc4fun
at home and /home/stud1/bkeppl at universitiy) without loosing the current
theme.

bernhard
-------------- next part --------------
? yourchanges.patch
Index: src/Util.cc
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Attic/Util.cc,v
retrieving revision 1.11
diff -p -u -r1.11 Util.cc
--- src/Util.cc	2002/08/22 01:03:08	1.11
+++ src/Util.cc	2003/02/25 13:24:56
@@ -162,6 +162,15 @@ string expandTilde(const string& s) {
   return string(home + s.substr(s.find('/')));
 }
 
+string unexpandTilde(const string& s) {
+  const char* const home = getenv("HOME");
+  if (home == NULL) return s;
+  int home_len=strlen(home);
+  if(s.substr(0,home_len) == home) {
+    return string("~" + s.substr(home_len));
+  }
+  return s;
+}
 
 void bexec(const string& command, const string& displaystring) {
 #ifndef    __EMX__
Index: src/Util.hh
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Attic/Util.hh,v
retrieving revision 1.9
diff -p -u -r1.9 Util.hh
--- src/Util.hh	2002/07/22 06:12:38	1.9
+++ src/Util.hh	2003/02/25 13:24:56
@@ -90,7 +90,9 @@ struct Strut {
 /* XXX: this needs autoconf help */
 const unsigned int BSENTINEL = 65535;
 
+
 std::string expandTilde(const std::string& s);
+std::string unexpandTilde(const std::string& s);
 
 void bexec(const std::string& command, const std::string& displaystring);
 
Index: src/blackbox.cc
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Attic/blackbox.cc,v
retrieving revision 1.42
diff -p -u -r1.42 blackbox.cc
--- src/blackbox.cc	2002/08/27 08:18:04	1.42
+++ src/blackbox.cc	2003/02/25 13:24:56
@@ -1193,7 +1193,7 @@ void Blackbox::save_rc(void) {
                    (resource.auto_raise_delay.tv_usec / 1000)));
   config.setValue("session.cacheLife", resource.cache_life / 60000);
   config.setValue("session.cacheMax", resource.cache_max);
-  config.setValue("session.styleFile", resource.style_file);
+  config.setValue("session.styleFile", unexpandTilde(resource.style_file));
   config.setValue("session.titlebarLayout", resource.titlebar_layout);
 
   string s;


More information about the openbox mailing list