Simplified version of zaxtax/xmonad-sessions that also saves workspace of the windows to be restored. xmonad-sessions is a way to use xmonad to control which of your applications persist and are easily restored.
place ViewDoc.hs into ~/.xmonad/lib/
$ cp ViewDoc.hs ~/.xmonad/lib
modify xmonad.hs to import:
import ViewDoc
import XMonad.Actions.SpawnOn
and call toggleSaveState
to save/unsave focused window and launchDocuments
to restore all saved windows, e.g. bind it to keys:
mykeys (XConfig {modMask = modm}) = M.fromList $
[ ((modm, xK_s), toggleSaveState)
, ((modm .|. shiftMask, xK_s), launchDocuments)
]
And use manageSpawn
in your manageHooks, e.g.
main = xmonad $ defaultConfig
{ managehook = manageSpawn <+> myManageHook
, ...
}
For a setup as described above:
If you want to save any window focus over it and Mod-s. Mod-s again will untoggle it
To restore all previous windows saved Mod-S
All applications that have been wrapped with saveDocument will be restorable