summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar
diff options
context:
space:
mode:
authorEmmanuel Rosa <emmanuelrosa@protonmail.com>2019-11-17 12:05:41 +0700
committerjao <jao@gnu.org>2019-11-17 19:17:08 +0000
commitc175588099632c474f988fb4a61ab51ad2523975 (patch)
treea4fd175256cbf6a7e3df3d208e387c3fd3b2b7a7 /src/Xmobar
parent6150993d0528b2a081b3d7e0b7e76732a611625d (diff)
downloadxmobar-c175588099632c474f988fb4a61ab51ad2523975.tar.gz
xmobar-c175588099632c474f988fb4a61ab51ad2523975.tar.bz2
DateZone: get timezone series from TZDIR
The DateZone plugin calls `getTimeZoneSeriesFromOlsonFile` using the hard-coded path /usr/share/zoneinfo. While that may work just fine on most Linux distros, it does not work on NixOS since that directory is always locates somewhere under /nix/store. Based on mild research, it seems the environment variable TZDIR is commonly set to the absolute path to `zoneinfo` (but without a trailing slash). This change modifies the DateZone plugin to first try getting the zoneinfo path from the TZDIR environment variable, falling back to the hard-coded path /usr/share/zoneinfo
Diffstat (limited to 'src/Xmobar')
-rw-r--r--src/Xmobar/Plugins/DateZone.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Xmobar/Plugins/DateZone.hs b/src/Xmobar/Plugins/DateZone.hs
index 22be6c2..35767a8 100644
--- a/src/Xmobar/Plugins/DateZone.hs
+++ b/src/Xmobar/Plugins/DateZone.hs
@@ -28,6 +28,9 @@ import Xmobar.Run.Exec
import Control.Concurrent.STM
import System.IO.Unsafe
+import System.Environment (lookupEnv)
+
+import Data.Maybe (fromMaybe)
import Data.Time.Format
import Data.Time.LocalTime
@@ -63,7 +66,8 @@ instance Exec DateZone where
locale <- getTimeLocale
atomically $ putTMVar localeLock lock
if z /= "" then do
- timeZone <- getTimeZoneSeriesFromOlsonFile ("/usr/share/zoneinfo/" ++ z)
+ tzdir <- lookupEnv "TZDIR"
+ timeZone <- getTimeZoneSeriesFromOlsonFile ((fromMaybe "/usr/share/zoneinfo" tzdir) ++ "/" ++ z)
go (dateZone f locale timeZone)
else
go (date f locale)