Cycle through all visible windows

Hi all, I’ve been trying to get XMonad set up for dual monitor, but have been struggling with finding a way to cycle focus through every window (not workspace) visible on either screen. The behavior would be similar to XMonad.Actions.WindowNavigation (the experimental module), but the cycling wouldn’t be bound to any direction, just cycle through all visible windows in the normal Alt-Tab sequence (left to right, top to bottom). I’ve found some code in a previous thread that supposedly manipulates the StackSet, but it didn’t work for me:
-- top of config import qualified XMonad.StackSet as W
-- somewhere at top level onAllWS f = windows $ \ws@W.StackSet{ W.current = c, W.visible = vs } -> let screenNext x = W.current . f $ ws { W.current = x } c':vs' = map screenNext (c:vs) in ws{ W.current = c', W.visible = vs' }
...
-- in keybindings: there are much more W.swap* W.focus* and W.shift* functions to use. ,((modm, xK_f), onAllWS W.focusDown) ,((modm, xK_d), onAllWS W.focusUp) ,((modm, xK_g), onAllWS W.swapMaster)
Unfortunately, I’m still too terrible at Haskell to fix whatever is wrong with the above code, and haven’t found any other modules that have the functionality I want. Any help would be appreciated! Thanks! Alex

On Thu, Feb 23, 2017 at 09:19:18AM -0600, alexsu04@gmail.com wrote:
Hi all,
I’ve been trying to get XMonad set up for dual monitor, but have been struggling with finding a way to cycle focus through every window (not workspace) visible on either screen. The behavior would be similar to XMonad.Actions.WindowNavigation (the experimental module), but the cycling wouldn’t be bound to any direction, just cycle through all visible windows in the normal Alt-Tab sequence (left to right, top to bottom).
I’ve found some code in a previous thread that supposedly manipulates the StackSet, but it didn’t work for me:
-- top of config import qualified XMonad.StackSet as W
-- somewhere at top level onAllWS f = windows $ \ws@W.StackSet{ W.current = c, W.visible = vs } -> let screenNext x = W.current . f $ ws { W.current = x } c':vs' = map screenNext (c:vs) in ws{ W.current = c', W.visible = vs' }
...
-- in keybindings: there are much more W.swap* W.focus* and W.shift* functions to use. ,((modm, xK_f), onAllWS W.focusDown) ,((modm, xK_d), onAllWS W.focusUp) ,((modm, xK_g), onAllWS W.swapMaster)
Unfortunately, I’m still too terrible at Haskell to fix whatever is wrong with the above code, and haven’t found any other modules that have the functionality I want. Any help would be appreciated!
Have you looked at XMonad.Actions.CycleWS? I use it to cycle through all workspaces with windows in them. My config is customized beyond the standard XMonad config so you'd have to adapt it to your needs: https://github.com/listx/syscfg/blob/master/xmonad/xmonad.hs#L150 Another alternative might be XMonad.Actions.GridSelect as it gives you a popup of all open windows (not workspaces). Best, Linus
Thanks!
Alex
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

Thanks for the response!
Cycling through workspaces and then cycling focus isn't exactly what I was
looking for, neither is GridSelect. Ideally, the behavior would be just be
to move the currently focused window to the next window on any visible
screen and cycle through (changing workspaces as necessary), whereas right
now Alt-Tab is limited to cycling focus through windows on the focused
workspace. There wouldn't be any screen swapping, just basically being able
to Alt-Tab across the two physical screens that I have.
On Thu, Feb 23, 2017 at 1:49 PM, Linus Arver
On Thu, Feb 23, 2017 at 09:19:18AM -0600, alexsu04@gmail.com wrote:
Hi all,
I’ve been trying to get XMonad set up for dual monitor, but have been
struggling with finding a way to cycle focus through every window (not workspace) visible on either screen. The behavior would be similar to XMonad.Actions.WindowNavigation (the experimental module), but the cycling wouldn’t be bound to any direction, just cycle through all visible windows in the normal Alt-Tab sequence (left to right, top to bottom).
I’ve found some code in a previous thread that supposedly manipulates
the StackSet, but it didn’t work for me:
-- top of config import qualified XMonad.StackSet as W
-- somewhere at top level onAllWS f = windows $ \ws@W.StackSet{ W.current = c, W.visible = vs }
let screenNext x = W.current . f $ ws { W.current = x } c':vs' = map screenNext (c:vs) in ws{ W.current = c', W.visible = vs' }
...
-- in keybindings: there are much more W.swap* W.focus* and W.shift* functions to use. ,((modm, xK_f), onAllWS W.focusDown) ,((modm, xK_d), onAllWS W.focusUp) ,((modm, xK_g), onAllWS W.swapMaster)
Unfortunately, I’m still too terrible at Haskell to fix whatever is wrong with the above code, and haven’t found any other modules that have
-> the functionality I want. Any help would be appreciated!
Have you looked at XMonad.Actions.CycleWS? I use it to cycle through all workspaces with windows in them. My config is customized beyond the standard XMonad config so you'd have to adapt it to your needs: https://github.com/listx/syscfg/blob/master/xmonad/xmonad.hs#L150
Another alternative might be XMonad.Actions.GridSelect as it gives you a popup of all open windows (not workspaces).
Best, Linus
Thanks!
Alex
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

