From c73e5ad6d402a847c67b55bf4a3553841a71bf63 Mon Sep 17 00:00:00 2001 From: gopsychonauts Date: Fri, 4 May 2012 08:23:39 +0200 Subject: UrgencyHooks made available as Window -> X () functions Ignore-this: 6a57cae1d693109b7e27c6471d04f50f 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. darcs-hash:20120504062339-1e6bb-c452c421b9598394f422d90e4875aa7f834bf62f.gz --- XMonad/Hooks/UrgencyHook.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'XMonad/Hooks/UrgencyHook.hs') diff --git a/XMonad/Hooks/UrgencyHook.hs b/XMonad/Hooks/UrgencyHook.hs index 4ecfca3..495c576 100644 --- a/XMonad/Hooks/UrgencyHook.hs +++ b/XMonad/Hooks/UrgencyHook.hs @@ -68,6 +68,7 @@ module XMonad.Hooks.UrgencyHook ( SpawnUrgencyHook(..), UrgencyHook(urgencyHook), Interval, + borderUrgencyHook, focusHook, spawnUrgencyHook, stdoutUrgencyHook ) where import XMonad @@ -390,9 +391,12 @@ suppressibleWindows Never = return [] -- | The class definition, and some pre-defined instances. -class (Read h, Show h) => UrgencyHook h where +class UrgencyHook h where urgencyHook :: h -> Window -> X () +instance UrgencyHook (Window -> X ()) where + urgencyHook = id + data NoUrgencyHook = NoUrgencyHook deriving (Read, Show) instance UrgencyHook NoUrgencyHook where @@ -420,6 +424,7 @@ instance UrgencyHook DzenUrgencyHook where > withUrgencyHook FocusHook $ myconfig { ... -} +focusHook = urgencyHook FocusHook data FocusHook = FocusHook deriving (Read, Show) instance UrgencyHook FocusHook where @@ -435,6 +440,8 @@ instance UrgencyHook FocusHook where -- (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.) + +borderUrgencyHook = urgencyHook . BorderUrgencyHook data BorderUrgencyHook = BorderUrgencyHook { urgencyBorderColor :: !String } 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 -- you provide. (Make sure to add a space if you need it.) Do your crazy -- xcompmgr thing. +spawnUrgencyHook = urgencyHook . SpawnUrgencyHook newtype SpawnUrgencyHook = SpawnUrgencyHook String deriving (Read, Show) instance UrgencyHook SpawnUrgencyHook where urgencyHook (SpawnUrgencyHook prefix) w = spawn $ prefix ++ show w -- | For debugging purposes, really. +stdoutUrgencyHook = urgencyHook StdoutUrgencyHook data StdoutUrgencyHook = StdoutUrgencyHook deriving (Read, Show) instance UrgencyHook StdoutUrgencyHook where -- cgit v1.2.3