Automatically Save and Restore Your i3 Workspaces with i3-resurrect-auto
If you’re an i3wm user, you know the pain of losing your carefully arranged workspace layouts after a reboot. You spend time positioning terminals, browsers, and applications exactly how you like them—only to start from scratch every time you restart your system.
Enter i3-resurrect-auto—a collection of scripts that automatically saves your i3 workspaces on shutdown and restores them on startup, so you can pick up right where you left off.
The Problem
i3wm is fantastic for productivity, but it doesn’t natively remember your window layouts between sessions. While i3-resurrect exists to save and restore workspaces manually, there’s no built-in way to automate this process.
The Solution
i3-resurrect-auto wraps i3-resurrect with automation scripts that:
- 💾 Save all workspaces automatically when you shutdown, reboot, or logout
- 🚀 Restore everything on startup—layouts and applications
- 🎯 Provide rofi menus for manual save/restore operations
How It Works
The project consists of a few simple bash scripts:
- save-workspaces.sh – Iterates through your configured workspaces and saves each one
- restore-workspaces.sh – Runs on i3 startup and restores all saved workspaces
- config.sh – Maps your workspace numbers to profile names
- rofi menus – Optional GUI for manual operations
Quick Installation
# Clone the repo
git clone https://github.com/CryptLabs/i3-resurrect-auto.git
cd i3-resurrect-auto
# Run the installer
chmod +x install.sh
./install.sh
The installer copies everything to ~/.config/i3/scripts/ and provides instructions for the remaining setup.
Configuration
Edit ~/.config/i3/scripts/config.sh to map your workspaces:
declare -A workspace_map=(
["1"]="Terminal"
["2"]="Browser"
["3"]="Code"
["4"]="Files"
# Add your workspaces here
)
Then add the restore script to your i3 config:
exec --no-startup-id ~/.config/i3/scripts/restore-workspaces.sh
Integrating with Your Power Menu
The key to automatic saving is integrating with your shutdown/reboot process. If you use a rofi power menu (which most i3 users do), simply add the save script before each action:
# In your power menu script, before reboot:
~/.config/i3/scripts/save-workspaces.sh
systemctl reboot
# Before shutdown:
~/.config/i3/scripts/save-workspaces.sh
systemctl poweroff
Now every time you shutdown or reboot through your menu, your workspaces are automatically preserved.
Rofi Integration
The project includes two rofi scripts for manual operations:
Full menu (i3-resurrect-rofi.sh):
- Save All / Restore All for bulk operations
- Save / Restore / Delete for individual profiles
Simple menu (i3-resurrect-rofi-simple.sh):
- Lightweight version for individual profile management only
Bind one to a key in your i3 config:
bindsym $mod+Shift+r exec --no-startup-id ~/.config/i3/scripts/i3-resurrect-rofi.sh
Tips for Best Results
- Check your workspace names – Run
i3-msg -t get_workspaces | jq '.[].name'to see what i3 actually calls your workspaces - Test manually first – Run the save and restore scripts manually before relying on automation
- Adjust the restore delay – If applications don’t restore correctly, increase the
sleepvalue inrestore-workspaces.sh
Get It Now
The project is available on GitHub:
👉 github.com/CryptLabs/i3-resurrect-auto
Contributions and feedback are welcome!
Made with ❤️ using
