Close open windows gracefully and save them as a session. And you can restore them when necessary manually or automatically at startup.
Most importantly, it supports both X11 and Wayland!
This extension is based on several Gnome technologies and APIs including Meta, Shell and St(Shell Toolkit).
Click item to close open windows:
After confirm to close:
Click item to save open windows as a session:
After confirm to save:
Restore previous apps and windows at startup
under Restore sessions
. (See also: Restore previous apps and windows at startup).Log Out
, Restart
, Power Off
. disabled by default, to enable it please activate Auto close session
under Close windows
. (See also: Auto close session).ydotool
so you don't lose sessions of this app (See also: How to make Close by rules work)Always on Top
, Always on Visible Workspace
and maximizationAlt+F2 -> r
or killall -3 gnome-shell
.Enable this feature through Auto close session
under Close windows
:
After you click the Log Out/Restart/Power Off
button:
If the second button on the above dialog has via AWSM
, it means this feature is enabled.
After you click Log Out(via AWSM)
, all apps and windows will be closed automatically by AWSM. But some apps might be still opening, you have to close them yourself; then if there are no running apps, this extension logs out the current user immediately.
You can move it around in case it covers other windows.
Please note that currently if this option is enabled, it modifies the Gnome Shell endSessionDialog
globally, which means running gnome-session-quit --logout
will also popup the new modified dialog.
Close by rules
workTo make this feature work, you need to install ydotool:
# 1. Install `ydotool` using the package manager and make sure the version is greater than v1.0.0
sudo dnf install ydotool
#Or install it from the source code: https://github.com/ReimuNotMoe/ydotool
#Check the permission of `/dev/uinput`, if it's `crw-rw----+`, you can skip step 2
# 2. Get permission to access to `/dev/uinput` as the normal user
sudo touch /etc/udev/rules.d/60-awsm-ydotool-uinput.rules
# Here we use `tee`, not redirect(>), to avoid `warning: An error occurred while redirecting file '/etc/udev/rules.d/60-awsm-ydotool-uinput.rules' open: Permission denied`
# See: https://www.shellhacks.com/sudo-echo-to-file-permission-denied/
echo '# See:
# https://github.com/ValveSoftware/steam-devices/blob/master/60-steam-input.rules
# https://github.com/ReimuNotMoe/ydotool/issues/25
# ydotool udev write access
KERNEL=="uinput", SUBSYSTEM=="misc", TAG+="uaccess", OPTIONS+="static_node=uinput"' | sudo tee --append /etc/udev/rules.d/60-awsm-ydotool-uinput.rules
cat /etc/udev/rules.d/60-awsm-ydotool-uinput.rules
#Remove executable permission (a.k.a. x)
sudo chmod 644 /etc/udev/rules.d/60-awsm-ydotool-uinput.rules
# 3. Copy ydotool.service to /usr/lib/systemd/user, so `systemctl --user enable ydotool.service` can work
sudo cp /usr/lib/systemd/system/ydotool.service /usr/lib/systemd/user
# 4. Start ydotool.service at startup automatically for the current normal user
systemctl --user enable ydotool.service
# 5. Note that you may have to restart the system if the following commands are not working
# 6. Start the ydotoold service for the current normal user
systemctl --user start ydotool.service
# 7. Check if ydotoold service is working. The word `hello` should print on the terminal, if not you might need to reboot the system or try to relogin your account.
ydotool type 'hello'
## misc. ##
# Check if the ydotoold service is running, if not you may have to restart the system or start ydotool.service
systemctl --user status ydotool.service
Note that it's no necessary to run systemctl --user enable ydotool.service
, because this extension starts ydotool.service
every time while you use it to close windows.
Feel free to fill an issue if ydotool
does not work under normal user, you may also want to do that in its git issue area
Activate Restore previous apps and windows at startup
to enable this feature. This option and Restore selected session at startup
are exclusive. And this option works for shutting down the system normally (via Log Out/Restart/Power Off buttons) and other ways (like pressing the physical power-off button).
Then while startup, AWSM will launch and restore apps and states from the previous saved session configs.
The session configs are saved in the path ~/.config/another-window-session-manager/sessions/currentSession
.
You can use the below command to test it.
gdbus call --session --dest org.gnome.Shell.Extensions.awsm --object-path /org/gnome/Shell/Extensions/awsm --method org.gnome.Shell.Extensions.awsm.Autostart.RestorePreviousSession "{'removeAfterRestore': <false>}"
Restore a session at startup
?To make it work, you must enable it through Restore sessions -> Restore at startup
in the Preferences AND active a session by clicking in the popup menu.
While you enable it through Restore sessions -> Restore at startup
, it creates a _gnome-shell-extension-another-window-session-manager.desktop
under the folder ~/.config/autostart/
.
Test the settings in command line via:
gdbus call --session --dest org.gnome.Shell.Extensions.awsm --object-path /org/gnome/Shell/Extensions/awsm --method org.gnome.Shell.Extensions.awsm.Autostart.RestoreSession
Please do not modify _gnome-shell-extension-another-window-session-manager.desktop
, all changes by yourself could be overidden or deleted.
Icon | Description |
---|---|
Save open windows as a session, which name is the item's name | |
Restore the saved session using the item's name | |
Move the open windows using the item's name | |
Close the current open windows | |
Activate the current session to be restored at startup | |
Inactivate the current session to be restored at startup | |
Indicate the autorestore button |
Use ps
and pwdx
to get some information from a process, install it via dnf install procps-ng
if you don't have.
Use gdbus
to call the remote method, which is provided by this exension, to implement the restore at start
feature. gdbus
is part of glib2
.
Send keys to close the application gracefully with multiple windows.
As of version 34, AWSM also uses libgtop2
to query process information, just like ps
. The cost of calling ps
is very high, so I'm planing to remove this entirely.
To install it:
Fedora and derivatives:
dnf install libgtop2
Debian, Ubuntu, Pop!_OS, and derivatives:
apt install gir1.2-gtop-2.0 libgtop2-dev
Arch and derivatives:
pacman -S libgtop
If the .desktop is missing from a session file, restoring an application relies on the command line completely.
In this case this extension will generate a .desktop in the journalctl
when you click the save button (). Search Generated a .desktop file
in journalctl /usr/bin/gnome-shell -r
to find it: journalctl /usr/bin/gnome-shell -b -o cat --no-pager | grep 'Generated a .desktop file'
. To make it work, You need to copy it to ~/.local/share/applications
, and relaunch the app and save the session again. This extension should be able to restore the workspace, state, size and position of this application.
The generated .desktop might not work sometimes, it's better to check whether the value of Exec
is correct or not. If you restore an app using a bad .desktop, this extension will give you a notification and log error level logs in the journalctl
.
I tested on Anki, VirtualBox machine and two .AppImage apps, they all have no .desktop and are launched in the terminal. By using the generated .desktop, Anki, VirtualBox machine works. One .AppImage app works. Another .AppImage app is Wire_x86_64.AppImage
and doesn't work, because the command line returned is something like /tmp/.mount_Wire-3xxxxx/wire-desktop
, you can use it to launch Wire but files in the /tmp
will be deleted during the OS shutdown and start.
It's impossible / hard to query the command line from a process, the pid of a window might not be right too and I don't find a standard way for this.
One of the following should be enough to prove the .desktop is not proper:
Add to Favorites
in the menuMost existing applications should have a proper .desktop. I'm just handling the special case. Someone like myself might want this feature.
They are all in ~/.config/another-window-session-manager/sessions
. When use an existing name to save the current open windows, the previous file will be copied to ~/.config/another-window-session-manager/sessions/backups
as a new name, which is the-old-session-name.backup-current-timestamp.
Note that I've marked backups
as a reserved word, so you can't use it as a session name when saving a session. But you do have the freedom to manually create a file named backups
in ~/.config/another-window-session-manager/sessions
. But this extension will only backup the session file that you are clicking the save button and you will receive an error log in the journalctl
and an error notification every time you save an existing session.
.desktop
file by Shell.AppSystem.get_default().get_running()
.awsm-client
(See: issue 34)