Default to a file in /tmp for the restart state.
The file is now created in /tmp using the process PID and the username of the user running i3. The restart state file is only loaded when restarting (the --restart option is appended to the command line prior to the restart). That means that renaming the old state file with the ".old" extension is no longer needed. This "--restart" switch is supposed to be only used by i3. The "-L" switch can be used to load a layout (and not delete it afterwards). We unlink the state file after we load it so that we don't keep cruft in /tmp or try to restart from an old config file if restart_state is set.
This commit is contained in:
committed by
Michael Stapelberg
parent
68f906f278
commit
c88c3e3ab2
13
src/tree.c
13
src/tree.c
@ -13,8 +13,8 @@ struct all_cons_head all_cons = TAILQ_HEAD_INITIALIZER(all_cons);
|
||||
* Loads tree from ~/.i3/_restart.json (used for in-place restarts).
|
||||
*
|
||||
*/
|
||||
bool tree_restore() {
|
||||
char *globbed = resolve_tilde(config.restart_state_path);
|
||||
bool tree_restore(const char *path) {
|
||||
char *globbed = resolve_tilde(path);
|
||||
|
||||
if (!path_exists(globbed)) {
|
||||
LOG("%s does not exist, not restoring tree\n", globbed);
|
||||
@ -28,15 +28,6 @@ bool tree_restore() {
|
||||
|
||||
tree_append_json(globbed);
|
||||
|
||||
size_t path_len = strlen(config.restart_state_path);
|
||||
char *old_restart = smalloc(path_len + strlen(".old") + 1);
|
||||
strncpy(old_restart, config.restart_state_path, path_len + strlen(".old") + 1);
|
||||
strncat(old_restart, ".old", strlen(".old") + 1);
|
||||
unlink(old_restart);
|
||||
rename(globbed, old_restart);
|
||||
free(globbed);
|
||||
free(old_restart);
|
||||
|
||||
printf("appended tree, using new root\n");
|
||||
croot = TAILQ_FIRST(&(croot->nodes_head));
|
||||
printf("new root = %p\n", croot);
|
||||
|
Reference in New Issue
Block a user