Skip to main content

Session save and restore for the Hyprland Wayland compositor

Project description

██╗  ██╗██╗   ██╗██████╗ ██████╗       ███████╗███████╗███████╗███████╗██╗ ██████╗ ██████╗
██║  ██║╚██╗ ██╔╝██╔══██╗██╔══██╗      ██╔════╝██╔════╝██╔════╝██╔════╝██║██╔═══██╗██╔══██╗
███████║ ╚████╔╝ ██████╔╝██████╔╝█████╗███████║█████╗  ███████║███████║██║██║   ██║██║  ██║
██╔══██║  ╚██╔╝  ██╔═══╝ ██╔══██╗╚════╝╚════██║██╔══╝  ╚════██║╚════██║██║██║   ██║██║  ██║
██║  ██║   ██║   ██║     ██║  ██║      ███████║███████╗███████║███████║██║╚██████╔╝██║  ██║
╚═╝  ╚═╝   ╚═╝   ╚═╝     ╚═╝  ╚═╝      ╚══════╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝  ╚═╝

Native session restoration for Hyprland.

Bring back your workspaces.
Bring back your windows.
Continue exactly where you stopped.

A KDE Plasma-like session restore experience for the Hyprland Wayland compositor.


Python Hyprland License Status


Why hypr-session?

You close your laptop.

You reboot.

Everything is gone.

Your carefully arranged workspaces, terminals, editors, file managers, and apps disappear because Wayland currently has no universal session restoration protocol like the old X11 XSMP system.

KDE solved this internally.

Hyprland intentionally keeps things lightweight.

hypr-session fills that gap.

The Idea

Most "session managers" try to control your desktop.

hypr-session does not.

It simply:

  1. Takes a snapshot of your running environment.
  2. Stores your window layout.
  3. Restores everything during your next login.

Optional background daemon for automatic saves.

Event-driven auto-save (no polling).

No unnecessary magic.


Demo

$ hypr-session status

╭────────────── Saved Session ───────────────╮
│                                             │
│  Firefox        workspace 2       READY     │
│  Kitty          workspace 1       READY     │
│  VSCode         workspace 3       READY     │
│                                             │
╰─────────────────────────────────────────────╯

Features

Atomic Hyprland Restoration

Uses Hyprland dispatch rules:

[workspace 2 silent] firefox

Applications spawn directly into their saved workspace.

No window teleporting.

No flickering.

No ugly startup chaos.


Smart Process Recovery

Hyprland knows windows.

Linux knows processes.

hypr-session connects both.

Uses:

hyprctl -j clients
        +
/proc/<pid>/cmdline
        +
XDG desktop mapping

to reconstruct how applications were launched.


DBus Resistant Restore Engine

Modern applications are annoying.

Firefox, Dolphin, Electron apps, and Flatpaks often ignore simple launch rules because DBus handles the real process.

hypr-session tracks the created window address:

0x55fa91ab3020

and forcefully restores the correct workspace.


Terminal Directory Restore

Close your terminal inside:

~/Projects/kernel-driver/

Restore session.

Terminal opens again inside:

~/Projects/kernel-driver/

Supported:

  • Kitty
  • Alacritty
  • Foot
  • WezTerm

Electron / Flatpak Friendly

Handles:

  • VSCode
  • Discord
  • Obsidian
  • Chromium apps
  • sandbox wrappers
  • renamed binaries

Beautiful CLI

Powered by Rich.

Includes:

  • colored dashboards
  • progress animations
  • session overview
  • dry runs

Installation

Arch Linux (AUR)

If you are using Arch Linux, you can install the package directly from the AUR using your favorite helper:

yay -S hypr-session-git

Then, install the auto-start hooks:

hypr-session install-hooks

PyPI (Universal)

For all other distributions (Ubuntu, Fedora, NixOS, etc.), we recommend using pipx to install hypr-session in an isolated environment.

Arch Linux / EndeavourOS / Manjaro

sudo pacman -S python-pipx
pipx install hypr-session
hypr-session install-hooks

Fedora

sudo dnf install pipx
pipx install hypr-session
hypr-session install-hooks

Ubuntu / Debian

sudo apt install pipx
pipx install hypr-session
hypr-session install-hooks

Quick Install Script

If you want a fully automated installation that handles pipx configuration for you:

curl -sSL https://raw.githubusercontent.com/krishiv2489/hypr-session/main/install.sh | bash

Usage

Workspace Profiles

Save a named layout once:

hypr-session save --profile study

Restore it with a keybind. Add to ~/.config/hypr/hyprland.conf:

# SUPER + SHIFT + S restores your Study layout instantly
bind = SUPER SHIFT, S, exec, hypr-session restore --profile study

