I am trying to give focus to a window whenever the cursor moves on it.

Use case:

  1. window A focused by the cursor
  2. user moves focus with the keyboard
  3. user moves the mouse and expects the window below the cursor to activate

Instead of 3, I am required to move the cursor to another window, then back.

This exists, and seems to do exactly what I want. I can't make it work.

Here is what I have, see rows 121 and 122, or see the diff in case it's easier (there are a couple changes with indentation, I leave it here just to be sure not to remove anything relevant):

@@ -1,5 +1,6 @@
 import XMonad hiding ((|||))
 import XMonad.Actions.RotSlaves
+import XMonad.Actions.UpdateFocus
 import XMonad.Hooks.DynamicLog
 import XMonad.Hooks.EwmhDesktops
 import XMonad.Hooks.ManageDocks
@@ -111,12 +112,14 @@ myKeys =
          , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]

 main = do
-    xmproc <- spawnPipe "/usr/bin/xmobar ~/.xmonad/.xmobarrc -x 0"
-    --xmproc <- spawnPipe "~/.cabal/bin/xmobar ~/.xmonad/.xmobarrc -x 1"
-    xmonad $ withUrgencyHook NoUrgencyHook
-           $ defaultConfig {
+  xmproc <- spawnPipe "/usr/bin/xmobar ~/.xmonad/.xmobarrc -x 0"
+  xmonad
+    $ withUrgencyHook NoUrgencyHook
+    $ defaultConfig {
         workspaces = myWorkspaces
         , terminal = "gnome-terminal"
+        , startupHook = adjustEventInput
+        , handleEventHook = focusOnMouseMove
         , manageHook = myManageHook <+> manageHook defaultConfig
         , layoutHook = avoidStruts $ smartBorders $ myLayout
         , logHook = dynamicLogWithPP xmobarPP

xmonad version 0.12. I've tried not only mod+q, but also logging out and in.


Apparently, the pointer movement mask that focusOnMouseMove used is no longer implemented that way, which makes this contribution obsolete.

That is the answer I got on IRC:

Instead of setting up the startupHook, try to update the masks

, rootMask = rootMask defaultConfig .|. pointerMotionMask
, clientMask = clientMask defaultConfig .|. pointerMotionMask

That didn't work for me, but hey, good luck if someone else wants to try it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.