- `adopt_orphans` — Manage all the unmanaged windows remaining from a previous session.
-- `restore FILE_PATH` — Restore the layout of each desktop from the content of `FILE_PATH`.
+- `restore_layout FILE_PATH` — Restore the layout of each desktop from the content of `FILE_PATH`.
+
+- `restore_history FILE_PATH` — Restore the history of each desktop from the content of `FILE_PATH`.
- `quit [EXIT_STATUS]` — Quit.
_bspc()
{
- local messages='get set list list_desktops list_monitors list_windows list_rules list_history presel cancel ratio pad focus shift swap push pull cycle nearest circulate grab_pointer track_pointer ungrab_pointer toggle_fullscreen toggle_floating toggle_locked toggle_visibility close kill send_to drop_to send_to_monitor drop_to_monitor use use_monitor alternate alternate_desktop alternate_monitor add add_in rename_monitor rename cycle_monitor cycle_desktop layout cycle_layout rotate flip balance rule remove_rule put_status adopt_orphans restore quit'
+ local messages='get set list list_desktops list_monitors list_windows list_rules list_history presel cancel ratio pad focus shift swap push pull cycle nearest circulate grab_pointer track_pointer ungrab_pointer toggle_fullscreen toggle_floating toggle_locked toggle_visibility close kill send_to drop_to send_to_monitor drop_to_monitor use use_monitor alternate alternate_desktop alternate_monitor add add_in rename_monitor rename cycle_monitor cycle_desktop layout cycle_layout rotate flip balance rule remove_rule put_status adopt_orphans restore_layout restore_history quit'
local settings='focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color urgent_border_color border_width window_gap split_ratio top_padding right_padding bottom_padding left_padding wm_name borderless_monocle gapless_monocle focus_follows_pointer adaptative_raise apply_shadow_property auto_alternate focus_by_distance'
.BI adopt_orphans
Manage all the unmanaged windows remaining from a previous session.
.TP
-.BI restore " FILE_PATH"
+.BI restore_layout " FILE_PATH"
Restore the layout of each desktop from the content of FILE_PATH.
.TP
+.BI restore_history " FILE_PATH"
+Restore the history of each desktop from the content of FILE_PATH.
+.TP
.BI quit " [EXIT_STATUS]"
Quit.
.SH SETTINGS
#! /bin/sh
-if [ -e "$BSPWM_BACKUP" ] ; then
- bspc restore "$BSPWM_BACKUP"
- rm "$BSPWM_BACKUP"
+if [ -e "$BSPWM_LAYOUT" ] ; then
+ bspc restore_layout "$BSPWM_LAYOUT"
+ rm "$BSPWM_LAYOUT"
else
bspc adopt_orphans
fi
+
+if [ -e "$BSPWM_HISTORY" ] ; then
+ bspc restore_history "$BSPWM_HISTORY"
+ rm "$BSPWM_HISTORY"
+fi
-BSPWM_BACKUP=/tmp/bspwm-backup
+BSPWM_LAYOUT=/tmp/bspwm.layout
+BSPWM_HISTORY=/tmp/bspwm.history
super + alt + {Escape,shift + Escape}
- {wm_restart,bspc quit 1}
+ {bspc list_monitors > "$BSPWM_LAYOUT"; bspc list_history > "$BSPWM_HISTORY"; bspc quit,bspc quit 1}
+++ /dev/null
-#! /bin/sh
-
-bspc list_monitors > "$BSPWM_BACKUP"
-bspc quit
put_status();
} else if (strcmp(cmd, "adopt_orphans") == 0) {
adopt_orphans();
- } else if (strcmp(cmd, "restore") == 0) {
+ } else if (strcmp(cmd, "restore_layout") == 0) {
char *arg = strtok(NULL, TOK_SEP);
- restore(arg);
+ restore_layout(arg);
+ } else if (strcmp(cmd, "restore_history") == 0) {
+ char *arg = strtok(NULL, TOK_SEP);
+ restore_history(arg);
} else if (strcmp(cmd, "quit") == 0) {
char *arg = strtok(NULL, TOK_SEP);
if (arg != NULL)
list(d, n->second_child, rsp, depth + 1);
}
-void restore(char *file_path)
+void restore_layout(char *file_path)
{
if (file_path == NULL)
return;
ewmh_update_current_desktop();
}
}
+
+void restore_history(char *file_path)
+{
+ if (file_path == NULL)
+ return;
+
+ FILE *snapshot = fopen(file_path, "r");
+ if (snapshot == NULL) {
+ warn("restore history: can't open file\n");
+ return;
+ }
+
+ char line[MAXLEN];
+ desktop_t *d = NULL;
+ unsigned int level;
+
+ while (fgets(line, sizeof(line), snapshot) != NULL) {
+ unsigned int i = strlen(line) - 1;
+ while (i > 0 && isspace(line[i]))
+ line[i--] = '\0';
+ level = 0;
+ while (level < strlen(line) && isspace(line[level]))
+ level++;
+ PRINTF("level %u: %s\n", level, line + level);
+ if (level == 0) {
+ desktop_location_t loc;
+ if (locate_desktop(line + level, &loc))
+ d = loc.desktop;
+ } else if (d != NULL) {
+ xcb_window_t win;
+ if (sscanf(line + level, "%X", &win) == 1) {
+ window_location_t loc;
+ if (locate_window(win, &loc))
+ history_add(d->history, loc.node);
+ }
+ }
+ }
+
+ fclose(snapshot);
+}
void list_monitors(list_option_t, char *);
void list_desktops(monitor_t *, list_option_t, unsigned int, char *);
void list(desktop_t *, node_t *, char *, unsigned int);
-void restore(char *);
+void restore_layout(char *);
+void restore_history(char *);
#endif