Open vivi-gomez opened 2 years ago
Hi @txirrindulari ,
If you are using X11, you can install xsession-manager via pip3 install xsession-manager
and then follow the instructions of If you want to restore the previous X session automatically after login. It's very easy. xsession-manager is a command line tool. It should fit your needs if you are running Gnome on X11.
This extension probably can't be used in terminal directly. Maybe it can be used via D-Bus, I'm not sure about this. And I have been adding the feature of WIP: [Feature] Restore saved windows automatically after login #33. But it will take time to finish, I don't have much time for it recently.
It's possible to use features of this extension from the terminal via D-Bus.
Here is a working example: https://github.com/ickyicky/window-calls/blob/b0223fca3348a115e8bb220709bc069cde78c615/extension.js#L44.
After installing https://extensions.gnome.org/extension/4724/window-calls/, run the below command in the terminal to retrieve all the running windows:
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Extensions/Windows --method org.gnome.Shell.Extensions.Windows.List
See also: https://gist.github.com/rbreaves/257c3edfa301786e66e964d7ac036269
@nlpsuge I believe I'm after what the OP is after and that's just the ability to invoke the same functionality that's invoked upon pressing "Save open windows" and "restore windows from saved session", but on the terminal. For example, I'm previously using lwsm and with that I can simply lwsm save NAME_OF_SESSION
and lwsm restore NAME_OF_SESSION
. Ultimately, because some apps do not properly restore state automatically I need to manually restore it's state before restoring window arrangement. Here's what my script currently looks like because Tilix doesn't restore state automatically.
#!/bin/bash
# start tilix since lwsm can't seem to restore previous session
tilix -s ~/ownCloud/work/tilix.json
xdg-open ~/ownCloud/work
# wait a moment for tilix to open
# sleep 5
# restore the rest of the windows and the geometries of previously opened
lwsm restore work
If I understand correctly, we need a command line tool
which wraps the calling of the core functions of this extension, such as Save open windows
and restore windows from saved session
.
I'm pretty sure this can be implemented via D-Bus
.
awsm-client
is a proper name for the command line tool
.
The calling graph is this: awsm-client => D-Bus services => core functions
.
@curiousercreative
Another solution is adding a new option in the Preferences to allow all or some apps to be restored via the saved cmd line
instead of the .desktop file
.
In your example, the saved cmd line
for Tilix
should be tilix -s ~/ownCloud/work/tilix.json
.
But this may not always work, because the cmd line
is not always the expected one, I guess it completely depends on the app itself.
Anyway, I have a plan to provide a awsm-client
. On the terminal, we can do a lot more things.
@nlpsuge thanks for detailing a plan for awsm-client
, I think that's exactly what we're looking for! Thanks also for the suggestion with the desktop file.
@nlpsuge this is going a bit off-topic, but related to working around the lack of cli for the extension. I'm attempting to create a desktop file for restoring this tilix session as described above. It's located at ~/.local/share/applications/work.Tilix.desktop
with contents
[Desktop Entry]
Version=1.0
Name=Common Energy Tilix
Comment=A tiling terminal for Gnome
Keywords=shell;prompt;command;commandline;cmd;
Exec=tilix -s /home/user/Desktop/work.json
Terminal=false
Type=Application
StartupNotify=true
Categories=System;TerminalEmulator;X-GNOME-Utilities;
Icon=com.gexperts.Tilix
This desktop file launches the expected tilix session. I then position it on the display in the correct position and attempt to save the session using the extension. Seems to save properly, but upon restore, an empty tilix session window is created (in the correct position though) rather than the tilix saved session. Upon further inspection of the saved session in ~/.config/another-window-session-manager/sessions/test
reveals that a default tilix desktop file was selected
{
"cmd": [
"tilix",
"--quake"
],
"desktop_file_id": "com.gexperts.Tilix.desktop",
"desktop_file_id_full_path": "/usr/share/applications/com.gexperts.Tilix.desktop",
}
The app_name
, window_title
and other attributes appear correct though. How does the extension determine which desktop file to load?
NOTE: in my case the cmd
is also wrong when this long running process (a terminal window that hides when not in focus) is running. If I kill that process, then the cmd is correct and reflects what is found in the desktop file that launched the window.
I should also mention this behavior was encountered on Pop!_OS 22.04, GNOME 42, X11
Hi @curiousercreative,
Sorry for the delay. I've been busy lately and forget your post.
Short answer:
Add StartupWMClass=Tilix
to the ~/.local/share/applications/work.Tilix.desktop
and try again. If it does not work, use StartupWMClass=tilix
instead and try again.
[Desktop Entry]
Version=1.0
Name=Common Energy Tilix
Comment=A tiling terminal for Gnome
Keywords=shell;prompt;command;commandline;cmd;
Exec=tilix -s /home/user/Desktop/work.json
Terminal=false
Type=Application
StartupNotify=true
Categories=System;TerminalEmulator;X-GNOME-Utilities;
Icon=com.gexperts.Tilix
StartupWMClass=Tilix
I hope it works for you. :)
How does the extension determine which desktop file to load?
It probably depends on AppSystem.lookup_app(a desktop id - such as firefox.desktop) and the property of one of wm_class
and wm_class_instance
in the desktop file.
Add
StartupWMClass=Tilix
to the~/.local/share/applications/work.Tilix.desktop
and try again. If it does not work, useStartupWMClass=tilix
instead and try again.
That first one seems to have done the trick, thanks very much!
Add StartupWMClass=Tilix to the ~/.local/share/applications/work.Tilix.desktop and try again. If it does not work, use StartupWMClass=tilix instead and try again.
On my laptop I run Wayland more often and there I am using the second lowercase. I had to save/restore/save multiple times to get things working, so perhaps that attribute is not the determining factor...
Hi, this is not a issue, but trying to find a way to control the extension from terminal and gnome 40.4.0 I want to use it within kvm hooks to save the current session with a given name and then restart the session again. Is there any way to accomplish this?