summaryrefslogtreecommitdiff
path: root/util/fluxbox-update_configs.cc
diff options
context:
space:
mode:
Diffstat (limited to 'util/fluxbox-update_configs.cc')
-rw-r--r--util/fluxbox-update_configs.cc53
1 files changed, 53 insertions, 0 deletions
diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc
index 0105c18..0528119 100644
--- a/util/fluxbox-update_configs.cc
+++ b/util/fluxbox-update_configs.cc
@@ -323,6 +323,59 @@ int run_updates(int old_version, FbTk::ResourceManager &rm) {
323 new_version = 9; 323 new_version = 9;
324 } 324 }
325 325
326 if (old_version < 10) { // update keys file for NextWindow syntax changes
327 string whole_keyfile = read_file(keyfilename);
328
329 size_t pos = 0;
330 while (true) {
331 const char *keyfile = whole_keyfile.c_str();
332 const char *loc = 0;
333 size_t old_pos = pos;
334 // find the first position that matches any of next/prevwindow/group
335 if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos,
336 "nextwindow")))
337 pos = (loc - keyfile) + 10;
338 if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos,
339 "prevwindow")))
340 pos = (pos > old_pos && keyfile + pos < loc) ?
341 pos : (loc - keyfile) + 10;
342 if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos,
343 "nextgroup")))
344 pos = (pos > old_pos && keyfile + pos < loc) ?
345 pos : (loc - keyfile) + 9;
346 if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos,
347 "prevgroup")))
348 pos = (pos > old_pos && keyfile + pos < loc) ?
349 pos : (loc - keyfile) + 9;
350 if (pos == old_pos)
351 break;
352
353 pos = whole_keyfile.find_first_not_of(" \t", pos);
354 if (pos != std::string::npos && isdigit(whole_keyfile[pos])) {
355 char *endptr = 0;
356 unsigned int mask = strtoul(keyfile + pos, &endptr, 0);
357 string insert = "";
358 if ((mask & 9) == 9)
359 insert = "{static groups}";
360 else if (mask & 1)
361 insert = "{groups}";
362 else if (mask & 8)
363 insert = "{static}";
364 if (mask & 2)
365 insert += " (stuck=no)";
366 if (mask & 4)
367 insert += " (shaded=no)";
368 if (mask & 16)
369 insert += " (minimized=no)";
370 if (mask)
371 whole_keyfile.replace(pos, endptr - keyfile - pos, insert);
372 }
373 }
374
375 write_file(keyfilename, whole_keyfile);
376 new_version = 10;
377 }
378
326 return new_version; 379 return new_version;
327} 380}
328 381