Turris-nighlight: set Turris' LED intensity according the current time period

Hi,

I’ve had too much free time this Saturday and made a shell script inspired by Windows 10 Night light and similar. It sets LED intensity according the current time period (nighttime, morning twilight, daytime, evening twilight). The intensity is set to the minimal value during nighttime, to the maximal value during daytime, gradually increased during morning twilight, and gradually decreased during evening twilight.

The start and end points of the mentioned time periods vary, based on factors such as season, latitude, longitude, and time zone. Turris-nightlight uses a web API (http://api.sunrise-sunset.org/) to obtain these time points. If geographic coordinates are not supplied as command-line arguments, the coordinates are obtained by an IP geolocation service. A query to a web IP geolocation API (http://ip-api.com/line) will be performed, which will use your current IP address (as seen by the API).

See the GitHub page for more information. Developed and tested on Turris Omnia, not sure whether it will work on older devices.

2 Likes

Hi,

I like where this is going.

Is there any tutorial on how to install this?

To install the script, you have to download turris-nightlight.sh to /usr/bin/, and make it executable:

curl https://raw.githubusercontent.com/jwrona/turris-nightlight/master/turris-nightlight.sh >/usr/bin/turris-nightlight.sh
chmod +x /usr/bin/turris-nightlight.sh

To run it periodically (which is recommended), create a crontab file /etc/cron.d/turris-nightlight with the following content:

MAILTO=""
*/1     *       *       *       *       root    turris-nightlight.sh --log syslog

You can tweak the parameters as you wish. Simple as that. :slightly_smiling_face:

1 Like

Thank you jwrona.

I followed the instructions. I hope I have done it right.

I am not particularly known with installing things on my omnia, just waiting on good tutorials on how to install in the documentation area.

No problem. :slight_smile: It would help me if you confirmed whether it is working correctly for you or if you encountered any problems. Especially if you are located in different time zone than me (CET/CEST), time zones are always a struggle.