Allow saving whole session with all workspaces#104
Allow saving whole session with all workspaces#104cedryc wants to merge 7 commits intoJonnyHaystack:masterfrom
Conversation
JonnyHaystack
left a comment
There was a problem hiding this comment.
I reviewed some of this and have left some comments, but it's really a lot so it's pretty hard. Appreciate your work though. If you can keep the changes especially to the interface as minimal as possible then that would make things easier.
i3_resurrect/main.py
Outdated
| from . import util | ||
|
|
||
| DEFAULT_DIRECTORY = config.get('directory', '~/.i3/i3-resurrect/') | ||
| DEFAULT_DIRECTORY = config.get('directory', '~/.config/i3-resurrect/') |
There was a problem hiding this comment.
Ya it's not relevant here, so removed.
i3_resurrect/layout.py
Outdated
| for window_id in window_ids: | ||
| xdo_unmap_window(window_id) | ||
| if target in ('clean', 'force'): | ||
| keept_windows = clean_workspace(layout, saved_programs, normal_windows, target) |
There was a problem hiding this comment.
Don't understand this variable name. What is keept?
There was a problem hiding this comment.
That represent windows that are preserved on the layout. Changed variable name to preserved_windows.
i3_resurrect/layout.py
Outdated
| keept_windows = [] | ||
| saved_windows = treeutils.get_leaves(layout) | ||
| for saved_program in saved_programs: | ||
| # print(saved_window) |
There was a problem hiding this comment.
This line needs to be removed
| directory = Path(expandvars(directory)).expanduser() | ||
| if profile is not None: | ||
| directory = directory / 'profiles' | ||
| directory = directory / profile |
There was a problem hiding this comment.
Why did you change this? That's not how the directory structure is
There was a problem hiding this comment.
Yes is a personal preference, that was easier for me to implement the feature with profiles stored in dirs.This way, the directory name is the name of the profile. Also allow saving multiple workspace in the same profile name. So session profiles can be handled the same way as session without profile name.
i3_resurrect/main.py
Outdated
| """ | ||
| List saved workspaces or profiles. | ||
| """ | ||
| # TODO: list workspaces in profiles |
There was a problem hiding this comment.
This is something that worked before. Please don't break existing functionality in a PR.
README.md
Outdated
| --layout-only Only restore layout. | ||
| --programs-only Only restore running programs. | ||
| -c, --clean Move program that are not part of the workspace | ||
| layout to the scratchpad. |
README.md
Outdated
| layout to the scratchpad. | ||
|
|
||
| -F, --force Close program that are not part of the workspace | ||
| layout before restore it. |
There was a problem hiding this comment.
I notice both of these help texts have a big space in the middle because of how you've written them in the code, so you'll need to fix that.
i3_resurrect/main.py
Outdated
| Save i3 workspace(s) layout(s) or whole session and running programs to a file. | ||
|
|
||
| WORKSPACES are the workspaces to save. | ||
| [default: current workspace] |
There was a problem hiding this comment.
What's up with this comment?
i3_resurrect/main.py
Outdated
| @click.option('--workspace', '-w', | ||
| help='The workspace to save.\n[default: current workspace]') | ||
| is_flag=True, | ||
| help='The workspaces to save.\n This can either be a name or the number of a workspace.') |
There was a problem hiding this comment.
Why are you making this a flag?
There was a problem hiding this comment.
To allow saving multiples workspaces at once. Workspaces name or number are parsed as arguments
i3_resurrect/main.py
Outdated
| @click.option('--workspace', '-w', | ||
| help='The workspace to restore.\n[default: current workspace]') | ||
| is_flag=True, | ||
| help='The WORKSPACES to restore.\nThis can either be a name or the number of a workspace.') |
There was a problem hiding this comment.
Doesn't make sense that you're making this a flag but also claiming that it takes a list of workspaces which it doesn't...
|
Would this feature be finished in the future? |
I made some changes on this feature in my repo, may need some further testing... |
|
When would the program to be ran to save the session? Is there a hook to hook into to be called before the session ends. |
Work in progress
Made a pull request for this feature:
This implementation use subdir for saving profiles instead of files, to allow saving multiples workspaces or whole session profile
this may be usefull for some people