summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Config.hs
diff options
context:
space:
mode:
authorPavan Rikhi <pavan.rikhi@gmail.com>2018-03-17 22:48:24 -0400
committerjao <jao@gnu.org>2018-11-21 21:41:35 +0000
commit4d1402a1a7d87767267d48a77998e4fb13395b31 (patch)
tree17fd6160dc1fa9c8a0676a94bcf8d19b551c655c /src/Xmobar/Config.hs
parent9e2a5c7daddf683d4be7c318aefed3da3ea7a89a (diff)
downloadxmobar-4d1402a1a7d87767267d48a77998e4fb13395b31.tar.gz
xmobar-4d1402a1a7d87767267d48a77998e4fb13395b31.tar.bz2
Split Modules into Library & Executable Structure
Move the Main module to a new `app` directory. All other modules have been nested under the `Xmobar` name. Lots of module headers & imports were updated.
Diffstat (limited to 'src/Xmobar/Config.hs')
-rw-r--r--src/Xmobar/Config.hs170
1 files changed, 170 insertions, 0 deletions
diff --git a/src/Xmobar/Config.hs b/src/Xmobar/Config.hs
new file mode 100644
index 0000000..21b29fa
--- /dev/null
+++ b/src/Xmobar/Config.hs
@@ -0,0 +1,170 @@
+{-# LANGUAGE TypeOperators, CPP #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module : Xmobar.Config
+-- Copyright : (c) Andrea Rossato
+-- License : BSD-style (see LICENSE)
+--
+-- Maintainer : Jose A. Ortega Ruiz <jao@gnu.org>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- The configuration module of Xmobar, a text based status bar
+--
+-----------------------------------------------------------------------------
+
+module Xmobar.Config
+ ( -- * Configuration
+ -- $config
+ Config (..)
+ , XPosition (..), Align (..), Border(..)
+ , defaultConfig
+ , runnableTypes
+ ) where
+
+
+import Xmobar.Commands
+import {-# SOURCE #-} Xmobar.Runnable
+import Xmobar.Plugins.Monitors
+import Xmobar.Plugins.Date
+import Xmobar.Plugins.PipeReader
+import Xmobar.Plugins.BufferedPipeReader
+import Xmobar.Plugins.MarqueePipeReader
+import Xmobar.Plugins.CommandReader
+import Xmobar.Plugins.StdinReader
+import Xmobar.Plugins.XMonadLog
+import Xmobar.Plugins.EWMH
+import Xmobar.Plugins.Kbd
+import Xmobar.Plugins.Locks
+
+#ifdef INOTIFY
+import Xmobar.Plugins.Mail
+import Xmobar.Plugins.MBox
+#endif
+
+#ifdef DATEZONE
+import Xmobar.Plugins.DateZone
+#endif
+
+-- $config
+-- Configuration data type and default configuration
+
+-- | The configuration data type
+data Config =
+ Config { font :: String -- ^ Font
+ , additionalFonts :: [String] -- ^ List of alternative fonts
+ , wmClass :: String -- ^ X11 WM_CLASS property value
+ , wmName :: String -- ^ X11 WM_NAME property value
+ , bgColor :: String -- ^ Backgroud color
+ , fgColor :: String -- ^ Default font color
+ , position :: XPosition -- ^ Top Bottom or Static
+ , textOffset :: Int -- ^ Offset from top of window for text
+ , textOffsets :: [Int] -- ^ List of offsets for additionalFonts
+ , iconOffset :: Int -- ^ Offset from top of window for icons
+ , border :: Border -- ^ NoBorder TopB BottomB or FullB
+ , borderColor :: String -- ^ Border color
+ , borderWidth :: Int -- ^ Border width
+ , alpha :: Int -- ^ Transparency from 0 (transparent) to 255 (opaque)
+ , hideOnStart :: Bool -- ^ Hide (Unmap) the window on
+ -- initialization
+ , allDesktops :: Bool -- ^ Tell the WM to map to all desktops
+ , overrideRedirect :: Bool -- ^ Needed for dock behaviour in some
+ -- non-tiling WMs
+ , pickBroadest :: Bool -- ^ Use the broadest display
+ -- instead of the first one by
+ -- default
+ , lowerOnStart :: Bool -- ^ lower to the bottom of the
+ -- window stack on initialization
+ , persistent :: Bool -- ^ Whether automatic hiding should
+ -- be enabled or disabled
+ , iconRoot :: FilePath -- ^ Root folder for icons
+ , commands :: [Runnable] -- ^ For setting the command,
+ -- the command arguments
+ -- and refresh rate for the programs
+ -- to run (optional)
+ , sepChar :: String -- ^ The character to be used for indicating
+ -- commands in the output template
+ -- (default '%')
+ , alignSep :: String -- ^ Separators for left, center and
+ -- right text alignment
+ , template :: String -- ^ The output template
+ } deriving (Read)
+
+data XPosition = Top
+ | TopW Align Int
+ | TopSize Align Int Int
+ | TopP Int Int
+ | Bottom
+ | BottomP Int Int
+ | BottomW Align Int
+ | BottomSize Align Int Int
+ | Static {xpos, ypos, width, height :: Int}
+ | OnScreen Int XPosition
+ deriving ( Read, Eq )
+
+data Align = L | R | C deriving ( Read, Eq )
+
+data Border = NoBorder
+ | TopB
+ | BottomB
+ | FullB
+ | TopBM Int
+ | BottomBM Int
+ | FullBM Int
+ deriving ( Read, Eq )
+
+-- | The default configuration values
+defaultConfig :: Config
+defaultConfig =
+ Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
+ , additionalFonts = []
+ , wmClass = "xmobar"
+ , wmName = "xmobar"
+ , bgColor = "#000000"
+ , fgColor = "#BFBFBF"
+ , alpha = 255
+ , position = Top
+ , border = NoBorder
+ , borderColor = "#BFBFBF"
+ , borderWidth = 1
+ , textOffset = -1
+ , iconOffset = -1
+ , textOffsets = []
+ , hideOnStart = False
+ , lowerOnStart = True
+ , persistent = False
+ , allDesktops = True
+ , overrideRedirect = True
+ , pickBroadest = False
+ , iconRoot = "."
+ , commands = [ Run $ Date "%a %b %_d %Y * %H:%M:%S" "theDate" 10
+ , Run StdinReader]
+ , sepChar = "%"
+ , alignSep = "}{"
+ , template = "%StdinReader% }{ " ++
+ "<fc=#00FF00>%uname%</fc> * <fc=#FF0000>%theDate%</fc>"
+ }
+
+
+-- | An alias for tuple types that is more convenient for long lists.
+type a :*: b = (a, b)
+infixr :*:
+
+-- | This is the list of types that can be hidden inside
+-- 'Runnable.Runnable', the existential type that stores all commands
+-- to be executed by Xmobar. It is used by 'Runnable.readRunnable' in
+-- the 'Runnable.Runnable' Read instance. To install a plugin just add
+-- the plugin's type to the list of types (separated by ':*:') appearing in
+-- this function's type signature.
+runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*:
+ BufferedPipeReader :*: CommandReader :*: StdinReader :*:
+ XMonadLog :*: EWMH :*: Kbd :*: Locks :*:
+#ifdef INOTIFY
+ Mail :*: MBox :*:
+#endif
+#ifdef DATEZONE
+ DateZone :*:
+#endif
+ MarqueePipeReader :*: ()
+runnableTypes = undefined