Skip to main content

xsession-manager

Save and restore windows for X11 desktop environment like Gnome, and many other features.

This project was written in Bash originally. But now I'm completely rewriting it in Python which obviously makes it way more flexible, extensible.

If you are a Gnome 3 user and also want to use these similar features on Wayland, please give Another Window Session Manager a try, it's a Gnome extension, much more faster than xsm, and much more native experience on Gnome.

Downloads Supported Versions Pypi Versions Contributors

Install

Install dependencies

  • Fedora
dnf install python3-devel python3-tkinter wmctrl

Install xsession-manager via PyPi

pip3 install xsession-manager

Install xsession-manager via source code

Method-1: Using pip.

This method install xsession-manager in ~/.local/lib/python3.9/site-packages if you are a normal user, in /usr/local/lib/python3.9/site-packages if you are root.

cd the_root_of_source_code
pip install .

Method-2: Using setup.py

This method install xsession-manager in /usr/local/lib/python3.9/site-packages.

cd the_root_of_source_code
sudo python3 setup.py install

Common usage

  • Save running windows as a X session

Save all running GUI windows to xsession-default

xsm -s

Specify a session name like, my-session-name, restore it later on by running xsm -s my-session-name. This feature should be very helpful when you have multiple tasks to do and each task needs different GUI apps.

xsm -s my-session-name

Note:

  1. It will save some window states, which include Always on Top and Always on Visible Workspace and will be used when executing xsm -r or xsm -ma.
  • Close running windows except those apps with mutiple windows. It's better to leave them to the user to close by hand, some apps like JetBrain's IDEs may have their own session.
xsm -c
  • Close running windows include those apps with mutiple windows.
xsm -c -im
  • Restore the saved X session

Restore all GUI apps using the saved session named xsession-default

xsm -r

Restore gnome-system-monitor using the saved session named my-session-name

xsm -r my-session-name -i gnome-system-monitor
  • Move running windows to their Workspaces according to the saved X session
xsm -ma
  • List saved X sessions
xsm -l
  • View the details of a saved X sessions
xsm -t xsession-default

Full usage:

usage: xsm [-h] [-s [SAVE]] [-c [CLOSE_ALL ...]] [-im] [-r [RESTORE]] [-ri RESTORING_INTERVAL] [-pr [PR]] [-l] [-t [DETAIL]]
           [-x EXCLUDE [EXCLUDE ...]] [-i INCLUDE [INCLUDE ...]] [-ma [MOVE_AUTOMATICALLY]] [--version] [-v] [-vv]

options:
  -h, --help            show this help message and exit
  -s [SAVE], --save [SAVE]
                        Save the current session. Save to the default session if not specified a session name.
  -c [CLOSE_ALL ...], --close-all [CLOSE_ALL ...]
                        Close the windows gracefully. Close all windows if only -c/--close-all present. Or close one or more
                        apps if arguments provided, which supports <window_id>, <pid>, <app_name> or <title_name> exactly the
                        same as -x. For example: `xsm -c gedit 23475 0x03e00004`
  -im, --including-apps-with-multiple-windows
                        Close the windows gracefully including apps with multiple windows
  -r [RESTORE], --restore [RESTORE]
                        Restore a session gracefully. Restore the default session if not specified a session name.
  -ri RESTORING_INTERVAL, --restoring-interval RESTORING_INTERVAL
                        Specify the interval between restoring applications, in seconds. The default is 2 seconds.
  -pr [PR]              Pop up a dialog to ask user whether to restore a X session.
  -l, --list            List the sessions.
  -t [DETAIL], --detail [DETAIL]
                        Check out the details of a session.
  -x EXCLUDE [EXCLUDE ...], --exclude EXCLUDE [EXCLUDE ...]
                        Exclude apps from the operation according to <window_id>, <pid>, <app_name> or <title_name>. Require
                        at least one value
  -i INCLUDE [INCLUDE ...], --include INCLUDE [INCLUDE ...]
                        Include apps from the operation according to <window_id>, <pid>, <app_name> or <title_name>. Require
                        at least one value
  -ma [MOVE_AUTOMATICALLY], --move-automatically [MOVE_AUTOMATICALLY]
                        Auto move windows to specified workspaces according to a saved session. The default session is
                        `xsession-default`
  --version             show program's version number and exit
  -v, --verbose         Print debugging information
  -vv                   Print more debugging information, could contain sensitive info

If you want to restore the previous X session automatically after login

Here is a solution. If you are using Fedora, create a file named auto-restore-working-state.desktop and the Exec should be:

xsm -pr

Then put this file into ~/.config/autostart.

For example:

[Desktop Entry]
Name=Auto Restore saved X Windows
Comment=
Icon=
Exec=xsm -pr
Terminal=false
Type=Application
X-GNOME-Autostart-Delay=20

NOTE: You can also use xsession-manager instead of xsm.

Todo:

TODO

Metadata

Release files for xsession-manager 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xsession-manager 1.0.8
File Size Uploaded Provenance Actions
xsession-manager-1.0.8.tar.gz 37.7 kB Without provenance Details for xsession-manager-1.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xsession-manager 1.0.8
File Interpreter ABI Platform Actions
xsession_manager-1.0.8-py3-none-any.whl Python 3 none any Details for xsession_manager-1.0.8-py3-none-any.whl

Total release size: 80.2 kB

Release files / xsession-manager-1.0.8.tar.gz

Download URL xsession-manager-1.0.8.tar.gz
Size 37.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0257e7e7b4eb918d60d1973857ec50ec555c1a6f0acc1d8135cea43d0bb2e76c
BLAKE2b-256 checksum
How to use checksums
6c4561234bbf9c51f38571c1cd3067caf60785e8cce404c077c4d81facd6dfa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / xsession_manager-1.0.8-py3-none-any.whl

Download URL xsession_manager-1.0.8-py3-none-any.whl
Size 42.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c20d16926d49c7577b0c59e8a648e3a3d617c0c1ef65c35d606e6d1f78f3617c
BLAKE2b-256 checksum
How to use checksums
3de4471e7b6c3bc041fe2f297f0d99ccf9efe2e35f8a05eb7435eaeeb871583b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for xsession-manager 1.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page