Create as many profiles as you need:

hypr-session save --profile gaming
hypr-session save --profile coding
hypr-session save --profile music

Each profile is a separate JSON file and can be exported, shared, or version-controlled.

Basic Commands

Save current session:

hypr-session save

Restore:

hypr-session restore

Preview without opening apps:

hypr-session restore --dry-run

Show dashboard:

hypr-session status

List profiles:

hypr-session list

Compare your active desktop to the saved session:

hypr-session diff

Diagnose system issues:

hypr-session doctor

Pause automatic saving:

hypr-session pause
hypr-session pause --permanent

Commands

Command Description
save Snapshot current desktop
restore Restore saved session
diff Compare active vs saved windows
status View saved windows
list Show saved sessions
rename Rename a session profile
copy Duplicate a session profile
export Export session to JSON
import Import session from JSON
doctor Run system diagnostics
pause Disable temporary/permanent save
clear Delete one or all sessions
resume Re-enable auto-save
config Create default config file
daemon Run auto-save background daemon
install-hooks Configure Hyprland automatically
enable-daemon Install systemd auto-save service

Hyprland Integration

Auto restore:

exec-once = hypr-session restore --wait

Save before exit:

bind = SUPER SHIFT, Q, exec, hypr-session save ; hyprctl dispatch exit

How It Works

Saving

Hyprland IPC
      |
      v
hyprctl clients
      |
      v
Window PID
      |
      v
Linux /proc
      |
      v
Session JSON

Example saved entry:

{
  "class": "kitty",
  "workspace": 1,
  "cmd": "kitty",
  "size": [900, 600]
}

Restoring

Session JSON
      |
      v
Launch application
      |
      v
Detect new window
      |
      v
Apply Hyprland rules

Project Structure

hypr-session/

├── src/
│   └── hypr_session/
│
│       ├── models.py
│       │   Data structures
│
│       ├── session.py
│       │   Save engine
│
│       ├── restore.py
│       │   Restore engine
│
│       ├── mapping.py
│       │   Application detection
│
│       ├── config.py
│       │   User configuration
│
│       └── cli.py
│           Terminal interface
│
├── tests/
├── pyproject.toml
└── README.md

Philosophy

A window manager cannot know what is inside an application.

Browsers restore browser tabs.

Editors restore files.

Terminals restore shell locations.

hypr-session restores the desktop environment around them.

Small tools.

Clear boundaries.

Unix philosophy.


Roadmap

v1.0 ✅

  • Named profiles
hypr-session save --profile gaming
hypr-session restore --profile coding
  • DBus-resistant restore engine

  • Terminal CWD restoration

  • Rich CLI with progress bars

  • Dry-run mode

  • Auto-hook installer (install-hooks)

  • AUR package

  • PyPI release

v1.x

  • Hyprland groups / tabbed layout support

  • Special workspace restoration

  • Socket event listener for auto-save (daemon command)


Contributing

Contributions are welcome.

Useful contributions:

  • application mappings
  • bug fixes
  • distro testing
  • restore improvements

Development:

git clone https://github.com/krishiv2489/hypr-session

cd hypr-session

python -m venv .venv

source .venv/bin/activate

pip install -e ".[dev]"

pytest

Author

Created by Krishiv Patel

GitHub: @krishiv2489


License

MIT License.

Use it.

Modify it.

Break it.

Improve it.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hypr_session-1.0.2.tar.gz (44.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hypr_session-1.0.2-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

File details

Details for the file hypr_session-1.0.2.tar.gz.

File metadata

  • Download URL: hypr_session-1.0.2.tar.gz
  • Upload date:
  • Size: 44.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hypr_session-1.0.2.tar.gz
Algorithm Hash digest
SHA256 270fae56b04d97f0ba9d307761eba49033c338eaa679ee59c375096073407840
MD5 804836b9691a2d1fc2fdf28c46205e64
BLAKE2b-256 10097ad95ce4f1820f5e39cdba1a35df8c60ae115306988d74d22048aa46888f

See more details on using hashes here.

Provenance

The following attestation bundles were made for hypr_session-1.0.2.tar.gz:

Publisher: publish.yml on krishiv2489/hypr-session

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hypr_session-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: hypr_session-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hypr_session-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 484472cf5c8b46f8bf2b531d6047fd48444c08cc76f2ceb6786b77945b3ce637
MD5 08239792913c5490e32be8465a16311e
BLAKE2b-256 471f4e6a0c485354d494c5504421c33eef46c13e7d1a9a90c9fb652d2466f0ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for hypr_session-1.0.2-py3-none-any.whl:

Publisher: publish.yml on krishiv2489/hypr-session

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page