Skip to content

Timer: Preserve current theme when sunrise/sunset is unavailable

Greetings @rmnvgr! Thanks a lot again for creating this incredible extension!

I spent a considerable amount of time implementing this often-requested feature/fix as cleanly as possible, in a non-intrusive way, and following your current codestyle as closely as possible. I sincerely hope that it's up to your standards.

The implementation is as follows:

  • If it's impossible to determine whether the current hour is "before or after sunrise", keep the user's current operating system theme instead of forcibly changing it to day.
  • Refactored the "theme detection" to a separate function, so that it can be called when needed, whenever this.#time doesn't have a value yet. This only happens once, at extension startup.

This will make a lot of people happy, because it means that the following becomes possible:

  • Set the geolocation mode to "manual", and set "sunrise" + "sunset" to the exact same value. This situation has always meant that it becomes impossible for the extension to determine whether hour is "before or after sunrise".
  • The extension then preserves the user's current system theme. It simply remains active as a listener for all other events (such as manual theme switching via GNOME's "Dark Style" main menu toggle), where it helps people enjoy their own sets of custom wallpapers/themes/cursors/icons/etc thanks to your great extension!
  • If the user goes in and sets different values for sunset/sunrise, or disables "manual" mode (so that the sunrise/sunset are automatically based on the current location again), then the extension immediately begins auto-switching again.
  • Which means that it's a seamlessly implemented solution for this frequent feature request. Everyone will be able to personalize their experiences with Night Theme Switcher, and seamlessly move between automatic or controlled modes.

If there's anything else I can do to help, please let me know! 😺

Hope you have a great day!

Edited by Johnny Arcitec

Merge request reports