diff options
author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-12 19:50:34 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-12 19:50:34 +0200 |
commit | e85b0920a06ad019754e1cb8e72eb6cc34cdeedc (patch) | |
tree | 34a28f6a54290bd7347f83efc4a7a5f387419f31 /Config.hs | |
parent | 14267de1e03841980ce99206c0cf63e40bfa6cca (diff) | |
download | xmobar-e85b0920a06ad019754e1cb8e72eb6cc34cdeedc.tar.gz xmobar-e85b0920a06ad019754e1cb8e72eb6cc34cdeedc.tar.bz2 |
use of existential types for plugin support
This patch, which *changes the configuration format*, adds easy plugin support
by using an existential type for storing the list of commands to be
executed. Adding a plugin is just a matter of writing the appropriate
instance of the Exec class, after importing Commands.hs.
I must thank Claus Reinke for the help in understanding the mysteries of
reading existential types. The Read instance of Runnable must be credited to
him. See here:
http://www.haskell.org/pipermail/haskell-cafe/2007-July/028227.html
darcs-hash:20070712175034-d6583-f10174bb3b0a9b4f6e08d05052c18f30e539b319.gz
Diffstat (limited to 'Config.hs')
-rw-r--r-- | Config.hs | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -16,9 +16,12 @@ module Config ( -- * Configuration -- $config Config (..) , defaultConfig + , runnableTypes ) where import Commands +import {-# SOURCE #-} Runnable + -- $config -- Configuration data type and default configuration @@ -33,7 +36,7 @@ data Config = , height :: Int -- ^ Window height , align :: String -- ^ text alignment , refresh :: Int -- ^ Refresh rate in tenth of seconds - , commands :: [(Command,Int)] -- ^ For setting the command, the command argujments + , commands :: [Runnable] -- ^ For setting the command, the command argujments -- and refresh rate for the programs to run (optional) , sepChar :: String -- ^ The character to be used for indicating -- commands in the output template (default '%') @@ -52,7 +55,10 @@ defaultConfig = , height = 15 , align = "left" , refresh = 10 - , commands = [(Memory [],10)] + , commands = [Run $ Memory [] 10] , sepChar = "%" , template = "Uptime: <fc=#00FF00>%uptime%</fc> ** <fc=#FF0000>%date%</fc> %memory%" } + +runnableTypes :: (Command,()) +runnableTypes = undefined :: (Command,()) |