CycleWS: shiftTo Next EmptyWS >> andThenSomehowFollow

Hi all, CycleWS's documentation suggests
If you want to follow the moved window, you can use both actions:
, ((modm .|. shiftMask, xK_Down), shiftToNext >> nextWS) , ((modm .|. shiftMask, xK_Up), shiftToPrev >> prevWS)
I'd like to achieve an action like 'shiftTo Next EmptyWS >> andThenSomehowFollow'. The goal is to move the window to the next empty workspace and then to follow it there. My silly attempts with , ((modm .|. shiftMask, xK_Down), followTo Next EmptyWS) using followTo d = shiftTo d >> moveTo d don't work. I suspect this is because I'm not properly saving the Next EmptyWS result prior to mutating the state. I'm a Haskell noob. Would some kind soul please show me the four lines I need to implement followTo? Thank you, Rhys

On Thu, Aug 8, 2013 at 11:28 AM, Rhys Ulerich
I'd like to achieve an action like 'shiftTo Next EmptyWS >> andThenSomehowFollow'. The goal is to move the window to the next empty workspace and then to follow it there.
My silly attempts with , ((modm .|. shiftMask, xK_Down), followTo Next EmptyWS) using followTo d = shiftTo d >> moveTo d don't work. I suspect this is because I'm not properly saving the Next EmptyWS result prior to mutating the state.
IIRC you can't easily get at the workspace it chooses, and of course after the window is shifted it's no longer empty. Better is to do it the other way around: import qualified XMonad.StackSet as W {- ... -} followTo which wsel = withFocused $ \w -> do moveTo which wsel here <- gets $ tag . workspace . current . windowset windows $ W.shift here w -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Hi Brandon,
import qualified XMonad.StackSet as W
{- ... -}
followTo which wsel = withFocused $ \w -> do moveTo which wsel here <- gets $ tag . workspace . current . windowset windows $ W.shift here w
Thank you. Would you please pass along the imports you're using? I needed to add an 'import XMonad.StackSet' but on 'xmonad --recompile' I am seeing Couldn't match expected type `WindowSet -> WindowSet' with actual type `StackSet i0 l0 a0 s0 sd0' In the return type of a call of `shift' In the second argument of `($)', namely `shift here w' In the expression: windows $ shift here w - Rhys

