C2N14 / AutomaThemely

Simple, set-and-forget python application for changing between desktop themes according to light and dark hours
GNU General Public License v3.0
205 stars 31 forks source link

systemd daemon required to schedule theme changes #21

Closed mijorus closed 5 years ago

mijorus commented 5 years ago

Hi, after checking the code i saw that the postinstall script creates a timer that just updates the sunset and sunrise time, but won't be able to switch between them automatically. I got around this issue by manually creating a simple systemd timer which looks like this:

[Unit]
Description=Switch theme

[Timer]
OnCalendar=*-*-* 20:00:00
OnCalendar=*-*-* 08:00:00
Persistent=true

[Install]
WantedBy=timers.target

obviously it doesn't update the time based on the location, but as long as my almost absent knowledge goes this gets the job done. It runs asyncronous as well which is ideal for my laptop. The easiest metod to update those times would be to replace the lines and call systemctl daemon-reload every time but that is just stupid, so i'll keep it like this. I hope it will help to make some sort of real changes in the project

C2N14 commented 5 years ago

Hi there! The way this currently works is by calling scheduler.py at the start of the user session, that runs once and then waits in the background until the time comes for changing the theme.

I did think about scheduling using systemctl in the past but I found that changing the times was not as convenient, and since sunset and sunrise time change not only by location but also by time of the year I came up with the current implementation. If in the future I am able to see a more advantageous implementation using systemctl I might take it into consideration.

If you are having an issue with it not running automatically right now though, it might be related to a bug that I am trying to work with that has to do with the installation process, so for the moment it might not work properly until I can figure something out.

mrdvt92 commented 4 years ago

I was trying to figure out how to integrate systemd timer with the Perl scripts in the distribution https://metacpan.org/release/Geo-Local-Server called

sunrise_time - Prints the time of the next sunrise sunset_time - Prints the time of the next sunset

If we can figure out how to integrate that then we will have the timer that we need.

The lat.lon.hae are defined in the file /etc/local.coordinates