[xmonad] list of visible workspaces

Bryan Huh bhh1988 at gmail.com
Thu Aug 2 19:19:43 CEST 2012


What I'm trying to do is prevent my focus from switching to a different 
screen if I mistakenly try to switch to an already visible workspace. I 
already am not using greedyView so I don't have the problem of the 
visible workspaces swapping on me. But suppose I have two screens and 
workspace 1 is on the left, workspace 2 is on the right. If I'm focused 
on the left screen, and I were to press mod-2, the focus switches to the 
screen on the right. If I now press mod-3 it will be the right screen 
which switches to workspace 3. This annoys me, because it effectively 
prevents me from cycling through workspaces on one screen. Greedyview I 
think would not have this issue, but the screen swapping confuses me. 
What I want is, when I'm on the left screen and I press mod-2, which is 
an already visible workspace, nothing should happen. No swapping of 
screens, and no moving of focus.

The part of my config I'm trying to modify to achieve this is the last 
line below (the commented line).

myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
    ... (some key mappings)
    ...
    [((m .|. modm, k), windows $ f i)
         | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
         , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]


        --  , i `notelem` (visible workspaces)
         ]

It seemed simple enough, but my understanding of Haskell is not quite 
there to understand the documentation.

Bryan

On 08/02/2012 09:53 AM, Brandon Allbery wrote:
> On Thu, Aug 2, 2012 at 12:29 PM, Bryan Huh <bhh1988 at gmail.com> wrote:
>
>> How do you get a list of visible workspaces (only those workspaces that
>> are displayed on the monitors)? Currently I get the entire list of
>> workspaces in my xmonad config with (XMonad.workspaces conf). It looks like
>> this command returns a list of strings, each of which denote a workspace
>> (i.e. ["1", "2"... ] ). But not sure how to get a list of only those which
>> are visible (I could also probably work with a list of hidden workspaces).
>>
> This depends to some extent on how you plan to use it; for example, when
> passing that list to an outside program using ppVisible or ppOrder from
> XMonad.Hooks.DynamicLog may be more convenient than other mechanisms.
>
> The general case, however, is roughly along the lines of
>
>      visibleWorkspaces :: X [WorkspaceId]
>      visibleWorkspaces = do
>        ws <- gets windowset
>        return $ map W.tag $ W.current ws : W.visible ws
>
> Note that this is impure, so you can't simply drop it in place of
> (workspaces conf).  If you give us more detail as to what you're trying to
> do, we can help you work it into your configuration properly.
>





More information about the xmonad mailing list