From af5cb8cf15c2b64ed2490b688c17fd60950d78d0 Mon Sep 17 00:00:00 2001 From: "allbery.b" Date: Sat, 25 Feb 2012 09:26:16 +0100 Subject: Add BorderUrgencyHook to XMonad.Hooks.UrgencyHook Ignore-this: 9fac77914ff28a6e9eb830e8c9c7e21e BorderUrgencyHook is a new UrgencyHook usable with withUrgencyHook or withUrgencyHookC; it allows an urgent window to be given a different border color. This may not always work as intended, since UrgencyHook likes to assume that a window being visible is sufficient to disable urgency notification; but with suppressWhen darcs-hash:20120225082616-181ff-86834feb1bc8299474b0c6364f617af38c6222b7.gz --- XMonad/Hooks/UrgencyHook.hs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/XMonad/Hooks/UrgencyHook.hs b/XMonad/Hooks/UrgencyHook.hs index 6515943..4ecfca3 100644 --- a/XMonad/Hooks/UrgencyHook.hs +++ b/XMonad/Hooks/UrgencyHook.hs @@ -59,6 +59,7 @@ module XMonad.Hooks.UrgencyHook ( dzenUrgencyHook, DzenUrgencyHook(..), NoUrgencyHook(..), + BorderUrgencyHook(..), FocusHook(..), minutes, seconds, -- * Stuff for developers: @@ -83,6 +84,7 @@ import Data.Bits (testBit) import Data.List (delete, (\\)) import Data.Maybe (listToMaybe, maybeToList) import qualified Data.Set as S +import System.IO (hPutStrLn, stderr) -- $usage -- @@ -423,6 +425,30 @@ data FocusHook = FocusHook deriving (Read, Show) instance UrgencyHook FocusHook where urgencyHook _ _ = focusUrgent +-- | A hook that sets the border color of an urgent window. The color +-- will remain until the next time the window gains or loses focus, at +-- which point the standard border color from the XConfig will be applied. +-- You may want to use suppressWhen = Never with this: +-- +-- > withUrgencyHookC BorderUrgencyHook { urgencyBorderColor = "#ff0000" } urgencyConfig { suppressWhen = Never } ... +-- +-- (This should be @urgentBorderColor@ but that breaks "XMonad.Layout.Decoration". +-- @borderColor@ breaks anyone using 'XPConfig' from "XMonad.Prompt". We need to +-- think a bit more about namespacing issues, maybe.) +data BorderUrgencyHook = BorderUrgencyHook { urgencyBorderColor :: !String } + deriving (Read, Show) + +instance UrgencyHook BorderUrgencyHook where + urgencyHook BorderUrgencyHook { urgencyBorderColor = cs } w = + withDisplay $ \dpy -> io $ do + c' <- initColor dpy cs + case c' of + Just c -> setWindowBorder dpy w c + _ -> hPutStrLn stderr $ concat ["Warning: bad urgentBorderColor " + ,show cs + ," in BorderUrgencyHook" + ] + -- | Flashes when a window requests your attention and you can't see it. -- Defaults to a duration of five seconds, and no extra args to dzen. -- See 'DzenUrgencyHook'. -- cgit v1.2.3