taffybar-3.2.2: A desktop bar similar to xmobar, but with more GUI

Copyright | (c) Ivan A. Malison
License | BSD3-style (see LICENSE)
Maintainer | Ivan A. Malison
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell2010

System.Taffybar.Context

Description

Synopsis

- logIO :: Priority -> String -> IO ()
- logC :: MonadIO m => Priority -> String -> m ()
- type Taffy m v = MonadIO m => ReaderT Context m v
- type TaffyIO v = ReaderT Context IO v
- type Listener = Event -> Taffy IO ()
- type SubscriptionList = [(Unique, Listener)]
- data Value = forall t.Typeable t => Value t
- fromValue :: forall t. Typeable t => Value -> Maybe t
- data BarConfig = BarConfig {
  - strutConfig :: StrutConfig
  - widgetSpacing :: Int32
  - startWidgets :: [TaffyIO Widget]
  - centerWidgets :: [TaffyIO Widget]
  - endWidgets :: [TaffyIO Widget]
  - barId :: Unique
  }
- type BarConfigGetter = TaffyIO [BarConfig]
- data TaffybarConfig = TaffybarConfig {
  - dbusClientParam :: Maybe Client
  - startupHook :: TaffyIO ()
  - getBarConfigsParam :: BarConfigGetter
  - cssPath :: Maybe FilePath
  - errorMsg :: Maybe String
  }
- appendHook :: TaffyIO () -> TaffybarConfig -> TaffybarConfig
- defaultTaffybarConfig :: TaffybarConfig
- data Context = Context {
  - x11ContextVar :: MVar X11Context
  - listeners :: MVar SubscriptionList
  - contextState :: MVar (Map TypeRep Value)
  - existingWindows :: MVar [(BarConfig, Window)]
  - sessionDBusClient :: Client
  - systemDBusClient :: Client
  - getBarConfigs :: BarConfigGetter
  - contextBarConfig :: Maybe BarConfig
  }
- buildContext :: TaffybarConfig -> IO Context
- buildEmptyContext :: IO Context
- buildBarWindow :: Context -> BarConfig -> IO Window
- refreshTaffyWindows :: TaffyIO ()
- forceRefreshTaffyWindows :: TaffyIO ()
- asksContextVar :: (r -> MVar b) -> ReaderT r IO b
- runX11 :: X11Property a -> TaffyIO a
- runX11Def :: a -> X11Property a -> TaffyIO a
- runX11Context :: MonadIO m => Context -> a -> X11Property a -> m a
- getState :: forall t. Typeable t => Taffy IO (Maybe t)
- getStateDefault :: Typeable t => Taffy IO t -> Taffy IO t
- putState :: forall t. Typeable t => Taffy IO t -> Taffy IO t
- taffyFork :: ReaderT r IO () -> ReaderT r IO ()
- startX11EventHandler :: Taffy IO ()
- unsubscribe :: Unique -> Taffy IO ()
- subscribeToAll :: Listener -> Taffy IO Unique
- subscribeToPropertyEvents :: [String] -> Listener -> Taffy IO Unique
- handleX11Event :: Event -> Taffy IO ()

# Documentation

logIO :: Priority -> String -> IO () Source #

logC :: MonadIO m => Priority -> String -> m () Source #

type Taffy m v = MonadIO m => ReaderT Context m v Source #

type TaffyIO v = ReaderT Context IO v Source #

type Listener = Event -> Taffy IO () Source #

type SubscriptionList = [(Unique, Listener)] Source #

data Value Source #

Constructors

forall t.Typeable t => Value t |

fromValue :: forall t. Typeable t => Value -> Maybe t Source #

data BarConfig Source #

Constructors

BarConfig |

Fields

- strutConfig :: StrutConfig
- widgetSpacing :: Int32
- startWidgets :: [TaffyIO Widget]
- centerWidgets :: [TaffyIO Widget]
- endWidgets :: [TaffyIO Widget]
- barId :: Unique

#### Instances

Instances details

