aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-04-08 14:41:34 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:46 -0600
commit401b293fe6a726d24cf944e626c301262d726aad (patch)
tree6c459c551fea6b2d3c813a2d66126b0478717736
parenta1736a26f48c95574a682c260a311ef379e96352 (diff)
downloadrde-401b293fe6a726d24cf944e626c301262d726aad.tar.gz
rde-401b293fe6a726d24cf944e626c301262d726aad.tar.bz2
rde-401b293fe6a726d24cf944e626c301262d726aad.zip
Cleanup and more documentation.
-rw-r--r--src/Internal/Keys.hs23
-rw-r--r--src/Internal/Layout.hs26
-rw-r--r--src/Internal/LayoutZipper.hs9
3 files changed, 42 insertions, 16 deletions
diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs
index 748aae2..40ad0af 100644
--- a/src/Internal/Keys.hs
+++ b/src/Internal/Keys.hs
@@ -46,6 +46,7 @@ import XMonad.Actions.SpawnOn as SpawnOn
import qualified Data.Map as Map
import qualified XMonad.StackSet as W
+import Internal.LayoutZipper
import Internal.MouseMotion
import Internal.Windows
import Internal.Lib
@@ -401,13 +402,25 @@ keymap = runKeys $ do
altMod $ spawnX "sudo -A systemctl suspend && xsecurelock"
bind xK_space $ do
- justMod $ sendMessage NextLayout
- shiftMod $ sendMessage NextLayout
+ justMod $
+ doc "Use the next layout in the layout list." $ sendMessage ToNextLayout
+
+ altMod $
+ doc "Reset the layout to the default layout." $ sendMessage (SetLayout 0)
+
+ shiftMod $
+ doc "Use the previous layout in the layout list." $
+ sendMessage ToPreviousLayout
bind xK_t $ do
- justMod $ spawnX (terminal config)
- shiftMod $ withFocused $ windows . W.sink
- altMod $ spawnX (terminal config ++ " -t Floating\\ Term")
+ justMod $
+ doc "Spawn a terminal." $ spawnX (terminal config)
+
+ shiftMod $
+ doc "Sink the current window into the tiling." $ withFocused $ windows . W.sink
+
+ altMod $
+ doc "Spawn a floating terminal" $ spawnX (terminal config ++ " -t Floating\\ Term")
bind xK_v $
-- Allows repeated strokes of M-h and M-l to reduce and increase volume
diff --git a/src/Internal/Layout.hs b/src/Internal/Layout.hs
index 8613284..d883d18 100644
--- a/src/Internal/Layout.hs
+++ b/src/Internal/Layout.hs
@@ -1,6 +1,8 @@
-{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, KindSignatures, DataKinds, GADTs, RankNTypes #-}
module Internal.Layout where
+import GHC.TypeLits
+
import Internal.CornerLayout (Corner(..))
import Control.Arrow (second)
import XMonad.Hooks.ManageDocks
@@ -22,6 +24,8 @@ import XMonad
import XMonad.Core
import XMonad.Layout.NoBorders (smartBorders, noBorders)
+import Internal.LayoutZipper
+
import qualified Data.Map as M
import qualified XMonad.StackSet as W
@@ -33,15 +37,17 @@ myLayout =
ModifiedLayout (Flippable False) $
ModifiedLayout (HFlippable False) $
ModifiedLayout (Rotateable False) $
- spiral (6/7) |||
- (Corner (3/4) (3/100) :: Corner Window) |||
- ModifyDescription TallDescriptionModifier (Tall 1 (3/100) (1/2)) |||
- ModifyDescription ThreeColDescMod (ThreeCol 1 (3/100) (1/2)) |||
- Full |||
- Grid |||
- Dishes 2 (1/6) |||
- (MosaicAlt M.empty :: MosaicAlt Window) |||
- D.Dwindle D.R D.CW 1.5 1.1
+ layoutZipper $
+ spiral (6/7) |:
+ (Corner (3/4) (3/100) :: Corner Window) |:
+ ModifyDescription TallDescriptionModifier (Tall 1 (3/100) (1/2)) |:
+ ModifyDescription ThreeColDescMod (ThreeCol 1 (3/100) (1/2)) |:
+ Full |:
+ Grid |:
+ Dishes 2 (1/6) |:
+ (MosaicAlt M.empty :: MosaicAlt Window) |:
+ D.Dwindle D.R D.CW 1.5 1.1 |:
+ nil
data ModifyDescription m l a = ModifyDescription m (l a)
deriving (Show, Read)
diff --git a/src/Internal/LayoutZipper.hs b/src/Internal/LayoutZipper.hs
index d31360b..787fe4f 100644
--- a/src/Internal/LayoutZipper.hs
+++ b/src/Internal/LayoutZipper.hs
@@ -29,7 +29,11 @@ layoutZipper = LayoutZipper 0
nil :: LNil a
nil = LNil
-data NavigateLayout = ToNextLayout | ToPreviousLayout deriving (Typeable, Show)
+data NavigateLayout =
+ ToNextLayout |
+ ToPreviousLayout |
+ SetLayout Int
+ deriving (Typeable, Show)
instance Message NavigateLayout where
class LayoutSelect l a where
@@ -85,6 +89,9 @@ instance (Show (l a), Typeable l, LayoutSelect l a) => LayoutClass (LayoutZipper
if idx > 0
then return $ Just (LayoutZipper (idx - 1) l)
else return $ Just (LayoutZipper (nLayouts l - 1) l)
+ handleMessage (LayoutZipper _ l) (fromMessage -> Just (SetLayout i)) =
+ return $ Just $ LayoutZipper (max 0 $ min (nLayouts l - 1) $ i) l
+
handleMessage (LayoutZipper idx l) m = do
r <- update idx l $ \layout -> ((),) <$> handleMessage layout m
return $ LayoutZipper idx . snd <$> r