@@ -60,6 +60,7 @@ module XMonad.Hooks.UrgencyHook (
60
60
FocusHook (.. ),
61
61
filterUrgencyHook , filterUrgencyHook' ,
62
62
minutes , seconds ,
63
+ askUrgent , doAskUrgent ,
63
64
-- * Stuff for developers:
64
65
readUrgents , withUrgents , clearUrgents' ,
65
66
StdoutUrgencyHook (.. ),
@@ -70,7 +71,7 @@ module XMonad.Hooks.UrgencyHook (
70
71
) where
71
72
72
73
import XMonad
73
- import XMonad.Prelude (delete , fromMaybe , listToMaybe , maybeToList , when , (\\) )
74
+ import XMonad.Prelude (fi , delete , fromMaybe , listToMaybe , maybeToList , when , (\\) )
74
75
import qualified XMonad.StackSet as W
75
76
76
77
import XMonad.Hooks.ManageHelpers (windowTag )
@@ -542,3 +543,28 @@ filterUrgencyHook skips = filterUrgencyHook' $ maybe False (`elem` skips) <$> wi
542
543
-- should never be marked urgent.
543
544
filterUrgencyHook' :: Query Bool -> Window -> X ()
544
545
filterUrgencyHook' q w = whenX (runQuery q w) (clearUrgents' [w])
546
+
547
+ -- | Mark the given window urgent.
548
+ --
549
+ -- (The implementation is a bit hacky: send a _NET_WM_STATE ClientMessage to
550
+ -- ourselves. This is so that we respect the 'SuppressWhen' of the configured
551
+ -- urgency hooks. If this module if ever migrated to the ExtensibleConf
552
+ -- infrastrcture, we'll then invoke markUrgent directly.)
553
+ askUrgent :: Window -> X ()
554
+ askUrgent w = withDisplay $ \ dpy -> do
555
+ rw <- asks theRoot
556
+ a_wmstate <- getAtom " _NET_WM_STATE"
557
+ a_da <- getAtom " _NET_WM_STATE_DEMANDS_ATTENTION"
558
+ let state_add = 1
559
+ let source_pager = 2
560
+ io $ allocaXEvent $ \ e -> do
561
+ setEventType e clientMessage
562
+ setClientMessageEvent' e w a_wmstate 32 [state_add, fi a_da, 0 , source_pager]
563
+ sendEvent dpy rw False (substructureRedirectMask .|. substructureNotifyMask) e
564
+
565
+ -- | Helper for 'ManageHook' that marks the window as urgent (unless
566
+ -- suppressed, see 'SuppressWhen'). Useful in
567
+ -- 'XMonad.Hooks.EwmhDesktops.activateLogHook' and also in combination with
568
+ -- "XMonad.Hooks.InsertPosition", "XMonad.Hooks.Focus".
569
+ doAskUrgent :: ManageHook
570
+ doAskUrgent = ask >>= \ w -> liftX (askUrgent w) >> return mempty
0 commit comments