From 88beaa9ad5907391bc864ddc9295dc2cce5cd5ff Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 4 Mar 2017 12:03:10 -0800 Subject: [PATCH] [taffybar] Set a default monitor --- dotfiles/config/taffybar/taffybar.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dotfiles/config/taffybar/taffybar.hs b/dotfiles/config/taffybar/taffybar.hs index 1432b35e..345b82a7 100644 --- a/dotfiles/config/taffybar/taffybar.hs +++ b/dotfiles/config/taffybar/taffybar.hs @@ -1,7 +1,7 @@ module Main where +import Control.Exception.Base import Data.Char (toLower) - import Data.List import Data.Maybe import qualified Graphics.UI.Gtk as Gtk @@ -59,8 +59,12 @@ myGetIconInfo = windowTitleClassIconGetter False fallbackIcons main = do - monString <- getEnv "TAFFYBAR_MONITOR" - let monitorNumber = fromMaybe 1 $ readMaybe monString + monEither <- (try $ getEnv "TAFFYBAR_MONITOR") :: IO (Either SomeException String) + let monNumber = + case monEither of + Left _ -> 0 + Right monString -> fromMaybe 0 $ readMaybe monString + let memCfg = defaultGraphConfig {graphDataColors = [(1, 0, 0, 1)], graphLabel = Just "mem"} @@ -99,7 +103,7 @@ main = do defaultTaffybarConfig { startWidgets = [hud] , endWidgets = [underlineWidget tray "tray", underlineWidget clock "clock", mem, cpu, mpris] - , monitorNumber = monitorNumber + , monitorNumber = monNumber , monitorFilter = allMonitors , barPosition = Top , barHeight = 40