mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
UrgencyHook: extract whenNotVisible
This commit is contained in:
parent
26b1a747c6
commit
0350117f47
@ -27,7 +27,7 @@ module XMonad.Hooks.UrgencyHook (
|
|||||||
SpawnUrgencyHook(..),
|
SpawnUrgencyHook(..),
|
||||||
dzenUrgencyHook, DzenUrgencyHook(..),
|
dzenUrgencyHook, DzenUrgencyHook(..),
|
||||||
UrgencyHook(urgencyHook),
|
UrgencyHook(urgencyHook),
|
||||||
seconds
|
whenNotVisible, seconds
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
@ -153,6 +153,12 @@ urgencyLayoutHook hook = eventHook $ WithUrgencyHook hook
|
|||||||
|
|
||||||
-- | The class definition, and some pre-defined instances.
|
-- | The class definition, and some pre-defined instances.
|
||||||
|
|
||||||
|
-- | Convenience method for those writing UrgencyHooks.
|
||||||
|
whenNotVisible :: Window -> X () -> X ()
|
||||||
|
whenNotVisible w act = do
|
||||||
|
visibles <- gets mapped
|
||||||
|
when (not $ S.member w visibles) act
|
||||||
|
|
||||||
class (Read h, Show h) => UrgencyHook h where
|
class (Read h, Show h) => UrgencyHook h where
|
||||||
urgencyHook :: h -> Window -> X ()
|
urgencyHook :: h -> Window -> X ()
|
||||||
|
|
||||||
@ -166,12 +172,11 @@ data DzenUrgencyHook = DzenUrgencyHook { duration :: Int, args :: [String] }
|
|||||||
|
|
||||||
instance UrgencyHook DzenUrgencyHook where
|
instance UrgencyHook DzenUrgencyHook where
|
||||||
urgencyHook DzenUrgencyHook { duration = d, args = a } w = do
|
urgencyHook DzenUrgencyHook { duration = d, args = a } w = do
|
||||||
visibles <- gets mapped
|
|
||||||
name <- getName w
|
name <- getName w
|
||||||
ws <- gets windowset
|
ws <- gets windowset
|
||||||
whenJust (W.findTag w ws) (flash name visibles)
|
whenJust (W.findTag w ws) (flash name)
|
||||||
where flash name visibles index =
|
where flash name index =
|
||||||
when (not $ S.member w visibles) $
|
whenNotVisible w $
|
||||||
dzenWithArgs (show name ++ " requests your attention on workspace " ++ index) a d
|
dzenWithArgs (show name ++ " requests your attention on workspace " ++ index) a d
|
||||||
|
|
||||||
-- | Flashes when a window requests your attention and you can't see it. Configurable
|
-- | Flashes when a window requests your attention and you can't see it. Configurable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user