diff options
author | Adam Vogt <vogt.adam@gmail.com> | 2014-02-25 01:27:03 -0500 |
---|---|---|
committer | Adam Vogt <vogt.adam@gmail.com> | 2014-02-25 12:29:04 -0500 |
commit | dc670b15ba8b279e1119ac895dd681feab4e3939 (patch) | |
tree | 59ac3f96a4ab84bf43af7d88dc256d4353d258d1 /src/Plugins/DateZone.hs | |
parent | b739857ed4d2282e80a8908165ffda82fcc3ecdc (diff) | |
download | xmobar-dc670b15ba8b279e1119ac895dd681feab4e3939.tar.gz xmobar-dc670b15ba8b279e1119ac895dd681feab4e3939.tar.bz2 |
have disabled plugins still accept input
This change lets xmobar compiled without -fwith_inotify accept a config
that mentions the Mail plugin with a warning (and display an
Updating...).
Diffstat (limited to 'src/Plugins/DateZone.hs')
-rw-r--r-- | src/Plugins/DateZone.hs | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/Plugins/DateZone.hs b/src/Plugins/DateZone.hs index 79596c9..f1737fb 100644 --- a/src/Plugins/DateZone.hs +++ b/src/Plugins/DateZone.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DoAndIfThenElse #-} ----------------------------------------------------------------------------- -- | @@ -23,30 +24,37 @@ module Plugins.DateZone (DateZone(..)) where import Plugins -import Localize +#ifdef DATEZONE import Control.Concurrent.STM +import System.IO.Unsafe + +import Localize import Data.Time.LocalTime import Data.Time.Format import Data.Time.LocalTime.TimeZone.Olson import Data.Time.LocalTime.TimeZone.Series -import System.IO.Unsafe import System.Locale (TimeLocale) +#else +import System.IO +import Plugins.Date +#endif -{-# NOINLINE localeLock #-} --- ensures that only one plugin instance sets the locale -localeLock :: TMVar Bool -localeLock = unsafePerformIO (newTMVarIO False) - data DateZone = DateZone String String String String Int deriving (Read, Show) instance Exec DateZone where alias (DateZone _ _ _ a _) = a +#ifndef DATEZONE + start (DateZone f _ _ a r) cb = do + hPutStrLn stderr $ "Warning: DateZone plugin needs -fwith_datezone."++ + " Using Date plugin instead." + start (Date f a r) cb +#else start (DateZone f l z _ r) cb = do lock <- atomically $ takeTMVar localeLock setupTimeLocale l @@ -60,6 +68,11 @@ instance Exec DateZone where where go func = func >>= cb >> tenthSeconds r >> go func +{-# NOINLINE localeLock #-} +-- ensures that only one plugin instance sets the locale +localeLock :: TMVar Bool +localeLock = unsafePerformIO (newTMVarIO False) + date :: String -> TimeLocale -> IO String date format loc = getZonedTime >>= return . formatTime loc format @@ -67,3 +80,4 @@ dateZone :: String -> TimeLocale -> TimeZoneSeries -> IO String dateZone format loc timeZone = getZonedTime >>= return . formatTime loc format . utcToLocalTime' timeZone . zonedTimeToUTC -- zonedTime <- getZonedTime -- return $ formatTime loc format $ utcToLocalTime' timeZone $ zonedTimeToUTC zonedTime +#endif |