]> git.sur5r.net Git - i3/i3/commitdiff
Make the restart path configurable.
authorFernando Tarlá Cardoso Lemos <fernandotcl@gmail.com>
Sat, 27 Nov 2010 00:27:38 +0000 (22:27 -0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 28 Nov 2010 00:18:10 +0000 (01:18 +0100)
include/config.h
src/cfgparse.l
src/cfgparse.y
src/config.c
src/tree.c
src/util.c

index c9e8e1a4f138efa0565b9381b4cd7837d957a0cd..abbee5e716c88fed165723e7e3f2e36d9749321e 100644 (file)
@@ -89,6 +89,7 @@ struct Config {
         const char *font;
 
         const char *ipc_socket_path;
+        const char *restart_state_path;
 
         int container_mode;
         int container_stack_limit;
index eb9c25c710db698f708480b08177d7842d7d3e62..93ce916c258e26686ae1de78d45c1023292bd2a0 100644 (file)
@@ -91,6 +91,7 @@ assign                          { BEGIN(ASSIGN_COND); return TOKASSIGN; }
 set[^\n]*                       { return TOKCOMMENT; }
 ipc-socket                      { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
 ipc_socket                      { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
+restart_state                   { BEGIN(BIND_AWS_COND); return TOKRESTARTSTATE; }
 new_container                   { return TOKNEWCONTAINER; }
 new_window                      { return TOKNEWWINDOW; }
 focus_follows_mouse             { return TOKFOCUSFOLLOWSMOUSE; }
index c2227f67401d79574443538aa0257349ff5a95ed..eaed7c5d55727bfcafc0604ccf8acbfbb7b6ce9e 100644 (file)
@@ -217,6 +217,7 @@ void parse_file(const char *f) {
 %token TOKASSIGN "assign"
 %token TOKSET
 %token TOKIPCSOCKET "ipc_socket"
+%token TOKRESTARTSTATE "restart_state"
 %token TOKEXEC "exec"
 %token TOKSINGLECOLOR
 %token TOKCOLOR
@@ -248,6 +249,7 @@ line:
         | workspace
         | assign
         | ipcsocket
+        | restart_state
         | exec
         | single_color
         | color
@@ -554,6 +556,13 @@ ipcsocket:
         }
         ;
 
+restart_state:
+        TOKRESTARTSTATE WHITESPACE STR
+        {
+                config.restart_state_path = $<string>3;
+        }
+        ;
+
 exec:
         TOKEXEC WHITESPACE STR
         {
index 93390b4a69c80d31532f7f2ecbe46a58c6e0537f..c02d1c2a97fce34aba43086d28e4e86bb021bbe0 100644 (file)
@@ -364,6 +364,8 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
         INIT_COLOR(config.bar.unfocused, "#333333", "#222222", "#888888");
         INIT_COLOR(config.bar.urgent, "#2f343a", "#900000", "#ffffff");
 
+        config.restart_state_path = "~/.i3/_restart.json";
+
         parse_configuration(override_configpath);
 
         if (reload) {
index e37eb5f9e91a97453a0c2debe3c11a4f7ca36a6f..947a8daaba91c3520089fa69136a2732823012f7 100644 (file)
@@ -14,7 +14,7 @@ struct all_cons_head all_cons = TAILQ_HEAD_INITIALIZER(all_cons);
  *
  */
 bool tree_restore() {
-    char *globbed = resolve_tilde("~/.i3/_restart.json");
+    char *globbed = resolve_tilde(config.restart_state_path);
 
     if (!path_exists(globbed)) {
         LOG("%s does not exist, not restoring tree\n", globbed);
@@ -27,7 +27,11 @@ bool tree_restore() {
     focused = croot;
 
     tree_append_json(globbed);
-    char *old_restart = resolve_tilde("~/.i3/_restart.json.old");
+
+    size_t path_len = strlen(config.restart_state_path);
+    char *old_restart = malloc(path_len + 5);
+    strncpy(old_restart, config.restart_state_path, path_len + 5);
+    strncat(old_restart, ".old", path_len + 5);
     unlink(old_restart);
     rename(globbed, old_restart);
     free(globbed);
index 04ec150882d81abe9b76139620c10f924ed18706..75203cfbfa2be1beb308e927e8d9f7296d030072 100644 (file)
@@ -375,7 +375,7 @@ void store_restart_layout() {
         unsigned int length;
         y(get_buf, &payload, &length);
 
-        char *globbed = resolve_tilde("~/.i3/_restart.json");
+        char *globbed = resolve_tilde(config.restart_state_path);
         int fd = open(globbed, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
         free(globbed);
         if (fd == -1) {