Alex Su
Thanks for the response!
Cycling through workspaces and then cycling focus isn't exactly what I was looking for, neither is GridSelect. Ideally, the behavior would be just be to move the currently focused window to the next window on any visible screen and cycle through (changing workspaces as necessary), whereas right now Alt-Tab is limited to cycling focus through windows on the focused workspace. There wouldn't be any screen swapping, just basically being able to Alt-Tab across the two physical screens that I have.
I think you want to bind Alt-Tab to `windowGo` from XMonad.Actions.Navigation2D: https://hackage.haskell.org/package/xmonad-contrib-0.13/docs/XMonad-Actions-... -- Peter Jones, Founder, Devalot.com Defending the honor of good code

Correct me if I am wrong, but it looks to me like the windowGo function
accepts also a directional input.
I think I've tried that module, but whenever I have the case that I have a
window to the left, then windows stacked on top of each other, then another
window on the next screen over, just binding Alt-Tab to windowGo L for
instance skips certain windows in the cycle, in this case the window on the
first screen that is stacked under another.
On Thu, Feb 23, 2017 at 2:23 PM, Peter Jones
Alex Su
writes: Thanks for the response!
Cycling through workspaces and then cycling focus isn't exactly what I was looking for, neither is GridSelect. Ideally, the behavior would be just be to move the currently focused window to the next window on any visible screen and cycle through (changing workspaces as necessary), whereas right now Alt-Tab is limited to cycling focus through windows on the focused workspace. There wouldn't be any screen swapping, just basically being able to Alt-Tab across the two physical screens that I have.
I think you want to bind Alt-Tab to `windowGo` from XMonad.Actions.Navigation2D:
https://hackage.haskell.org/package/xmonad-contrib-0.13/ docs/XMonad-Actions-Navigation2D.html
-- Peter Jones, Founder, Devalot.com Defending the honor of good code
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

Alex Su
Correct me if I am wrong, but it looks to me like the windowGo function accepts also a directional input.
I think I've tried that module, but whenever I have the case that I have a window to the left, then windows stacked on top of each other, then another window on the next screen over, just binding Alt-Tab to windowGo L for instance skips certain windows in the cycle, in this case the window on the first screen that is stacked under another.
Correct. `windowGo` won't help you if you have windows stacked on top of one another. Assuming you are talking about floating layers, you'd have to use something like `switchLayer` first before `windowGo`. Another thing to consider as an alternative is: https://hackage.haskell.org/package/xmonad-contrib-0.13/docs/XMonad-Prompt-W... -- Peter Jones, Founder, Devalot.com Defending the honor of good code

