[xmonad] Re: XMonad.StackSet doesn't have focusLast

Ted Zlatanov tzz at lifelogs.com
Tue Dec 1 15:22:47 EST 2009

On Mon, 16 Nov 2009 12:55:49 -0500 Adam Vogt <vogt.adam at gmail.com> wrote: 

AV> * On Monday, November 16 2009, Ted Zlatanov wrote:
>> Similar to focusDown and focusUp in XMonad.StackSet, is there a way to
>> do focusLast?  I am learning Haskell but don't know it well enough to
>> write that function yet.
>> I saw something promising in
>> http://xmonad.org/xmonad-docs/xmonad-contrib/src/XMonad-Hooks-InsertPosition.html
>> (with a specific note wondering if focusLast should go into StackSet)
>> but don't know if it will work.  Any help is most welcome.
>> Thanks
>> Ted

AV> You can take the definition of focusLast' from that module (it's not
AV> exported, so you can't import it from H.InsertPositition without
AV> changing the export list of that module, and then recompiling)
AV> and pass it to the function XMonad.StackSet.modify':

I'm really, really inexperienced in Haskell so I wasn't able to do this
correctly.  I'll keep trying.

>> import qualified XMonad.StackSet as W

AV> ...

>> -- somewhere in your config
>> focusLast :: W.StackSet i l a s sd -> W.StackSet i l a s sd
>> focusLast = W.modify' focusLast'

>> focusLast' ::  W.Stack a -> W.Stack a
>> focusLast' st = let ws = W.integrate st
>> in W.Stack (last ws) (tail $ reverse ws) []

AV> I suppose that the easiest path for adding such functions to StackSet
AV> is to collect them somewhere in contrib first (to demonstrate that they
AV> actually are common functions).

I don't know the process, but would like to voice my support for this
function in particular.  Switching focus to the last window is very nice
and I'm used to it.  Right now I have to limit myself to 2 windows per
screen so that moving forward can act like focusLast.


More information about the xmonad mailing list