Eq BarConfig Source # |
Instance details Defined in System.Taffybar.Context Methods (==) :: BarConfig -> BarConfig -> Bool Source # (/=) :: BarConfig -> BarConfig -> Bool Source #

type BarConfigGetter = TaffyIO [BarConfig] Source #

data TaffybarConfig Source #

Constructors

TaffybarConfig |

Fields

- dbusClientParam :: Maybe Client
- startupHook :: TaffyIO ()
- getBarConfigsParam :: BarConfigGetter
- cssPath :: Maybe FilePath
- errorMsg :: Maybe String

appendHook :: TaffyIO () -> TaffybarConfig -> TaffybarConfig Source #

defaultTaffybarConfig :: TaffybarConfig Source #

data Context Source #

A Context value holds all of the state associated with a single running instance of taffybar. It is typically accessed from a widget constructor through the TaffyIO monad transformer stack.

Constructors

Context |

Fields

- x11ContextVar :: MVar X11Context

  The X11Context that will be used to service X11Property requests.

- listeners :: MVar SubscriptionList

  The handlers which will be evaluated against incoming X11 events.

- contextState :: MVar (Map TypeRep Value)

  A collection of miscellaneous peices of state which are keyed by their types. Most new peices of state should go here, rather than in a new field in Context. State stored here is typically accessed through "getStateDefault".

- existingWindows :: MVar [(BarConfig, Window)]

  Used to track the windows that taffybar is currently controlling, and which BarConfig objects they are associated with.

- sessionDBusClient :: Client

  The shared user session DBus.Client.

- systemDBusClient :: Client

  The shared system session DBus.Client.

- getBarConfigs :: BarConfigGetter

  The action that will be evaluated to get the bar configs associated with each active monitor taffybar should run on.

- contextBarConfig :: Maybe BarConfig

  Populated with the BarConfig that resulted in the creation of a given widget, when its constructor is called. This lets widgets access thing like who their neighbors are. Note that the value of "contextBarConfig" is different for widgets belonging to bar windows on differnt monitors.

buildContext :: TaffybarConfig -> IO Context Source #

Build the Context for a taffybar process.

buildEmptyContext :: IO Context Source #

buildBarWindow :: Context -> BarConfig -> IO Window Source #

refreshTaffyWindows :: TaffyIO () Source #

Use the "barConfigGetter" field of Context to get the set of taffybar windows that should active. Will avoid recreating windows if there is already a window with the appropriate geometry and BarConfig.

forceRefreshTaffyWindows :: TaffyIO () Source #

asksContextVar :: (r -> MVar b) -> ReaderT r IO b Source #

runX11 :: X11Property a -> TaffyIO a Source #

runX11Def :: a -> X11Property a -> TaffyIO a Source #

runX11Context :: MonadIO m => Context -> a -> X11Property a -> m a Source #

getState :: forall t. Typeable t => Taffy IO (Maybe t) Source #

getStateDefault :: Typeable t => Taffy IO t -> Taffy IO t Source #

Like "putState", but avoids aquiring a lock if the value is already in the map.

putState :: forall t. Typeable t => Taffy IO t -> Taffy IO t Source #

Get a value of the type returned by the provided action from the the current taffybar state, unless the state does not exist, in which case the action will be called to populate the state map.

taffyFork :: ReaderT r IO () -> ReaderT r IO () Source #

A version of "forkIO" in TaffyIO.

startX11EventHandler :: Taffy IO () Source #

unsubscribe :: Unique -> Taffy IO () Source #

Remove the listener associated with the provided Unique from the collection of listeners.

subscribeToAll :: Listener -> Taffy IO Unique Source #

Subscribe to all incoming events on the X11 event loop. The returned Unique value can be used to unregister the listener using "unsuscribe".

subscribeToPropertyEvents :: [String] -> Listener -> Taffy IO Unique Source #

Subscribe to X11 PropertyEvents where the property changed is in the provided list.

handleX11Event :: Event -> Taffy IO () Source #