No the windows are in the same layer and not floating. They are tiled, but
just split the screen in half top and bottom in the right half of the
screen (I'm using the default Tall layout).
Xprompt would be okay, but I was hoping someone might know about how to
come up with a StackSet hack similar to the code in my first post that
would work, or be able to point out what was wrong with it.
I'm a little surprised that there's no module that supports this already...
Thanks for your help so far though!
On Thu, Feb 23, 2017 at 3:03 PM, Peter Jones
Correct me if I am wrong, but it looks to me like the windowGo function accepts also a directional input.
I think I've tried that module, but whenever I have the case that I have a window to the left, then windows stacked on top of each other, then another window on the next screen over, just binding Alt-Tab to windowGo L for instance skips certain windows in the cycle, in this case the window on
Alex Su
writes: the first screen that is stacked under another.
Correct. `windowGo` won't help you if you have windows stacked on top of one another. Assuming you are talking about floating layers, you'd have to use something like `switchLayer` first before `windowGo`.
Another thing to consider as an alternative is:
https://hackage.haskell.org/package/xmonad-contrib-0.13/ docs/XMonad-Prompt-Window.html
-- Peter Jones, Founder, Devalot.com Defending the honor of good code
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

I’ve been trying to get XMonad set up for dual monitor, but have been struggling with finding a way to cycle focus through every window (not workspace) visible on either screen. The behavior would be similar to XMonad.Actions.WindowNavigation (the experimental module), but the cycling wouldn’t be bound to any direction, just cycle through all visible windows in the normal Alt-Tab sequence (left to right, top to bottom).
I’ve found some code in a previous thread that supposedly manipulates the StackSet, but it didn’t work for me:
-- top of config import qualified XMonad.StackSet as W
-- somewhere at top level onAllWS f = windows $ \ws@W.StackSet{ W.current = c, W.visible = vs } -> let screenNext x = W.current . f $ ws { W.current = x } c':vs' = map screenNext (c:vs) in ws{ W.current = c', W.visible = vs' }
...
-- in keybindings: there are much more W.swap* W.focus* and W.shift* functions to use. ,((modm, xK_f), onAllWS W.focusDown) ,((modm, xK_d), onAllWS W.focusUp) ,((modm, xK_g), onAllWS W.swapMaster)
Okay, let's start again. Why doesn't the code above work? Does it fail to compile or just fail to work the way you expect? If it fails to compile, what error messages are you getting from the compiler? -- Peter Jones, Founder, Devalot.com Defending the honor of good code

From what I can gather, the W.focus* functions take a StackSet and outputs another StackSet, which is then passed to the windows function to actually
The code compiles fine, just doesn't do what I expect, so no error messages.
perform the action. My understanding is that onAllWS is supposed to modify
the StackSet somehow to enable Alt-Tabbing across all windows on visible
screens; beyond that my Haskell is a little too elementary to understand
what is happening.
On Thu, Feb 23, 2017 at 3:34 PM, Peter Jones
writes: I’ve been trying to get XMonad set up for dual monitor, but have been struggling with finding a way to cycle focus through every window (not workspace) visible on either screen. The behavior would be similar to XMonad.Actions.WindowNavigation (the experimental module), but the cycling wouldn’t be bound to any direction, just cycle through all visible windows in the normal Alt-Tab sequence (left to right, top to bottom).
I’ve found some code in a previous thread that supposedly manipulates the StackSet, but it didn’t work for me:
-- top of config import qualified XMonad.StackSet as W
-- somewhere at top level onAllWS f = windows $ \ws@W.StackSet{ W.current = c, W.visible = vs } -> let screenNext x = W.current . f $ ws { W.current = x } c':vs' = map screenNext (c:vs) in ws{ W.current = c', W.visible = vs' }
...
-- in keybindings: there are much more W.swap* W.focus* and W.shift* functions to use. ,((modm, xK_f), onAllWS W.focusDown) ,((modm, xK_d), onAllWS W.focusUp) ,((modm, xK_g), onAllWS W.swapMaster)
Okay, let's start again.
Why doesn't the code above work? Does it fail to compile or just fail to work the way you expect? If it fails to compile, what error messages are you getting from the compiler?
-- Peter Jones, Founder, Devalot.com Defending the honor of good code
_______________________________________________ xmonad mailing list xmonad@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad

On Thu, Feb 23, 2017 at 4:46 PM, Alex Su
My understanding is that onAllWS is supposed to modify the StackSet somehow to enable Alt-Tabbing across all windows on visible screens; beyond that my Haskell is a little too elementary to understand what is happening.
The code you show runs a single action across the workspaces on all screens. `onAllWS W.focusDown` would switch the focus on all visible workspaces, otherwise leaving you where you were. This is not the droid you're looking for.... -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Any ideas about a more suitable droid?
On Thu, Feb 23, 2017 at 3:55 PM, Brandon Allbery
On Thu, Feb 23, 2017 at 4:46 PM, Alex Su
wrote: My understanding is that onAllWS is supposed to modify the StackSet somehow to enable Alt-Tabbing across all windows on visible screens; beyond that my Haskell is a little too elementary to understand what is happening.
The code you show runs a single action across the workspaces on all screens. `onAllWS W.focusDown` would switch the focus on all visible workspaces, otherwise leaving you where you were. This is not the droid you're looking for....
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Not really; I know more about workspace cycling. Don't even use alt-tab...
but I think focus cycling across workspaces like that will be difficult
given how focused the core is on stacks (which are part of a single
workspace).
On Thu, Feb 23, 2017 at 5:02 PM, Alex Su
Any ideas about a more suitable droid?
On Thu, Feb 23, 2017 at 3:55 PM, Brandon Allbery
wrote: On Thu, Feb 23, 2017 at 4:46 PM, Alex Su
wrote: My understanding is that onAllWS is supposed to modify the StackSet somehow to enable Alt-Tabbing across all windows on visible screens; beyond that my Haskell is a little too elementary to understand what is happening.
The code you show runs a single action across the workspaces on all screens. `onAllWS W.focusDown` would switch the focus on all visible workspaces, otherwise leaving you where you were. This is not the droid you're looking for....
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Hmm okay. I wonder how Windows.Actions.Navigate2D does it...maybe there's
some way to copy their implementation and just get rid of the directional
part; guess it's time for me to learn Haskell properly. Thanks!
On Thu, Feb 23, 2017 at 4:06 PM, Brandon Allbery
Not really; I know more about workspace cycling. Don't even use alt-tab... but I think focus cycling across workspaces like that will be difficult given how focused the core is on stacks (which are part of a single workspace).
On Thu, Feb 23, 2017 at 5:02 PM, Alex Su
wrote: Any ideas about a more suitable droid?
On Thu, Feb 23, 2017 at 3:55 PM, Brandon Allbery
wrote: On Thu, Feb 23, 2017 at 4:46 PM, Alex Su
wrote: My understanding is that onAllWS is supposed to modify the StackSet somehow to enable Alt-Tabbing across all windows on visible screens; beyond that my Haskell is a little too elementary to understand what is happening.
The code you show runs a single action across the workspaces on all screens. `onAllWS W.focusDown` would switch the focus on all visible workspaces, otherwise leaving you where you were. This is not the droid you're looking for....
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (6)
-
Alex Su
-
Alex Su
-
alexsu04@gmail.com
-
Brandon Allbery
-
Linus Arver
-
Peter Jones