rework timezone setup

- get rid of tz-data-monitor.*
- timezone is now persistent (saved to .cache)
This commit is contained in:
Stefan Saraev 2013-11-26 21:04:58 +02:00
parent adb0cf1ad1
commit c42b141d2e
5 changed files with 45 additions and 28 deletions

View File

@ -0,0 +1,26 @@
From 25be1b385303a8114d7e227ffab52a22de42ccd1 Mon Sep 17 00:00:00 2001
From: Stefan Saraev <stefan@saraev.ca>
Date: Tue, 26 Nov 2013 20:53:08 +0200
Subject: [PATCH] run tzdata-setup on timezone change
---
xbmc/linux/LinuxTimezone.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/xbmc/linux/LinuxTimezone.cpp b/xbmc/linux/LinuxTimezone.cpp
index be7bce6..4000181 100644
--- a/xbmc/linux/LinuxTimezone.cpp
+++ b/xbmc/linux/LinuxTimezone.cpp
@@ -158,6 +158,9 @@ void CLinuxTimezone::OnSettingChanged(const CSetting *setting)
const std::string &settingId = setting->GetId();
if (settingId == "locale.timezone")
{
+ const std::string cmd = std::string("sh /usr/lib/openelec/tzdata-setup ") + ((CSettingString*)setting)->GetValue().c_str();
+ system(cmd.c_str());
+
SetTimezone(((CSettingString*)setting)->GetValue());
CDateTime::ResetTimezoneBias();
--
1.8.3.2

View File

@ -59,6 +59,5 @@ post_makeinstall_target() {
}
post_install() {
enable_service tz-data-monitor.path
enable_service tz-data.service
}

View File

@ -19,14 +19,25 @@
# http://www.gnu.org/copyleft/gpl.html
################################################################################
GUISETTINGS="/storage/.xbmc/userdata/guisettings.xml"
if [ -f "$GUISETTINGS" ] ; then
TIMEZONE=`sed -n -e 's/.*<timezone>\(.*\)<\/timezone>.*/\1/p' /storage/.xbmc/userdata/guisettings.xml`
fi
if [ ! "$TIMEZONE" == "" -a -f "/usr/share/zoneinfo/$TIMEZONE" ] ; then
ln -sf "/usr/share/zoneinfo/$TIMEZONE" /var/run/localtime
if [ -z "$1" ] ; then
# called from systemd. read timezone if set
if [ -f /storage/.cache/timezone ] ; then
TIMEZONE=`cat /storage/.cache/timezone`
else
if [ -f /storage/.xbmc/userdata/guisettings.xml ] ; then
TIMEZONE=`sed -n -e 's/.*<timezone>\(.*\)<\/timezone>.*/\1/p' /storage/.xbmc/userdata/guisettings.xml`
fi
if [ -z "TIMEZONE" ] ; then
TIMEZONE="UTC"
fi
# save it!
echo "$TIMEZONE" > /storage/.cache/timezone
fi
else
ln -sf "/usr/share/zoneinfo/UTC" /var/run/localtime
# called from xbmc. save the timezone!
TIMEZONE="$1"
echo "$TIMEZONE" > /storage/.cache/timezone
fi
ln -sf "/usr/share/zoneinfo/$TIMEZONE" /var/run/localtime

View File

@ -1,9 +0,0 @@
[Unit]
Description=Timezone data monitor
After=local-fs.target
[Path]
PathChanged=/storage/.xbmc/userdata/guisettings.xml
[Install]
WantedBy=multi-user.target

View File

@ -1,10 +0,0 @@
[Unit]
Description=Timezone data monitor
[Service]
Type=oneshot
ExecStart=/bin/systemctl restart tz-data.service
StartLimitInterval=0
[Install]
WantedBy=multi-user.target