[taffybar] Set a default monitor

This commit is contained in:
Ivan Malison 2017-03-04 12:03:10 -08:00
parent 6d48eb51cf
commit 88beaa9ad5
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -1,7 +1,7 @@
module Main where module Main where
import Control.Exception.Base
import Data.Char (toLower) import Data.Char (toLower)
import Data.List import Data.List
import Data.Maybe import Data.Maybe
import qualified Graphics.UI.Gtk as Gtk import qualified Graphics.UI.Gtk as Gtk
@ -59,8 +59,12 @@ myGetIconInfo =
windowTitleClassIconGetter False fallbackIcons windowTitleClassIconGetter False fallbackIcons
main = do main = do
monString <- getEnv "TAFFYBAR_MONITOR" monEither <- (try $ getEnv "TAFFYBAR_MONITOR") :: IO (Either SomeException String)
let monitorNumber = fromMaybe 1 $ readMaybe monString let monNumber =
case monEither of
Left _ -> 0
Right monString -> fromMaybe 0 $ readMaybe monString
let memCfg = let memCfg =
defaultGraphConfig defaultGraphConfig
{graphDataColors = [(1, 0, 0, 1)], graphLabel = Just "mem"} {graphDataColors = [(1, 0, 0, 1)], graphLabel = Just "mem"}
@ -99,7 +103,7 @@ main = do
defaultTaffybarConfig defaultTaffybarConfig
{ startWidgets = [hud] { startWidgets = [hud]
, endWidgets = [underlineWidget tray "tray", underlineWidget clock "clock", mem, cpu, mpris] , endWidgets = [underlineWidget tray "tray", underlineWidget clock "clock", mem, cpu, mpris]
, monitorNumber = monitorNumber , monitorNumber = monNumber
, monitorFilter = allMonitors , monitorFilter = allMonitors
, barPosition = Top , barPosition = Top
, barHeight = 40 , barHeight = 40