Latesil / theme-switcher

Switch dark/light GTK theme automatically during day/night
GNU General Public License v3.0
9 stars 4 forks source link

Resolve day/night time from geolocation #11

Open cardil opened 2 years ago

cardil commented 2 years ago

For most people, the day/night transitions shifts during the year. It would be nice to be able to resolve them automatically from given geolocation.

I image the UI could be extended to have a checkbox titled: "Use geolocation to resolve Day/Night time". When checked, fields for latitude and longitude could have appeared. When fields are filled, Day/Night time is automatically resolved.

Such feature is for example implemented in DarkReader extension:

https://github.com/darkreader/darkreader/blob/90bb1f0c4ae7e915e547bf2bdc603e725326c1b0/src/utils/time.ts#L228-L251

cardil commented 2 years ago

The sunriset library looks like a good candidate to easily implement this. Here's example code:

https://github.com/BrianArbuckle/sunriset/blob/81d22197fb39c43c80757207b2e52e12970ace6d/test.py#L28-L33

phaux commented 2 years ago

You can also get current location automatically from timedatectl:

# timedatectl
               Local time: Mon 2021-10-25 16:14:37 CEST
           Universal time: Mon 2021-10-25 14:14:37 UTC
                 RTC time: Mon 2021-10-25 14:14:37
                Time zone: Europe/Warsaw (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no