mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
dynamicLogString
forces its result and recovers
Originally, `dynamicLogString` could have a bottom hidden in it and thereby crash the `logHook`. Under some circumstances (see #801) this could cause xmonad to get stuck. We now force the result, and `dynamicLogString` catches the exception and substitutes a message (currently "_|_"). Use `dynamicLogString'` for the old behavior.
This commit is contained in:
parent
29f0e03256
commit
4a97716d59
@ -100,6 +100,12 @@
|
|||||||
|
|
||||||
### Bug Fixes and Minor Changes
|
### Bug Fixes and Minor Changes
|
||||||
|
|
||||||
|
* `XMonad.Hooks.StatusBar.PP`
|
||||||
|
|
||||||
|
- `dynamicLogString` now forces its result and produces an error string if
|
||||||
|
it throws an exception. Use `dynamicLogString'` if for some reason you
|
||||||
|
need the old behavior.
|
||||||
|
|
||||||
* `XMonad.Util.EZConfig`
|
* `XMonad.Util.EZConfig`
|
||||||
|
|
||||||
- Added `remapKeysP`, which remaps keybindings from one binding to
|
- Added `remapKeysP`, which remaps keybindings from one binding to
|
||||||
|
@ -32,6 +32,7 @@ module XMonad.Hooks.StatusBar.PP (
|
|||||||
-- * Build your own formatter
|
-- * Build your own formatter
|
||||||
PP(..), def,
|
PP(..), def,
|
||||||
dynamicLogString,
|
dynamicLogString,
|
||||||
|
dynamicLogString',
|
||||||
dynamicLogWithPP,
|
dynamicLogWithPP,
|
||||||
|
|
||||||
-- * Predicates and formatters
|
-- * Predicates and formatters
|
||||||
@ -55,6 +56,7 @@ module XMonad.Hooks.StatusBar.PP (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.Reader
|
import Control.Monad.Reader
|
||||||
|
import Control.DeepSeq
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Prelude
|
import XMonad.Prelude
|
||||||
@ -181,7 +183,14 @@ dynamicLogWithPP pp = dynamicLogString pp >>= io . ppOutput pp
|
|||||||
-- allow for further processing, or use in some application other than
|
-- allow for further processing, or use in some application other than
|
||||||
-- a status bar.
|
-- a status bar.
|
||||||
dynamicLogString :: PP -> X String
|
dynamicLogString :: PP -> X String
|
||||||
dynamicLogString pp = do
|
dynamicLogString pp = userCodeDef "_|_" (dynamicLogString' pp)
|
||||||
|
|
||||||
|
-- | The guts of 'dynamicLogString'. Forces the result, so it may throw
|
||||||
|
-- an exception (most commonly because 'ppOrder' is non-total). Use
|
||||||
|
-- 'dynamicLogString' for a version that catches the exception and
|
||||||
|
-- produces an error string.
|
||||||
|
dynamicLogString' :: PP -> X String
|
||||||
|
dynamicLogString' pp = do
|
||||||
|
|
||||||
winset <- gets windowset
|
winset <- gets windowset
|
||||||
urgents <- readUrgents
|
urgents <- readUrgents
|
||||||
@ -199,7 +208,7 @@ dynamicLogString pp = do
|
|||||||
-- window title
|
-- window title
|
||||||
wt <- maybe (pure "") (fmap show . getName) . S.peek $ winset
|
wt <- maybe (pure "") (fmap show . getName) . S.peek $ winset
|
||||||
|
|
||||||
return $ sepBy (ppSep pp) . ppOrder pp $
|
return $! force $ sepBy (ppSep pp) . ppOrder pp $
|
||||||
[ ws
|
[ ws
|
||||||
, ppLayout pp ld
|
, ppLayout pp ld
|
||||||
, ppTitle pp $ ppTitleSanitize pp wt
|
, ppTitle pp $ ppTitleSanitize pp wt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user