[xmonad] Toggle between last used windows

Norbert Zeh nzeh at cs.dal.ca
Sat Sep 10 13:33:16 CEST 2011


Wirt Wolff [2011.09.10 0315 -0600]:
> Excerpts from informationen's message of Sat Sep 10 02:44:17 -0600 2011:
> > 
> > with "toggleWSNoSP" i can toggle between the recently visited workspaces.
> > How can i do that for the most recently used windows? Say i am
> > working with vim in one window and ghci in another. How can i
> > define a keyboard shortcut to toggle between the two?
> > 
>  
> With cycleRecentWindows from XMonad.Actions.CycleWindows you get
> something like this, although it re-arranges windows within the stack,
> which may not be what you want if the windows you toggle are not meant
> to tile just "above" and "below" the focused one. This was primarily
> written for use with layouts that hide most or all the unfocused
> windows.
> 
> I'm not aware of anything that keeps track of history and toggles
> between windows without re-arranging their position in e.g. Tall or
> Grid, etc.

Look at X.A.GroupNavigation, which may only be in the darcs version - I'm not
sure.  It does not tough the window stacks in any way.  It does, however,
require a log hook to keep track of window history - there needs to be some way
of remembering history.  If you simply want to go back to the most recent
window, then

nextMatch History (return True)

is enough as an action after setting your logHook to:

logHook = historyHook

You can, however, also create an action for going back, for example, to the
most recently used terminal window:

nextMatch History (appName =? "xterm")

or cycle through the set of open terminal windows over all workspaces

nextMatch Backward (appName =? "xterm")
nextMatch Forward (appName =? "xterm")

What GroupNavigation does not do is the behaviour you would get by using
"Alt-Tab" on Windows: while you keep Alt pressed, repeatedly pressing Alt gets
you further back in history.  The reason it doesn't do this is that this
wouldn't be possible to implement as a simple action bound to a key
combination.

Cheers,
Norbert



More information about the xmonad mailing list