Package: wm-win-tool
wm-win-toolStore desktops, geometries, and shade states of X11 windows, selected by
window title and class patterns, in order to restore their layouts later on.The primary reason for this program to exist is Firefox, that fails to restore
its session properly under usual X11 window managers (KF5 in my case).Note, that the problem is well known, but unfortunately, little has been done
in the last 13 years tosolve this issue.This program is an humble attempt to solve it manually/externally, but might
prove useful for other constellations as well.Usage:wm-win-tool [-hVvfbr] [-c class][-t title] store
wm-win-tool [-hVvfbr] [-c class][-t title] restore [arg]
wm-win-tool [-hVvb][-c class][-t title] curlist [max]
wm-win-tool [-hVv] list [max]
       -h, --help           this message
       -V, --version        print version and exit
       -v, --verbose        verbose mode (cumulative)
       -f, --force          force store
       -b, --bracket        use the bracket pattern
       -r, --regexp         class and title pattern are regexp
       -c, --class class    match window class
       -t, --title title    match window titleCommandsstorewill save the geometry, desktop, and shaded state of selected windows
by class or pattern, unless the previous state is unchanged or the operation
is enforced with--force.restorewill restore the window geometries, matched by class or pattern,argis either a timestamp from the store list, or a relative index (eg. -1
for the latest session [default], -2 for the one before...).Note, that the selection parameters for store and restoreshouldmatch.Use thecurlistcommand to test your current selection options.listshows the available sessions up to an optional maximum number of items
to be restored, sorted by date (descending).Options--classand--titleare simple case sensitive wildcard pattern, that can
be supplied multiple times to match a subset of windows.--regexpswitches
them to regular expression matching. Make sure to properly quote such
arguments.The--bracketoption just matches the part of the window title in square
brackets, eg.:[title] long titlewill just match[title]. This is most
useful in conjunction with Firefox and theWindow Titler addon.Example UsageCasual approach to restore your Firefox session:wm-win-tool -bc Navigator.Firefox storewill save every Firefox window, andwm-win-tool -bc Navigator.Firefox restorewill restore all recognized windows. The only downside is, that the window
titles must matchexactlyto be restored correctly. So better make sure to
run this tool right before leaving the session.A more robust approach to the issue in question: install theWindow Titler addonand supply all windows, that you want to have managed
with auniquetitle, that appears in square brackets in front of the
window title. This provides a static title, independent from which tab is
actived.Now saving a session is as easy as:wm-win-tool -vb storeYou can run this command as many times as you want. As long as the session
wasn't changed meanwhile, it won't store a new session (unless the--forceoption is supplied).After reboot, you may wish to restore this session:wm-win-tool -vb restoreé voila, the windows move to their original desktops, and have their former
geometry and shaded state applied.InstallUsing pip:$ pip install wm-win-toolFrom source:$ wget https://files.pythonhosted.org/packages/source/w/wm-win-tool/wm-win-tool-<version>.tar.gz
$ tar xvf wm-win-tool-<version>.tar.gz
$ cd wm-win-tool-<version>
$ python3 setup.py installDependenciesYou need to make sure, that the command line programswmctrlandxpropare
installed. Check with your distributions package manager..Consequently,wm-win-toolneeds a proper DISPLAY/XAUTHORITY environment
setup.Final notesThere are good chances, that the Firefox issue is fixed with Version 75. Hooray.
Let's hope for the best. If all goes well, this tool provides a nice way tovalidatethe final fix. If all windows match, it will not perform any action
on (verbose) restore. :wink:The commandsstoreandrestorecould be implicitly triggered, when executed
via symlinks towm-win-tool, eg.:$ cd <whatever>/bin
$ ln -s wm-win-tool wm-win-store
$ ln -s wm-win-tool wm-win-restoreThese operation modes come with some hardcoded defaults:--bracketand--verbosefor the most usual usage patterns. If that's not enough, a config
file option might be useful (TBD).The session data is saved in~/local/share/wm-win-tool.In pathological cases (where I count in for sure), it might be advantageous
to exclude Firefox from the window manager session restore completely. kwin5
is configurable as such. When executing Firefox after reboot, it will open all
session windows on yourcurrentdesktop then. Runwm-win-restoreandbe
done.If you plan to runwm-win-storefromcrontab -e, keep in mind, that most
cron implementations suffer from variable expansion issues. Here is an
example, that should work with Vixie cron:#PATH=$HOME/bin:/bin:/usr/bin	# won't work
#XAUTHORITY=~/.Xauthority	# neither that

# store firefox window list
42 * * * * XAUTHORITY=~/.Xauthority DISPLAY=:0 wm-win-tool -b storeAUTHORITYis expanded from the shell in this case, which is necessary to
operate properly. Depending on the way, you installedwm-win-tool, you might
need to adjust the path as well. We also avoid using the symlink shortcut
here due to its implicit verbosity level.Some things are realized in a prettyoldschoolway, eg. command line
handling, but until the command line interface getssignificantlymore
complex, I prefer to do it this way (since ages).If you have other ideas, interesting applications, what ever, let me know.Feedback welcome.