Skip to content

Add session restore support#800

Open
cheerfulScumbag wants to merge 4 commits intomangowm:mainfrom
cheerfulScumbag:feature/session-restore
Open

Add session restore support#800
cheerfulScumbag wants to merge 4 commits intomangowm:mainfrom
cheerfulScumbag:feature/session-restore

Conversation

@cheerfulScumbag
Copy link
Copy Markdown

@cheerfulScumbag cheerfulScumbag commented Mar 22, 2026

Adds opt-in session save/restore support to Mango.

When session_restore=1:

  • Mango saves a restorable snapshot on clean shutdown
  • Mango loads that snapshot on next startup
  • Mango relaunches supported apps from persisted launch_command
  • Mango restores tag, monitor, floating/fullscreen state, and floating geometry as windows map

When session_restore=0:

  • Mango behaves as before
  • no session file is written
  • no restore or relaunch path runs

Supported config:
'session_restore=0|1'

Optional override config:
'session_launch=app_id|command'
'session_launch=app_id|title|command'

Current launch-command priority:

  1. exact command Mango itself used to spawn the app
  2. normalized higher-level launcher command recovered from process metadata
  3. raw process argv fallback
  4. title-specific session_launch
  5. app-only session_launch
  6. plain app_id

Normalization currently implemented:

  • Flatpak apps normalize to desktop-entry launcher command
  • desktop-entry-backed apps normalize to the desktop file Exec= command

Validated:

  • disabled path writes no session file
  • clean shutdown save
  • self-relaunch on next Mango startup
  • duplicate foot windows with title-specific mappings
  • exact command capture for Mango-owned exec-once launches
  • process-based recovery for apps Mango did not spawn directly
  • single-monitor restore
  • floating geometry restore
  • tag restore
  • two-monitor restore when outputs already exist before clients map

@cheerfulScumbag cheerfulScumbag marked this pull request as draft March 22, 2026 23:16
@cheerfulScumbag
Copy link
Copy Markdown
Author

current implementation works, but I want to improve automatic launch recovery so common apps do not require as much manual session_launch configuration

@cheerfulScumbag
Copy link
Copy Markdown
Author

cheerfulScumbag commented Mar 23, 2026

Updated this draft with a stronger automatic launch-command recovery path.

Since the original draft, Mango now:

  • tracks exact commands for apps it launches itself
  • recovers commands from client process metadata for apps it did not launch directly
  • normalizes Flatpak apps to desktop-entry launcher command
  • normalizes desktop-entry-backed apps to the desktop file Exec= command

That reduces the need for manual session_launch rules for common apps.

@cheerfulScumbag cheerfulScumbag marked this pull request as ready for review March 23, 2026 17:03
@cheerfulScumbag cheerfulScumbag marked this pull request as draft March 23, 2026 17:19
@cheerfulScumbag cheerfulScumbag marked this pull request as ready for review March 23, 2026 19:15
@cheerfulScumbag cheerfulScumbag force-pushed the feature/session-restore branch from e87731f to 3aa9a90 Compare March 24, 2026 20:19
@cheerfulScumbag
Copy link
Copy Markdown
Author

tested on multiple programs and they all restore with no issues
so when session_restore=1:

  • Mango saves a restorable snapshot on clean shutdown
  • Mango loads that snapshot on next startup
  • Mango relaunches supported apps from persisted launch_command
  • Mango restores tag, monitor, floating/fullscreen state, and floating geometry as windows map

Give it a test and let me know what you think

@cheerfulScumbag cheerfulScumbag force-pushed the feature/session-restore branch from 3aa9a90 to f78d3b9 Compare March 25, 2026 20:43
@cheerfulScumbag cheerfulScumbag changed the title Add opt-in session save and restore support Restore Window Sessions Mar 26, 2026
@cheerfulScumbag cheerfulScumbag changed the title Restore Window Sessions Add session restore support Mar 26, 2026
@DreamMaoMao DreamMaoMao force-pushed the main branch 2 times, most recently from 0d3ed31 to 5267649 Compare March 30, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant