Skip to content
Snippets Groups Projects
Commit b8790e7e authored by Jens Nolte's avatar Jens Nolte
Browse files

Move runQBar to Server.hs, so it is easier to change the configuration

It is now much easier to write a custom Main.hs that generates a custom
bar configuration or that changes the argument parser.
parent 8d7fd2b2
No related branches found
No related tags found
No related merge requests found
module Main where module Main where
import QBar.Cli import QBar.Cli
import QBar.ControlSocket
import QBar.DefaultConfig import QBar.DefaultConfig
import QBar.Filter
import QBar.Server import QBar.Server
main :: IO () main :: IO ()
main = parseOptions >>= runQBar main = parseOptions >>= (runQBar generateDefaultBarConfig)
\ No newline at end of file
runQBar :: MainOptions -> IO ()
runQBar options@MainOptions{barCommand} = runCommand barCommand
where
runCommand BarServer = runBarConfiguration generateDefaultBarConfig options
runCommand NoFilter = sendIpc options $ SetFilter $ StaticFilter None
runCommand RainbowFilter = sendIpc options $ SetFilter $ AnimatedFilter Rainbow
\ No newline at end of file
...@@ -78,6 +78,9 @@ data BarUpdateChannel = BarUpdateChannel (IO ()) ...@@ -78,6 +78,9 @@ data BarUpdateChannel = BarUpdateChannel (IO ())
type BarUpdateEvent = Event.Event type BarUpdateEvent = Event.Event
type BarConfiguration = BarUpdateChannel -> Producer CachedBlock IO ()
defaultColor :: T.Text defaultColor :: T.Text
defaultColor = "#969896" defaultColor = "#969896"
......
...@@ -211,4 +211,12 @@ runBarConfiguration generateBarConfig options = do ...@@ -211,4 +211,12 @@ runBarConfiguration generateBarConfig options = do
renderLoop options handle barUpdateEvent initialOutput newBlockProducers renderLoop options handle barUpdateEvent initialOutput newBlockProducers
createCommandChan :: IO CommandChan createCommandChan :: IO CommandChan
createCommandChan = newTChanIO createCommandChan = newTChanIO
\ No newline at end of file
-- |Entry point.
runQBar :: BarConfiguration -> MainOptions -> IO ()
runQBar barConfiguration options@MainOptions{barCommand} = runCommand barCommand
where
runCommand BarServer = runBarConfiguration barConfiguration options
runCommand NoFilter = sendIpc options $ SetFilter $ StaticFilter None
runCommand RainbowFilter = sendIpc options $ SetFilter $ AnimatedFilter Rainbow
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment