hi3status-0.1.1.0: Status line for i3bar.

LicenseMIT
MaintainerJosh Kirklin (jjvk2@cam.ac.uk)
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Hi3Status.Block

Contents

Description

Blocks are the main components of a status line. A block is any instance of the Block class.

Synopsis

Class

class Block a where Source

Methods

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

data BlockM a Source

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 BlockDescriptions 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.