diff options
author | allbery.b <allbery.b@gmail.com> | 2012-02-25 09:26:16 +0100 |
---|---|---|
committer | allbery.b <allbery.b@gmail.com> | 2012-02-25 09:26:16 +0100 |
commit | af5cb8cf15c2b64ed2490b688c17fd60950d78d0 (patch) | |
tree | 45f4cc8c23a27d1383e4c5d1c350942f36319ac5 /XMonad | |
parent | 6f0f5ce628bfaa8988c07f6067dfd7a81f77390c (diff) | |
download | XMonadContrib-af5cb8cf15c2b64ed2490b688c17fd60950d78d0.tar.gz XMonadContrib-af5cb8cf15c2b64ed2490b688c17fd60950d78d0.tar.xz XMonadContrib-af5cb8cf15c2b64ed2490b688c17fd60950d78d0.zip |
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
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Hooks/UrgencyHook.hs | 26 |
1 files changed, 26 insertions, 0 deletions
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'. |