Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xmonad extension to cycle recent windows

Tags:

haskell

xmonad

I find it a bit awkward in xmonad to switch back and forth between two windows. Is there an extension (or a part of core xmonad) which allows this?

For example, I want to switch between firefox and emacs often, and they might not be in the same workspace. I currently do this using gotoMenu by typing M-g firefox<cr> and M-g emacs<cr> but this is awkward, especially if there's more than one instance of either app. Ideally I'd like a single shortcut to perform an action like give-focus-to-most-recently-used-unfocussed-window, which I could just press over and over to switch back and forth.

like image 367
Matthew Gilliard Avatar asked Dec 18 '13 09:12

Matthew Gilliard


1 Answers

XMonad.Actions.GroupNavigation seems to be a perfect fit. To let the module track your window history, make sure that logHook invokes historyHook. For example:

import XMonad.Actions.GroupNavigation
...
main = xmonad $ defaultConfig {
   ...
   , logHook = myLogHook xmobars >> historyHook
}

Then create a key binding for the following expression, which will toggle between the current and most recent window.

("M-x", nextMatch History (return True))
like image 135
Garrett Avatar answered Nov 23 '22 22:11

Garrett