mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
Merge pull request #878 from Chobbes/dynamic-status-bars-x
Update StatusBar library to use the X monad instead of IO.
This commit is contained in:
commit
2b079bf9fb
@ -4,6 +4,15 @@
|
|||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
|
||||||
|
* `XMonad.Hooks.StatusBars`
|
||||||
|
|
||||||
|
- Move status bar functions from the `IO` to the `X` monad to
|
||||||
|
allow them to look up information from `X`, like the screen
|
||||||
|
width. Existing configurations may need to use `io` from
|
||||||
|
`XMonad.Core` or `liftIO` from `Control.Monad.IO.Class` in
|
||||||
|
order to lift any existing `IO StatusBarConfig` values into
|
||||||
|
`X StatusBarConfig` values.
|
||||||
|
|
||||||
### New Modules
|
### New Modules
|
||||||
|
|
||||||
* `XMonad.Actions.Profiles`.
|
* `XMonad.Actions.Profiles`.
|
||||||
|
@ -452,7 +452,7 @@ instance ExtensionClass ActiveSBs where
|
|||||||
-- 'avoidStruts', check 'dynamicEasySBs'.
|
-- 'avoidStruts', check 'dynamicEasySBs'.
|
||||||
--
|
--
|
||||||
-- Heavily inspired by "XMonad.Hooks.DynamicBars"
|
-- Heavily inspired by "XMonad.Hooks.DynamicBars"
|
||||||
dynamicSBs :: (ScreenId -> IO StatusBarConfig) -> XConfig l -> XConfig l
|
dynamicSBs :: (ScreenId -> X StatusBarConfig) -> XConfig l -> XConfig l
|
||||||
dynamicSBs f conf = addAfterRescreenHook (updateSBs f) $ conf
|
dynamicSBs f conf = addAfterRescreenHook (updateSBs f) $ conf
|
||||||
{ startupHook = startupHook conf >> killAllStatusBars >> updateSBs f
|
{ startupHook = startupHook conf >> killAllStatusBars >> updateSBs f
|
||||||
, logHook = logHook conf >> logSBs
|
, logHook = logHook conf >> logSBs
|
||||||
@ -462,7 +462,7 @@ dynamicSBs f conf = addAfterRescreenHook (updateSBs f) $ conf
|
|||||||
-- resulting config and adds 'avoidStruts' to the
|
-- resulting config and adds 'avoidStruts' to the
|
||||||
-- layout.
|
-- layout.
|
||||||
dynamicEasySBs :: LayoutClass l Window
|
dynamicEasySBs :: LayoutClass l Window
|
||||||
=> (ScreenId -> IO StatusBarConfig)
|
=> (ScreenId -> X StatusBarConfig)
|
||||||
-> XConfig l
|
-> XConfig l
|
||||||
-> XConfig (ModifiedLayout AvoidStruts l)
|
-> XConfig (ModifiedLayout AvoidStruts l)
|
||||||
dynamicEasySBs f conf =
|
dynamicEasySBs f conf =
|
||||||
@ -471,7 +471,7 @@ dynamicEasySBs f conf =
|
|||||||
-- | Given the function to create status bars, update
|
-- | Given the function to create status bars, update
|
||||||
-- the status bars by killing those that shouldn't be
|
-- the status bars by killing those that shouldn't be
|
||||||
-- visible anymore and creates any missing status bars
|
-- visible anymore and creates any missing status bars
|
||||||
updateSBs :: (ScreenId -> IO StatusBarConfig) -> X ()
|
updateSBs :: (ScreenId -> X StatusBarConfig) -> X ()
|
||||||
updateSBs f = do
|
updateSBs f = do
|
||||||
actualScreens <- withWindowSet $ return . map W.screen . W.screens
|
actualScreens <- withWindowSet $ return . map W.screen . W.screens
|
||||||
(toKeep, toKill) <-
|
(toKeep, toKill) <-
|
||||||
@ -480,7 +480,7 @@ updateSBs f = do
|
|||||||
cleanSBs (map snd toKill)
|
cleanSBs (map snd toKill)
|
||||||
-- Create new status bars if needed
|
-- Create new status bars if needed
|
||||||
let missing = actualScreens \\ map fst toKeep
|
let missing = actualScreens \\ map fst toKeep
|
||||||
added <- io $ traverse (\s -> (s,) <$> f s) missing
|
added <- traverse (\s -> (s,) <$> f s) missing
|
||||||
traverse_ (sbStartupHook . snd) added
|
traverse_ (sbStartupHook . snd) added
|
||||||
XS.put (ASB (toKeep ++ added))
|
XS.put (ASB (toKeep ++ added))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user