{"id":13587439,"url":"https://github.com/dflock/window-workspace-save-restore","last_synced_at":"2025-07-13T07:36:49.556Z","repository":{"id":146371612,"uuid":"334048185","full_name":"dflock/window-workspace-save-restore","owner":"dflock","description":"Save X11 window workspace placements to a file, then restore those windows to their correct workspaces later.","archived":false,"fork":false,"pushed_at":"2024-09-03T20:49:00.000Z","size":15,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T16:14:43.347Z","etag":null,"topics":["linux","window","workspaces","x11"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dflock.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-01-29T05:35:13.000Z","updated_at":"2025-03-21T22:03:34.000Z","dependencies_parsed_at":"2024-02-13T21:59:44.797Z","dependency_job_id":null,"html_url":"https://github.com/dflock/window-workspace-save-restore","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflock%2Fwindow-workspace-save-restore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflock%2Fwindow-workspace-save-restore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflock%2Fwindow-workspace-save-restore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflock%2Fwindow-workspace-save-restore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dflock","download_url":"https://codeload.github.com/dflock/window-workspace-save-restore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249105470,"owners_count":21213535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","window","workspaces","x11"],"created_at":"2024-08-01T15:06:12.848Z","updated_at":"2025-04-15T16:15:03.051Z","avatar_url":"https://github.com/dflock.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# X11 Window Workspace Placement Save \u0026 Restore\n:author: Duncan Lock\n\nThese two scripts let you:\n\n* Save the current workspace placement of X11 windows, to stdout.\n* Restore the workspace placement of X11 windows from stdin.\n\nThis allows you to dump window workspace placements to a file, then restore those windows to their correct workspaces later.\n\nYou can filter the list through grep on the way out or back in, to only affect a subset of the windows.\n\n== Why is this useful?\n\nI currently have VSCode open, with 7 windows, arranged across 3 workspaces. If I quit and restart VSCode, all the windows will come back, but they will all be opened in the current workspace - and I'll have to move the back to the appropriate workspace. These two scripts let you automate this:\n\n[source,console]\n----\n# Run save to save VSCode window placements\n$ window-workspace-save | grep \"Visual Studio\" \u003e ~/tmp/vscode-windows.txt\n\n# Restart VSCode... then restore the VSCode windows to their correct workspaces:\n$ cat ~/tmp/vscode-windows.txt | window-workspace-restore\n----\n\nThis works with any X11 windows, not just VSCode.\n\n== Requirements\n\nYou need `wmctrl` installed. See: https://www.freedesktop.org/wiki/Software/wmctrl/\n\nFor Debian/Ubuntu, you can do:\n\n[source,console]\n----\n$ sudo apt install wmctrl\n----\n\n== Installation\n\n[source,console]\n----\n$ sudo cp window-workspace-save.sh /usr/bin/window-workspace-save\n$ sudo cp window-workspace-restore.sh /usr/bin/window-workspace-restore\n----\n\n== Usage\n\n[source,console]\n----\n# Restore the workspace placement of windows from a file:\n$ cat ~/tmp/windows.txt | window-workspace-restore\n\n# Restore the workspace placement of just the VSCode windows from a file:\n$ grep 'Visual Studio Code' ~/tmp/windows.txt | window-workspace-restore\n\n# Save the workspace placement of all windows to a file:\n$ window-workspace-save \u003e ~/tmp/windows.txt\n\n# Save the workspace placement of all Google Chrome windows to a file:\n$ window-workspace-save | grep 'Google Chrome' \u003e ~/tmp/chrome-windows.txt\n----\n\n== Caveats\n\n=== Only works with windows with unique titles\n\nThis uses `wmctrl` to do this. Wmctrl _does have_ window IDs, but these aren't stable, so when applications are restarted they will get new window IDs. The only thing that you can use is the window's title. So, if you have lots of terminal windows open all called \"Terminal\", then these will probably get moved around arbitrarily.\n\nSeems to work OK for applications with lots of document/tab windows, but not so well with lots of instances of single window applications, which sometimes do have the same window title.\n\n=== Doesn't really help with crashes\n\nYou need to run the save script _first_, _before_ you can restore - so it works OK with deliberate restarts. If the app crashes - and you haven't run the save script... then you're out of luck. One way around this is to run the script regularly every few minutes using `cron`. For example, you could run this every 5 mins to keep a recent backup of all your 'Visual Studio Code' window placements: \n\n[source,bash]\n----\n#!/usr/bin/env bash\n# Print the current environment, without colours/escapes, so it doesn't mess up the terminal\nprintenv | sed 's/\\x1B\\[[0-9;]\\{1,\\}[A-Za-z]//g'\nset -o xtrace\nexport DISPLAY=:0.0\n# Save Visual Studio Code window placements to a variable\nwindows=$(/home/duncan/bin/window-workspace-save | grep 'Visual Studio Code')\n# Only overwrite the file if there are windows\nif [ -n \"$windows\" ]; then\n  echo \"$windows\" \u003e $HOME/.config/windows/vscode-windows.txt\nfi\n----\n\nSave this as a script somewhere and make it executable (`chmod +x $HOME/bin/backup-vscode-window-placement.sh`), then add this to your crontab to run it every 5 mins:\n\n[source,shell]\n----\n*/5 * * * * $HOME/bin/backup-chrome-window-placement.sh \u003e $HOME/tmp/backup-vscode-window-placement.log 2\u003e\u00261\n----\n\nor this to run it every minute:\n\n[source,shell]\n----\n* * * * * $HOME/bin/backup-chrome-window-placement.sh \u003e $HOME/tmp/backup-vscode-window-placement.log 2\u003e\u00261\n----","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflock%2Fwindow-workspace-save-restore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdflock%2Fwindow-workspace-save-restore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflock%2Fwindow-workspace-save-restore/lists"}