aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-03-25 15:32:06 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:45 -0600
commit4b33192b56ea0f84f97d47e7656c186ec6ab7a68 (patch)
tree5fff307b3788278a7308700ea8af8dfa1d95238f /src/Main.hs
parent176b02a6f6f89c446311cb8df0cf43cd8e0e38a1 (diff)
downloadrde-4b33192b56ea0f84f97d47e7656c186ec6ab7a68.tar.gz
rde-4b33192b56ea0f84f97d47e7656c186ec6ab7a68.tar.bz2
rde-4b33192b56ea0f84f97d47e7656c186ec6ab7a68.zip
Added a way to do per-window bindings in XMonad.
This is particularly great for Chrome where one cannot remap the built-in bindings and some built-in bindings are really dumb (looking at you Ctrl+w!!).
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 5433c2e..b2a20d7 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -1,6 +1,7 @@
import XMonad
import Control.Monad.Trans.Class
+import Control.Monad.Reader
import XMonad.Hooks.ManageDocks (docks)
import System.Directory (getHomeDirectory)
import System.FilePath ((</>))
@@ -15,10 +16,13 @@ import Internal.Keys
import Internal.Layout
import Internal.Logger
import Internal.DMenu (menuCommandString)
+import Internal.Intercept
+import XMonad.Actions.WithAll (withAll)
import qualified XMonad as X
import qualified XMonad.StackSet as W
+
main = do
-- Execute some commands.
@@ -31,7 +35,15 @@ main = do
xmobar <- spawnXMobar
(=<<) X.xmonad $
- applyKeys $ ewmh $ docks $ def
+ applyKeys $ ewmh $ docks $ windowHooks (composeAll [
+ className =? "Google-chrome" --> composeAll [
+ -- The geniuses that made chrome decided that Ctrl+W should kill
+ -- the current tab! This makes it consistent with the rest of the
+ -- world ... ctrl+w deletes the last word (ctrl+backspace).
+ rebindKey (controlMask, xK_w) (controlMask, xK_BackSpace),
+ rebindKey (controlMask, xK_h) (0, xK_BackSpace)
+ ]
+ ]) $ def
{ terminal = "alacritty"
, modMask = mod3Mask
, borderWidth = 2
@@ -39,7 +51,7 @@ main = do
, focusedBorderColor = "#ff6c00"
, normalBorderColor = "#404040"
, layoutHook = myLayout
- , startupHook = spawn fp
+ , startupHook = spawn fp
, manageHook = composeAll [
isFullscreen --> doFullFloat
, className =? "Tilda" --> doFloat
@@ -55,7 +67,8 @@ main = do
, className =? "gnubby_ssh_prompt" --> doFloat
]
, workspaces = map return (['0'..'9'] ++ ['a'..'z'])
- , handleEventHook = fullscreenEventHook
+ , handleEventHook =
+ composeAll [fullscreenEventHook, interceptHook, remapHook]
, focusFollowsMouse = False
, clickJustFocuses = False
, logHook = xMobarLogHook xmobar
@@ -67,3 +80,15 @@ doCenterFloat =
centerRect :: W.RationalRect -> W.RationalRect
centerRect (W.RationalRect x y w h) = W.RationalRect ((1 - w) / 2) ((1 - h) / 2) w h
+
+
+windowHooks :: WindowHook -> XConfig l -> XConfig l
+windowHooks (Query readerT) config = do
+
+ config {
+ startupHook = do
+ withAll $ \w -> runReaderT readerT w
+ startupHook config,
+
+ manageHook = mappend (Query readerT >> return (Endo id)) (manageHook config)
+ }