aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Keys.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Rahm/Desktop/Keys.hs')
-rw-r--r--src/Rahm/Desktop/Keys.hs95
1 files changed, 53 insertions, 42 deletions
diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs
index f7aae3c..2f30763 100644
--- a/src/Rahm/Desktop/Keys.hs
+++ b/src/Rahm/Desktop/Keys.hs
@@ -61,6 +61,7 @@ import Rahm.Desktop.Layout.Flip (flipHorizontally, flipVertically)
import Rahm.Desktop.Layout.Rotate (rotateLayout)
import Rahm.Desktop.ScreenRotate (screenRotateForward, screenRotateBackward)
import Rahm.Desktop.Layout.ConsistentMosaic
+import Rahm.Desktop.Workspaces
type KeyMap l = XConfig l -> Map (KeyMask, KeySym) (X ())
type ButtonsMap l = XConfig l -> Map (KeyMask, Button) (Window -> X ())
@@ -264,6 +265,19 @@ keymap = runKeys $ do
sendMessage flipHorizontally
bind xK_g $ do
+ let selectWorkspace :: (KeySym, String) -> Maybe (X WorkspaceId)
+ selectWorkspace s = case s of
+ (_, [ch]) | isAlphaNum ch -> Just $ return [ch]
+ (_, "]") -> Just $ adjacentWorkspace next =<< getCurrentWorkspace
+ (_, "[") -> Just $ adjacentWorkspace prev =<< getCurrentWorkspace
+ (_, "}") -> Just $ adjacentScreen next
+ (_, "{") -> Just $ adjacentScreen prev
+ (_, "/") -> Just $ runMaybeT $ do
+ windowId <- askWindowId
+ workspaceWithWindow askWindowId
+ (_, " ") -> Just $ accompaningWorkspace <$> getCurrentWorkspace
+ _ -> Nothing
+
justMod $
doc "Goto a workspace\n\n\t\
@@ -279,35 +293,45 @@ keymap = runKeys $ do
\<space>: Jump to the accompaning workspace.\n\t\t\
\F1: display this help.\n" $
mapNextStringWithKeysym $ \_ keysym str ->
- case (keysym, str) of
- (_, [ch]) | isAlphaNum ch -> gotoWorkspace ch
- (_, "]") -> pushHistory $ withRelativeWorkspace next W.greedyView
- (_, "[") -> pushHistory $ withRelativeWorkspace prev W.greedyView
- (_, "}") -> windows screenRotateForward
- (_, "{") -> windows screenRotateBackward
- (_, " ") -> gotoAccompaningWorkspace
-
+ case ((keysym, str), selectWorkspace (keysym, str)) of
+ (_, Just w) -> pushHistory $ gotoWorkspace =<< w
-- Test binding. Tests that I can still submap keysyms alone (keys
-- where XLookupString won't return anything helpful.)
- (f, _) | f == xK_F1 ->
+ ((f, _), _) | f == xK_F1 ->
(safeSpawn "gxmessage" [
"-fn", "Source Code Pro",
documentation (keymap config)] :: X ())
-
_ -> return ()
+
shiftMod $
doc "Move the currently focused window to another workspace" $
- mapNextString $ \_ str ->
- case str of
- [ch] | isAlphaNum ch -> shiftToWorkspace ch
- "]" -> withRelativeWorkspace next W.shift
- "[" -> withRelativeWorkspace prev W.shift
+ mapNextStringWithKeysym $ \_ keysym str ->
+ case ((keysym, str), selectWorkspace (keysym, str)) of
+ (_, Just w) -> shiftToWorkspace =<< w
+ _ -> return ()
+
+ controlMod $
+ doc "Move the current focused window to another workspace and view that workspace" $
+ mapNextStringWithKeysym $ \_ keysym str ->
+ case ((keysym, str), selectWorkspace (keysym, str)) of
+ (_, Just w) -> pushHistory $ do
+ ws <- w
+ shiftToWorkspace ws
+ gotoWorkspace ws
+ _ -> return ()
+
+ altMod $
+ doc "Copy a window to the given workspace" $
+ mapNextStringWithKeysym $ \_ keysym str ->
+ case ((keysym, str), selectWorkspace (keysym, str)) of
+ (_, Just ws) -> windows . CopyWindow.copy =<< ws
_ -> return ()
+
shiftAltMod $
doc "Swap this workspace with another workspace (rename)." $
- mapNextString $ \_ str ->
- case str of
- [ch] | isAlphaNum ch -> swapWorkspace ch
+ mapNextStringWithKeysym $ \_ keysym str ->
+ case ((keysym, str), selectWorkspace (keysym, str)) of
+ (_, Just ws) -> swapWorkspace =<< ws
_ -> return ()
bind xK_h $ do
@@ -373,16 +397,6 @@ keymap = runKeys $ do
[ch] | isAlphaNum ch -> markCurrentWindow ch
_ -> return ()
- bind xK_n $ do
- justMod $
- doc "Shift to the next workspace." $
- withRelativeWorkspace next W.greedyView
-
- bind xK_p $ do
- justMod $
- doc "Shift to the previous workspace." $
- withRelativeWorkspace prev W.greedyView
-
bind xK_plus $ do
justMod $
doc "Increase the number of windows in the master region." $
@@ -511,14 +525,6 @@ keymap = runKeys $ do
doc "Less often used keybindings." $
subkeys $ do
- bind xK_g $ do
- (justMod -|- noMod) $
- doc "Copy a window to the given workspace" $
- mapNextString $ \_ s ->
- case s of
- [ch] | isAlphaNum ch -> windows (CopyWindow.copy s)
- _ -> return ()
-
bind xK_p $ do
(justMod -|- noMod) $
doc "Go to the prior window in the history" historyPrev
@@ -660,10 +666,12 @@ mouseMap = runButtons $ do
justMod $ \w -> focus w >> mouseResizeWindow w >> windows W.shiftMaster
bind button6 $
- justMod $ noWindow (withRelativeWorkspace prev W.greedyView)
+ justMod $
+ noWindow (viewAdjacent prev)
bind button7 $
- justMod $ noWindow (withRelativeWorkspace next W.greedyView)
+ justMod $
+ noWindow (viewAdjacent next)
bind button8 $
justMod $ noWindow mediaPrev
@@ -675,7 +683,7 @@ mouseMap = runButtons $ do
noMod $ subMouse $ do
bind button3 $
- noMod $ noWindow (gotoWorkspace 's')
+ noMod $ noWindow (gotoWorkspace "s")
bind button13 $ do
noMod $ noWindow $ click >> CopyWindow.kill1
@@ -714,7 +722,10 @@ mouseMap = runButtons $ do
bind button15 $ do
noMod $ subMouse $ do
- bind button13 $ noMod $ noWindow gotoAccompaningWorkspace
+ bind button13 $
+ noMod $
+ noWindow $
+ gotoWorkspace =<< (accompaningWorkspace <$> getCurrentWorkspace)
bind button15 $ do
noMod $ noWindow jumpToLast
@@ -723,8 +734,8 @@ mouseMap = runButtons $ do
let workspaceButtons = [
(button2, swapMaster),
- (button9, withRelativeWorkspace next W.greedyView),
- (button8, withRelativeWorkspace prev W.greedyView),
+ (button9, viewAdjacent next),
+ (button8, viewAdjacent prev),
(button4, windows W.focusUp),
(button5, windows W.focusDown),