mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Add BorderUrgencyHook to XMonad.Hooks.UrgencyHook
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 = Never it may work well enough. There is a report that if a new window is created at the wrong time, the wrong window may be marked urgent somehow. I seem to once again be revealing bugs in underlying packages, although a quick examination of X.H.UrgencyHook doesn't seem to show any way for the wrong window to be selected.
This commit is contained in:
parent
92e8f5ebef
commit
f6a050e5a3
@ -59,6 +59,7 @@ module XMonad.Hooks.UrgencyHook (
|
|||||||
dzenUrgencyHook,
|
dzenUrgencyHook,
|
||||||
DzenUrgencyHook(..),
|
DzenUrgencyHook(..),
|
||||||
NoUrgencyHook(..),
|
NoUrgencyHook(..),
|
||||||
|
BorderUrgencyHook(..),
|
||||||
FocusHook(..),
|
FocusHook(..),
|
||||||
minutes, seconds,
|
minutes, seconds,
|
||||||
-- * Stuff for developers:
|
-- * Stuff for developers:
|
||||||
@ -83,6 +84,7 @@ import Data.Bits (testBit)
|
|||||||
import Data.List (delete, (\\))
|
import Data.List (delete, (\\))
|
||||||
import Data.Maybe (listToMaybe, maybeToList)
|
import Data.Maybe (listToMaybe, maybeToList)
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
|
import System.IO (hPutStrLn, stderr)
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
--
|
--
|
||||||
@ -423,6 +425,30 @@ data FocusHook = FocusHook deriving (Read, Show)
|
|||||||
instance UrgencyHook FocusHook where
|
instance UrgencyHook FocusHook where
|
||||||
urgencyHook _ _ = focusUrgent
|
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.
|
-- | 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.
|
-- Defaults to a duration of five seconds, and no extra args to dzen.
|
||||||
-- See 'DzenUrgencyHook'.
|
-- See 'DzenUrgencyHook'.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user