aboutsummaryrefslogtreecommitdiff
path: root/src/Internal
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2020-03-20 16:10:03 -0600
committerJosh Rahm <rahm@google.com>2020-03-20 16:10:03 -0600
commit4c57dc73da6d8b0db8f84671619d11059da31775 (patch)
tree6061b29dc61dc39f222a974e0a97121fed823d22 /src/Internal
parent3c3c03b87a2d68f0115e33d16bb8093dd8b211f4 (diff)
downloadrde-4c57dc73da6d8b0db8f84671619d11059da31775.tar.gz
rde-4c57dc73da6d8b0db8f84671619d11059da31775.tar.bz2
rde-4c57dc73da6d8b0db8f84671619d11059da31775.zip
Added ability to cycle linearly through workspaces with win-N and win-P
Diffstat (limited to 'src/Internal')
-rw-r--r--src/Internal/Keys.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs
index 4828f27..3e7e054 100644
--- a/src/Internal/Keys.hs
+++ b/src/Internal/Keys.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE RankNTypes #-}
module Internal.Keys where
+import Data.Maybe (isJust)
import Debug.Trace
import Control.Applicative
import Prelude hiding ((!!))
@@ -32,6 +34,8 @@ applyKeys config@(XConfig {modMask = modm}) = do
withWindowNavigation (xK_k, xK_h, xK_j, xK_l) $
config { keys = ks }
+newtype Selector = Selector (forall a. (Eq a) => a -> [a] -> a)
+
data WinPrompt = WinPrompt
instance XPrompt WinPrompt where
@@ -71,6 +75,25 @@ newKeys =
swapSc f t (W.Screen ws a b) = W.Screen (swapWs f t ws) a b
+ relativeWorkspaceShift :: Selector -> X ()
+ relativeWorkspaceShift (Selector selector) = do
+ windows $ \ss -> do
+ let tags = sort $ (W.tag <$> filter (isJust . W.stack) (W.workspaces ss))
+ from = W.tag $ W.workspace $ W.current ss
+ to = selector from tags
+
+ W.greedyView to ss
+
+ nextWorkspace = Selector select
+ where select n (x:y:xs) | n == x = y
+ select n (x:xs) = select n xs
+ select n _ = n
+
+ prevWorkspace = Selector select
+ where select n (x:y:xs) | n == y = x
+ select n (x:xs) = select n xs
+ select n _ = n
+
swapWorkspace :: Char -> X ()
swapWorkspace toChar = do
windows $ \ss -> do
@@ -154,6 +177,9 @@ newKeys =
, ((modm, xK_space), sendMessage NextLayout)
+ , ((modm, xK_n), relativeWorkspaceShift nextWorkspace)
+ , ((modm, xK_p), relativeWorkspaceShift prevWorkspace)
+
, ((modm, xK_q), spawn "xmonad --recompile && xmonad --restart")
, ((modm, xK_z), sendMessage ToggleZoom)