You can find the package in the Wizardry and Steamworks Cydia repository.
Cydia has a nice application called f.lux which allows you to increase the caloric value of the LCD screen. They claim that bright LCD screens used during nighttime may be the cause for sleep disorders since it puts a considerable strain on the eyes. They have an application for Windows, OSX and iOS as well.
We like the idea behind f.lux
but the application has numerous problems on all iOS devices. For instance, when you switch the setting from Normal
to Halogene
and then back to Normal
, the color does not revert as it is supposed to. Apparently they are aware of the problem and the have to deal with other issues such as battery drainage. This lead us to want to create our own application.
The Color Profiles
Cydia utility by Ryan Petrich provides a clean interface allowing you to set the color temperature, albeit being a paid application, so we chose that as the starting point.
The color temperature setting is subjective but we can use Color Profiles
to calibrate the temperature for night-time. A setting of 0.6
in Color Profiles
gives a good mellow light for night-time so we pick that value as the upper bound which should be reached by midnight.
The low value follows immediately as 0.0
to cancel out the effect.
We write a org.grimore.clux.plist
file:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.grimore.clux</string> <key>ProgramArguments</key> <array> <string>/etc/scripts/clux.sh</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>3600</integer> </dict> </plist>
and add it to /Library/LaunchDaemons/
so that the script /etc/scripts/clux.sh
will run every hour.
The bash script, a bit more interesting consists of:
#!/bin/bash # Copyright (C) Wizardry and Steamworks. ## # Licensed to Wizardry and Steamworks under # the GPLv3 GNU License which can be found at: # http://www.gnu.org/licenses/gpl.html ## # Original at: http://grimore.org/ios:clux ## IDX=`expr $(date +%H) - 12` if [ $IDX -lt 0 ]; then IDX=`expr $IDX \* -1` fi LUX=( 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 ); plutil -type float -key temperature -value ${LUX[$IDX]} /private/var/mobile/Library/Preferences/com.rpetrich.colorprofiles.plist 2>&1 | true notify_post com.rpetrich.colorprofiles/settingchanged
There are several remarks about this script that are noteworthy:
bc
because the built-in expr
does not handle floating point. Since this is a minimal install, we do not want bc.if
-clause:IDX=`expr $(date +%H) - 12`
which would have been perfect if the bash
version on Cydia would be recent enough to support negative indexes so we would not have needed the array instantiation.