License | MIT |
---|---|
Maintainer | Josh Kirklin (jjvk2@cam.ac.uk) |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Blocks are the main components of a status line. A block is any instance of the
Block
class.
- class Block a where
- data BlockM a
- pushBlockDescription :: BlockDescription -> BlockM ()
- waitForUpdateSignal :: BlockM ()
- getUpdater :: BlockM (IO ())
- data BlockDescription = BlockDescription {}
- emptyBlockDescription :: BlockDescription
Class
runBlock :: a -> BlockM () Source
This function takes in a block, and returns a value of type
BlockM ()
, which is executed in its own thread when the status line
begins.
Monad
BlockM
is a monad responsible for controlling the operation of a block. Each block has two lines of communication with the main status line:
- The status line can tell the block that it needs updating.
- The block can push updates in the form of
BlockDescription
s to the status line, which will then be processed and submitted to i3bar.
pushBlockDescription :: BlockDescription -> BlockM () Source
Push a new block description to the status line.
waitForUpdateSignal :: BlockM () Source
Wait until an update is required.
getUpdater :: BlockM (IO ()) Source
Return the updater for this block, i.e. a value of the type IO ()
that
when run will request that the block be updated. This is useful when, for
example, we desire to set an update timer internal to the block itself:
updateInFiveSeconds :: BlockM () updateInFiveSeconds = do updater <- getUpdater liftIO $ forkIO $ do threadDelay 5000000 updater
Descriptions
data BlockDescription Source
A BlockDescription
contains everything needed by i3bar to properly render a block. This includes things like the text of a block, and the color of the text. For more information about each field, see the i3bar protocol at http://i3wm.org/docs/i3bar-protocol.html.
emptyBlockDescription :: BlockDescription Source
An empty block description, i.e. one with full_text = ""
, and everything else equal to Nothing
.