Skip to content

Latest commit

 

History

History
198 lines (139 loc) · 12.4 KB

File metadata and controls

198 lines (139 loc) · 12.4 KB

gnome-shell-extension-another-window-session-manager

Close and save open windows. And restore from a saved windows session.

Most importantly, it supports both X11 and Wayland!

This project is in early development, but it's basically working now. More features will be added in the future.

This extension is based on several Gnome technologies and APIs including Meta, Shell and St(Shell Toolkit).

Get it on GNOME Extensions

Screenshot

Overview

image

Close open windows

Click item to close open windows:

image

After confirm to close:

image

Save open windows

Click item to save open windows as a session:

image

After confirm to save:

image

Activate the current session to be restored at startup

image

Preferences

Restore sessions

To modify the delay, timer, and how to restore a session: image

Close windows

image

Main features

  1. Close open windows
  2. Close apps with multiple windows via ydotool so you don't lose sessions of this app (See also: How to make Close by rules work)
  3. Save open windows
  4. Restore session(s)
  5. Restore a session at startup (See also: #9). Please note that this feature is disabled by default.
  6. Restore window state, including Always on Top, Always on Visible Workspace and maximization
  7. Restore window workspace, size and position
  8. Move windows to their own workspace according to a saved session
  9. Support multi-monitor
  10. Trash saved session
  11. Search saved session by the session name fuzzily
  12. ...

Close windows

How to make Close by rules work

# 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
sudo 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"' > /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. Autostart the ydotoold service under the normal user
sudo cp /usr/lib/systemd/system/ydotool.service /usr/lib/systemd/user
sudo systemctl --user enable ydotool.service

And then reboot the system to take effect. Relogin maybe work too.

Restore sessions

How to 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.

Panel menu items

Icons description

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

Dependencies

  • procps-ng

Use ps and pwdx to get some information from a process, install it via dnf install procps-ng if you don't have.

  • glib2

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.

  • ydotool

Send keys to close the application with multiple windows.

Known issues

  1. On both X11 and Wayland, if click restore button () continually during the process of restoring, the window size and position may can't be restored, and it may restore many instances of an application. As a workaround, click the restore button () only once until all apps are restored.
  2. On both X11 and Wayland, due to this bug within mutter, in Overview, if click restore button () then immediately click the newly created workspace, the Gnome Shell can crash. To fix this issue, the Overview will be toggled hidden after clicking the restore button () when in Overview. I will remove this behavior once I find a better solution or it's fixed in a new version of Gnome Shell. (Fixed in Gnome 42)
  3. ...

Support applications launched via a command line or applications that don't have a proper .desktop file

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.

How can I know whether a .desktop of an application is proper or not?

One of the following should be enough to prove the .desktop is not proper:

  1. Right click on the icon in the panel or dash, if there is no Add to Favorites in the menu
  2. This extension can launch an application, but can't move the window to its workspace. (But it might suggest there is a bug in this extension, LOL :))

Most existing applications should have a proper .desktop. I'm just handling the special case. Someone like myself might want this feature.

Where are the saved sessions?

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.

TODO

    • Close open windows
      • Close all windows on the current workspace. Who needs this feature? Hand up.🙋
    • Save open windows
      • Save open windows
    • Restore saved open windows
      • Restore saved open windows
      • Move to belonging workspace automatically
      • Restore window size and position (issue 17)
      • Restore window workspace, size and position of applications launched via a command line and don't have a recognizable .desktop file by Shell.AppSystem.get_default().get_running().
      • Support multi-monitor (issue 21)
    • Saved open windows list
      • Save open windows button
      • Restore button
      • Rename button (double click text to rename?)
      • Move button
      • Delete button
    • Move windows according to a saved session.
    • Settings
      • Debugging mode
      • whitelist using for closing application with multiple windows
    • Support restoring a saved session at startup (issue 9)
    • Support saving and closing windows when Log Out, Power off, Reboot (issue 9)
    • All TODO tags in the projects
    • Translation?
    • A client tool called awsm-client (See: issue 34)
    • Fix any typo or grammar errors.
    • Open the Preferences on the popup menu
    • Open the session file from the popup menu