On Thu, Aug 8, 2013 at 12:04 PM, Rhys Ulerich
import qualified XMonad.StackSet as W
{- ... -}
followTo which wsel = withFocused $ \w -> do moveTo which wsel here <- gets $ tag . workspace . current . windowset windows $ W.shift here w
Thank you. Would you please pass along the imports you're using? I needed to add an 'import XMonad.StackSet' but on 'xmonad --recompile'
That was me typoing first thing in my morning :/ W.shiftWin is the correct function; W.shift uses the focused window (which won't exist as the workspace is empty). -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

None of the following code is tested. shiftTo and moveTo both take two arguments--a direction (like Next) and a condition (like EmptyWS). So you actually want followTo d t = (shiftTo d t) >> (moveTo d t) . However, this will shift to the next empty workspace, then move you to the next empty workspace, which is not the workspace you just shifted to since that one is full. It looks like you want to use findWorkspace, followed by both (windows . shift) and (windows . greedyView). I'll figure out the right implementation (or at least a plausible one) and send it in a second. Marshall On Thu, Aug 08, 2013 at 10:28:50AM -0500, Rhys Ulerich wrote:
Hi all,
CycleWS's documentation suggests
If you want to follow the moved window, you can use both actions:
, ((modm .|. shiftMask, xK_Down), shiftToNext >> nextWS) , ((modm .|. shiftMask, xK_Up), shiftToPrev >> prevWS)
I'd like to achieve an action like 'shiftTo Next EmptyWS >> andThenSomehowFollow'. The goal is to move the window to the next empty workspace and then to follow it there.
My silly attempts with , ((modm .|. shiftMask, xK_Down), followTo Next EmptyWS) using followTo d = shiftTo d >> moveTo d don't work. I suspect this is because I'm not properly saving the Next EmptyWS result prior to mutating the state.
I'm a Haskell noob. Would some kind soul please show me the four lines I need to implement followTo?
Thank you, Rhys
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

Maybe this will work: followTo :: Direction1D -> WSType -> X () followTo dir t = doTo dir t getSortByIndex (\w -> (windows (shift w)) >> (windows (greedyView w))) It parallels the code for shiftTo and moveTo in Actions/CycleWS.hs. Marshall On Thu, Aug 08, 2013 at 11:54:28AM -0400, Marshall Lochbaum wrote:
None of the following code is tested.
shiftTo and moveTo both take two arguments--a direction (like Next) and a condition (like EmptyWS). So you actually want followTo d t = (shiftTo d t) >> (moveTo d t) . However, this will shift to the next empty workspace, then move you to the next empty workspace, which is not the workspace you just shifted to since that one is full.
It looks like you want to use findWorkspace, followed by both (windows . shift) and (windows . greedyView). I'll figure out the right implementation (or at least a plausible one) and send it in a second.
Marshall
On Thu, Aug 08, 2013 at 10:28:50AM -0500, Rhys Ulerich wrote:
Hi all,
CycleWS's documentation suggests
If you want to follow the moved window, you can use both actions:
, ((modm .|. shiftMask, xK_Down), shiftToNext >> nextWS) , ((modm .|. shiftMask, xK_Up), shiftToPrev >> prevWS)
I'd like to achieve an action like 'shiftTo Next EmptyWS >> andThenSomehowFollow'. The goal is to move the window to the next empty workspace and then to follow it there.
My silly attempts with , ((modm .|. shiftMask, xK_Down), followTo Next EmptyWS) using followTo d = shiftTo d >> moveTo d don't work. I suspect this is because I'm not properly saving the Next EmptyWS result prior to mutating the state.
I'm a Haskell noob. Would some kind soul please show me the four lines I need to implement followTo?
Thank you, Rhys
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

And it requires you to import XMonad.StackSet (for shift and greedyView) and XMonad.Util.WorkspaceCompare (for getSortByIndex). Marshall On Thu, Aug 08, 2013 at 12:03:29PM -0400, Marshall Lochbaum wrote:
Maybe this will work:
followTo :: Direction1D -> WSType -> X () followTo dir t = doTo dir t getSortByIndex (\w -> (windows (shift w)) >> (windows (greedyView w)))
It parallels the code for shiftTo and moveTo in Actions/CycleWS.hs.
Marshall
On Thu, Aug 08, 2013 at 11:54:28AM -0400, Marshall Lochbaum wrote:
None of the following code is tested.
shiftTo and moveTo both take two arguments--a direction (like Next) and a condition (like EmptyWS). So you actually want followTo d t = (shiftTo d t) >> (moveTo d t) . However, this will shift to the next empty workspace, then move you to the next empty workspace, which is not the workspace you just shifted to since that one is full.
It looks like you want to use findWorkspace, followed by both (windows . shift) and (windows . greedyView). I'll figure out the right implementation (or at least a plausible one) and send it in a second.
Marshall
On Thu, Aug 08, 2013 at 10:28:50AM -0500, Rhys Ulerich wrote:
Hi all,
CycleWS's documentation suggests
If you want to follow the moved window, you can use both actions:
, ((modm .|. shiftMask, xK_Down), shiftToNext >> nextWS) , ((modm .|. shiftMask, xK_Up), shiftToPrev >> prevWS)
I'd like to achieve an action like 'shiftTo Next EmptyWS >> andThenSomehowFollow'. The goal is to move the window to the next empty workspace and then to follow it there.
My silly attempts with , ((modm .|. shiftMask, xK_Down), followTo Next EmptyWS) using followTo d = shiftTo d >> moveTo d don't work. I suspect this is because I'm not properly saving the Next EmptyWS result prior to mutating the state.
I'm a Haskell noob. Would some kind soul please show me the four lines I need to implement followTo?
Thank you, Rhys
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

followTo :: Direction1D -> WSType -> X () followTo dir t = doTo dir t getSortByIndex (\w -> (windows (shift w)) >> (windows (greedyView w)))
It parallels the code for shiftTo and moveTo in Actions/CycleWS.hs.
It does, perfectly. Thank you. That's arcane enough and useful enough it could be a nice addition to CycleWS. In particular, it would simplify the documentation example I quoted in my original note. Appreciate the help everyone, Rhys
participants (3)
-
Brandon Allbery
-
Marshall Lochbaum
-
Rhys Ulerich