From 878f7330253500311454d83a28b81fa6f9977ffe Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 6 Apr 2022 18:40:58 -0500 Subject: [PATCH] Set GUI time zone from geolocation The wonderful *ipapi.co* service can help identify the time zone of a device based on the geolocation information for its IP address. We can use this to set the `TZ` environment variable in the user session, which Firefox will respect. This has the effect of showing the correct time in e.g. Grafana dashboards, without hard-coding the time zone in the rootfs image. --- mkrootfs.sh | 1 + overlay/home/user/.xinitrc | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mkrootfs.sh b/mkrootfs.sh index 3bd8846..f12d9a7 100644 --- a/mkrootfs.sh +++ b/mkrootfs.sh @@ -18,6 +18,7 @@ echo install_weak_deps=False >> "${destdir}"/etc/dnf/dnf.conf dnf --installroot "${destdir}" install -y \ bcm2711-firmware \ + curl \ dhcp-client \ dracut-network \ firefox \ diff --git a/overlay/home/user/.xinitrc b/overlay/home/user/.xinitrc index 0cb7eda..c944550 100644 --- a/overlay/home/user/.xinitrc +++ b/overlay/home/user/.xinitrc @@ -2,6 +2,10 @@ xset s off xset -dpms -systemctl --user import-environment DISPLAY + +TZ="$(curl https://ipapi.co/timezone)" +export TZ + +systemctl --user import-environment DISPLAY TZ systemctl --user start firefox-marionette.socket firefox exec openbox