| Copyright | (c) Ivan A. Malison |
|---|---|
| License | BSD3-style (see LICENSE) |
| Maintainer | Ivan A. Malison |
| Stability | unstable |
| Portability | unportable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
System.Taffybar.Context
Description
The System.Taffybar.Context module provides the core functionality of the
taffybar library. It gets its name from the Context record, which stores
runtime information and objects, which are used by many of the widgets that
taffybar provides. Context is typically accessed through the Reader
interface of TaffyIO.
Synopsis
- data TaffybarConfig = TaffybarConfig {}
- defaultTaffybarConfig :: TaffybarConfig
- appendHook :: TaffyIO () -> TaffybarConfig -> TaffybarConfig
- data BarConfig = BarConfig {
- strutConfig :: StrutConfig
- widgetSpacing :: Int32
- startWidgets :: [TaffyIO Widget]
- centerWidgets :: [TaffyIO Widget]
- endWidgets :: [TaffyIO Widget]
- barId :: Unique
- type BarConfigGetter = TaffyIO [BarConfig]
- showBarId :: BarConfig -> String
- type Taffy m v = ReaderT Context m v
- type TaffyIO v = ReaderT Context IO v
- 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
- 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
- refreshTaffyWindows :: TaffyIO ()
- exitTaffybar :: Context -> IO ()
- runX11 :: X11Property a -> TaffyIO a
- runX11Def :: a -> X11Property a -> TaffyIO a
- subscribeToAll :: Listener -> Taffy IO Unique
- subscribeToPropertyEvents :: [String] -> Listener -> Taffy IO Unique
- unsubscribe :: Unique -> Taffy IO ()
- taffyFork :: ReaderT r IO () -> ReaderT r IO ()
Configuration
data TaffybarConfig Source #
TaffybarConfig provides an advanced interface for configuring taffybar.
Through the getBarConfigsParam, it is possible to specify different
taffybar configurations depending on the number of monitors present, and even
to specify different taffybar configurations for each monitor.
Constructors
| TaffybarConfig | |
Fields
| |
Instances
| Default TaffybarConfig Source # | |
Defined in System.Taffybar.Context Methods def :: TaffybarConfig # | |
defaultTaffybarConfig :: TaffybarConfig Source #
Default values for a TaffybarConfig. Not usuable without at least
properly setting getBarConfigsParam.
appendHook :: TaffyIO () -> TaffybarConfig -> TaffybarConfig Source #
Append the provided TaffyIO hook to the startupHook of the given
TaffybarConfig.
Bars
BarConfig specifies the configuration for a single taffybar window.
Constructors
| BarConfig | |
Fields
| |
type BarConfigGetter = TaffyIO [BarConfig] Source #
Taffy monad
Context
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
| |
buildContext :: TaffybarConfig -> IO Context Source #
Build the Context for a taffybar process.
buildEmptyContext :: IO Context Source #
Build an empty taffybar context. This function is mostly useful for
invoking functions that yield TaffyIO values in a testing setting (e.g. in
a repl).
Context State
getState :: forall t. Typeable t => Taffy IO (Maybe t) Source #
Get a state value by type from the contextState field of Context.
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.
Control
refreshTaffyWindows :: TaffyIO () Source #
exitTaffybar :: Context -> IO () Source #
Destroys all top-level windows belonging to Taffybar, then requests the GTK main loop to exit.
This ensures that the windows disappear promptly. For GTK windows to be destroyed, the main loop still needs to be running.
X11
runX11Def :: a -> X11Property a -> TaffyIO a Source #
Use runX11 together with postX11RequestSyncProp on the provided
property. Return the provided default if Nothing is returned
postX11RequestSyncProp.
Event subscription
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.
unsubscribe :: Unique -> Taffy IO () Source #
Remove the listener associated with the provided Unique from the collection of listeners.