4

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.

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
asu04
  • 41
  • 2

2 Answers2

2

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.

AlexJ136
  • 1,272
  • 1
  • 12
  • 21
  • 1
    Thanks for the response! I think that CycleWS lets me cycle through workspaces, but what I actually want to do is be able to move focus across windows, without actually cycling workspaces. So if I had two screens, with workspace 1 and 2 visible and I'm currently focused on a window in workspace 1, I would like to be able to bind alt-tab to move focus across all windows open in workspace 1 and 2. Does that make sense? – asu04 Feb 22 '17 at 19:14
0

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),
79E09796
  • 2,120
  • 1
  • 20
  • 33