196 stable releases
new 2.0.42 | Dec 12, 2024 |
---|---|
2.0.40 | Nov 20, 2024 |
2.0.26 | Jul 31, 2024 |
2.0.10 | Mar 25, 2024 |
1.0.4 | Jul 30, 2022 |
#56 in Unix APIs
472 downloads per month
52KB
111 lines
Automatic Timezone Daemon
A Linux daemon to automatically update the system timezone based on location.
How It Works
- The current location is retrieved from GeoClue
- The timezone of the current location is determined using tzf-rs
- The timezone is updated via
systemd-timedated
- Then, the daemon waits for the location updated signal from GeoClue, and repeats from step 1 when it happens
Note: The timezone choice may not be accurate if very close to a timezone border due to tzf-rs
using simplified shape data.
Requirements
- GeoClue
- systemd
- The user must be allowed to use the
org.freedesktop.timedate1.set-timezone
action (root
or Polkit rule) - The user must have a running GeoClue agent or the GeoClue configuration must allow the absence of agent with an empty agent
whitelist
(see also Stebalien/localtime - Configuring GeoClue, geoclue/geoclue#74)
Please see the examples/ directory for sample configurations.
Configuration
$ automatic-timezoned --help
Automatically update system timezone based on location
Usage: automatic-timezoned [OPTIONS]
Options:
-l, --log-level <LOG_LEVEL> Log level filter. See <https://docs.rs/env_logger> for syntax [env: AUTOTZD_LOG_LEVEL=] [default: info]
-h, --help Print help
-V, --version Print version
Packages
Development
Build
cargo build --release
Test
cargo test
Alternatives
This service depends on the tzf-rs
package which bundles timezones and their geographical borders,
here are some alternatives which have made different trade-offs for performance and accuracy:
- github.com/Stebalien/localtime: Depends on the unmaintained github.com/bradfitz/latlong Go library (although if you prefer Go, github.com/ringsaturn/tzf could be used).
- Gnome Automatic Time Zone (Source Code): Depends on the
tzdata
package and Nominatim Web API for distances.
License
GNU General Public License v3.0
Dependencies
~21–31MB
~324K SLoC