mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-07 15:31:54 -07:00
UrgencyHooks made available as Window -> X () functions
Adds an UrgencyHook instance for the type Window -> X (), allowing any such functions to be used directly as UrgencyHooks. The Show and Read constraints were removed from the UrgencyHook class in order to permit this; these constraints were required only in a historical implementation of the module, which used a layout modifier. All existing configurations using UrgencyHooks should remain fully functional. New configs may make use of this modification by declaring their UrgencyHook as a simple Window -> X () function.
This commit is contained in:
@@ -68,6 +68,7 @@ module XMonad.Hooks.UrgencyHook (
|
|||||||
SpawnUrgencyHook(..),
|
SpawnUrgencyHook(..),
|
||||||
UrgencyHook(urgencyHook),
|
UrgencyHook(urgencyHook),
|
||||||
Interval,
|
Interval,
|
||||||
|
borderUrgencyHook, focusHook, spawnUrgencyHook, stdoutUrgencyHook
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
@@ -390,9 +391,12 @@ suppressibleWindows Never = return []
|
|||||||
|
|
||||||
-- | The class definition, and some pre-defined instances.
|
-- | The class definition, and some pre-defined instances.
|
||||||
|
|
||||||
class (Read h, Show h) => UrgencyHook h where
|
class UrgencyHook h where
|
||||||
urgencyHook :: h -> Window -> X ()
|
urgencyHook :: h -> Window -> X ()
|
||||||
|
|
||||||
|
instance UrgencyHook (Window -> X ()) where
|
||||||
|
urgencyHook = id
|
||||||
|
|
||||||
data NoUrgencyHook = NoUrgencyHook deriving (Read, Show)
|
data NoUrgencyHook = NoUrgencyHook deriving (Read, Show)
|
||||||
|
|
||||||
instance UrgencyHook NoUrgencyHook where
|
instance UrgencyHook NoUrgencyHook where
|
||||||
@@ -420,6 +424,7 @@ instance UrgencyHook DzenUrgencyHook where
|
|||||||
|
|
||||||
> withUrgencyHook FocusHook $ myconfig { ...
|
> withUrgencyHook FocusHook $ myconfig { ...
|
||||||
-}
|
-}
|
||||||
|
focusHook = urgencyHook FocusHook
|
||||||
data FocusHook = FocusHook deriving (Read, Show)
|
data FocusHook = FocusHook deriving (Read, Show)
|
||||||
|
|
||||||
instance UrgencyHook FocusHook where
|
instance UrgencyHook FocusHook where
|
||||||
@@ -435,6 +440,8 @@ instance UrgencyHook FocusHook where
|
|||||||
-- (This should be @urgentBorderColor@ but that breaks "XMonad.Layout.Decoration".
|
-- (This should be @urgentBorderColor@ but that breaks "XMonad.Layout.Decoration".
|
||||||
-- @borderColor@ breaks anyone using 'XPConfig' from "XMonad.Prompt". We need to
|
-- @borderColor@ breaks anyone using 'XPConfig' from "XMonad.Prompt". We need to
|
||||||
-- think a bit more about namespacing issues, maybe.)
|
-- think a bit more about namespacing issues, maybe.)
|
||||||
|
|
||||||
|
borderUrgencyHook = urgencyHook . BorderUrgencyHook
|
||||||
data BorderUrgencyHook = BorderUrgencyHook { urgencyBorderColor :: !String }
|
data BorderUrgencyHook = BorderUrgencyHook { urgencyBorderColor :: !String }
|
||||||
deriving (Read, Show)
|
deriving (Read, Show)
|
||||||
|
|
||||||
@@ -458,12 +465,14 @@ dzenUrgencyHook = DzenUrgencyHook { duration = seconds 5, args = [] }
|
|||||||
-- | Spawn a commandline thing, appending the window id to the prefix string
|
-- | Spawn a commandline thing, appending the window id to the prefix string
|
||||||
-- you provide. (Make sure to add a space if you need it.) Do your crazy
|
-- you provide. (Make sure to add a space if you need it.) Do your crazy
|
||||||
-- xcompmgr thing.
|
-- xcompmgr thing.
|
||||||
|
spawnUrgencyHook = urgencyHook . SpawnUrgencyHook
|
||||||
newtype SpawnUrgencyHook = SpawnUrgencyHook String deriving (Read, Show)
|
newtype SpawnUrgencyHook = SpawnUrgencyHook String deriving (Read, Show)
|
||||||
|
|
||||||
instance UrgencyHook SpawnUrgencyHook where
|
instance UrgencyHook SpawnUrgencyHook where
|
||||||
urgencyHook (SpawnUrgencyHook prefix) w = spawn $ prefix ++ show w
|
urgencyHook (SpawnUrgencyHook prefix) w = spawn $ prefix ++ show w
|
||||||
|
|
||||||
-- | For debugging purposes, really.
|
-- | For debugging purposes, really.
|
||||||
|
stdoutUrgencyHook = urgencyHook StdoutUrgencyHook
|
||||||
data StdoutUrgencyHook = StdoutUrgencyHook deriving (Read, Show)
|
data StdoutUrgencyHook = StdoutUrgencyHook deriving (Read, Show)
|
||||||
|
|
||||||
instance UrgencyHook StdoutUrgencyHook where
|
instance UrgencyHook StdoutUrgencyHook where
|
||||||
|
Reference in New Issue
Block a user