asu04
asu04

Reputation: 41

XMonad cycle through all windows on visible workspaces

I'm using XMonad on a dual screen set up, and would like to be able to cycle focus through every window visible on either screen (say, with alt+tab). The behavior would be similar to XMonad.Actions.WindowNavigation, except it wouldn't be bound to a direction, and just cycle through them in some order that makes sense (left to right, top to bottom for instance).

I've found some code here that claims to manipulate the StackSet to solve this problem, and I got it to compile but it wouldn't do what I wanted. Unfortunately my understanding of Haskell is pretty limited, so I've been unable to either write my own or fix whatever is wrong with the code above.

Upvotes: 4

Views: 1599

Answers (2)

79E09796
79E09796

Reputation: 2230

This functionality has since been added to xmonad-contrib by this pull request.

Example usage:

import XMonad.Actions.GroupNavigation

within the keys section

-- use Alt+Tab and Alt+Shift+Tab to change focus to different windows across workspaces
((alt,           xK_Tab   ), nextMatch Forward isOnAnyVisibleWS),
((alt .|. shift, xK_Tab   ), nextMatch Backward isOnAnyVisibleWS),

Upvotes: 0

AlexJ136
AlexJ136

Reputation: 1282

You can use the CycleWS module in xmonad-contrib

It has bindings that you can use to cycle through non-empty workspaces:

import XMonad.Actions.CycleWS

myKeys homeDir conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
    [ -- (your own bindings here)
    -- Cycle non-empty workspaces with mod+tab or mod+shift+tab
    , ((modm              , xK_Tab   ), moveTo Next NonEmptyWS)
    , ((modm .|. shiftMask, xK_Tab   ), moveTo Prev NonEmptyWS)
    ]

My full config is here if you want a complete example.

Upvotes: 2

Related Questions