Discussion:
[xmonad] Cycle through all visible windows
a***@gmail.com
2017-02-23 15:19:18 UTC
Permalink
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).
-- top of config
import qualified XMonad.StackSet as W
-- somewhere at top level
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
Linus Arver
2017-02-23 19:49:09 UTC
Permalink
Post by a***@gmail.com
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).
-- top of config
import qualified XMonad.StackSet as W
-- somewhere at top level
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
Post by a***@gmail.com
Thanks!
Alex
_______________________________________________
xmonad mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Alex Su
2017-02-23 20:14:46 UTC
Permalink
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.
Post by a***@gmail.com
Post by a***@gmail.com
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).
Post by a***@gmail.com
I’ve found some code in a previous thread that supposedly manipulates
-- top of config
import qualified XMonad.StackSet as W
-- somewhere at top level
->
Post by a***@gmail.com
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.
Post by a***@gmail.com
,((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
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
Post by a***@gmail.com
Thanks!
Alex
_______________________________________________
xmonad mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Peter Jones
2017-02-23 20:23:49 UTC
Permalink
Post by 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-Navigation2D.html
--
Peter Jones, Founder, Devalot.com
Defending the honor of good code
Alex Su
2017-02-23 20:30:52 UTC
Permalink
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.
Post by Peter Jones
Post by Alex Su
Thanks for the response!
Cycling through workspaces and then cycling focus isn't exactly what I
was
Post by Alex Su
looking for, neither is GridSelect. Ideally, the behavior would be just
be
Post by Alex Su
to move the currently focused window to the next window on any visible
screen and cycle through (changing workspaces as necessary), whereas
right
Post by Alex Su
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
Post by Alex Su
to Alt-Tab across the two physical screens that I have.
I think you want to bind Alt-Tab to `windowGo` from
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
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Peter Jones
2017-02-23 21:03:33 UTC
Permalink
Post by 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-Window.html
--
Peter Jones, Founder, Devalot.com
Defending the honor of good code
Alex Su
2017-02-23 21:15:34 UTC
Permalink
This post might be inappropriate. Click to display it.
Peter Jones
2017-02-23 21:34:13 UTC
Permalink
Post by a***@gmail.com
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
-- top of config
import qualified XMonad.StackSet as W
-- somewhere at top level
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
Alex Su
2017-02-23 21:46:45 UTC
Permalink
The code compiles fine, just doesn't do what I expect, so no error messages.

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
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.
Post by a***@gmail.com
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
-- top of config
import qualified XMonad.StackSet as W
-- somewhere at top level
->
Post by a***@gmail.com
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.
Post by a***@gmail.com
,((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
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
Brandon Allbery
2017-02-23 21:55:57 UTC
Permalink
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
***@gmail.com ***@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
Alex Su
2017-02-23 22:02:25 UTC
Permalink
Any ideas about a more suitable droid?
Post by Brandon Allbery
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
unix, openafs, kerberos, infrastructure, xmonad
http://sinenomine.net
Brandon Allbery
2017-02-23 22:06:16 UTC
Permalink
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).
Post by Alex Su
Any ideas about a more suitable droid?
Post by Brandon Allbery
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
unix, openafs, kerberos, infrastructure, xmonad
http://sinenomine.net
--
brandon s allbery kf8nh sine nomine associates
***@gmail.com ***@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
Alex Su
2017-02-23 22:10:06 UTC
Permalink
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!
Post by 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).
Post by Alex Su
Any ideas about a more suitable droid?
Post by Brandon Allbery
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
unix, openafs, kerberos, infrastructure, xmonad
http://sinenomine.net
--
brandon s allbery kf8nh sine nomine associates
unix, openafs, kerberos, infrastructure, xmonad
http://sinenomine.net
Continue reading on narkive:
Loading...