Skip to content

Instantly share code, notes, and snippets.

@henninb
Created August 8, 2021 13:10
Show Gist options
  • Save henninb/a4750dc859ec7ed96fc2d48bd911294e to your computer and use it in GitHub Desktop.
Save henninb/a4750dc859ec7ed96fc2d48bd911294e to your computer and use it in GitHub Desktop.
subset of my xmonad config - trying to perform a greedyView with shift
--viewShift :: WorkspaceId -> Query (Endo (W.StackSet WorkspaceId l Window ScreenId sd))
--viewShift = doF . liftM2 (.) W.greedyView W.shift
keybinds :: XConfig Layout -> [((KeyMask, KeySym), NamedActions.NamedAction)]
keybinds conf = let
subKeys str ks = NamedActions.subtitle str : mkNamedKeymap conf ks
wsKeys = map show ([1..9] ++ [0] :: [Int])
zipM m nm ks as f = zipWith (\k d -> (m ++ k, NamedActions.addName nm $ f d)) ks as
zipM' m nm ks as f b = zipWith(\k d -> (m ++ k, NamedActions.addName nm $ f d b)) ks as
in
subKeys "Workspaces"
([]
++ zipM "M-" "View workspace" wsKeys [0..] (withNthWorkspace W.greedyView)
++ zipM "M-S-" "Move window to workspace" wsKeys [0..] (withNthWorkspace W.shift)
++ zipM "M-S-C-" "Copy window to workkspace" wsKeys [0..] (withNthWorkspace copy)
)
@henninb
Copy link
Author

henninb commented Aug 8, 2021

I am trying to perform a greedyView and shift in the code below (see the above for more context). I have searched github.com for examples of this same logic, however I am not finding a solution.

zipM "M-S-" "Move window to workspace" wsKeys [0..] (withNthWorkspace W.shift)

I thought I could combine them into one as follows, however this is not the answer.

zipM "M-S-" "Move window to workspace" wsKeys [0..] (withNthWorkspace W.greedyView . W.shift)

• Couldn't match type ‘W.StackSet String l0 a0 s0 sd0 -> W.StackSet String l0 a0 s0 sd0’ with ‘[Char]’ Expected type: String -> WindowSet -> WindowSet Actual type: String

@henninb
Copy link
Author

henninb commented Aug 8, 2021

Solutions 1:
++ zipM "M-S-" "Move window to workspace" wsKeys [0..] (withNthWorkspace (\i -> W.greedyView i . W.shift i))

Solution 2:
++ zipM "M-S-" "Move window to workspace" wsKeys [0..] (withNthWorkspace (liftM2 (.) W.greedyView W.shift))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment