mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
add toggleRecentWS
Add toggleRecentWS to switch to the most recent workspace, with repeated use toggling between a pair of workspaces.
This commit is contained in:
parent
1e3448fc53
commit
dcf1f3e694
@ -19,7 +19,9 @@ module XMonad.Actions.CycleRecentWS (
|
|||||||
-- * Usage
|
-- * Usage
|
||||||
-- $usage
|
-- $usage
|
||||||
cycleRecentWS,
|
cycleRecentWS,
|
||||||
cycleWindowSets
|
cycleWindowSets,
|
||||||
|
toggleRecentWS,
|
||||||
|
toggleWindowSets
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad hiding (workspaces)
|
import XMonad hiding (workspaces)
|
||||||
@ -47,9 +49,18 @@ cycleRecentWS :: [KeySym] -- ^ A list of modifier keys used when invoking this a
|
|||||||
-> KeySym -- ^ Key used to switch to previous (more recent) workspace.
|
-> KeySym -- ^ Key used to switch to previous (more recent) workspace.
|
||||||
-- If it's the same as the nextWorkspace key, it is effectively ignored.
|
-- If it's the same as the nextWorkspace key, it is effectively ignored.
|
||||||
-> X ()
|
-> X ()
|
||||||
cycleRecentWS = cycleWindowSets options
|
cycleRecentWS = cycleWindowSets recentWS
|
||||||
where options w = map (view `flip` w) (recentTags w)
|
|
||||||
recentTags w = map tag $ tail (workspaces w) ++ [head (workspaces w)]
|
|
||||||
|
-- | Switch to the most recent workspace. The stack of most recently used workspaces
|
||||||
|
-- is updated, so repeated use toggles between a pair of workspaces.
|
||||||
|
toggleRecentWS :: X ()
|
||||||
|
toggleRecentWS = toggleWindowSets recentWS
|
||||||
|
|
||||||
|
|
||||||
|
recentWS :: WindowSet -> [WindowSet]
|
||||||
|
recentWS w = map (`view` w) recentTags
|
||||||
|
where recentTags = map tag $ tail (workspaces w) ++ [head (workspaces w)]
|
||||||
|
|
||||||
|
|
||||||
cycref :: [a] -> Int -> a
|
cycref :: [a] -> Int -> a
|
||||||
@ -83,3 +94,12 @@ cycleWindowSets genOptions mods keyNext keyPrev = do
|
|||||||
io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
|
io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
|
||||||
setOption 0
|
setOption 0
|
||||||
io $ ungrabKeyboard d currentTime
|
io $ ungrabKeyboard d currentTime
|
||||||
|
|
||||||
|
|
||||||
|
-- | Switch to the first of a finite list of WindowSets.
|
||||||
|
toggleWindowSets :: (WindowSet -> [WindowSet]) -> X ()
|
||||||
|
toggleWindowSets genOptions = do
|
||||||
|
options <- gets $ genOptions . windowset
|
||||||
|
case options of
|
||||||
|
[] -> return ()
|
||||||
|
o:_ -> windows (const o)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user