First step : create the script
First let us create a script the will be run and would enable/disable flux depending on the time (I don't knot flux syntax, so adapt it for your need). You can note that here I suppose that you need to be root to run flux, but of course if you don't just run these steps as a classical user.
sudo mkdir -p /opt/flux/
sudo gedit /opt/flux/toogleFlux.sh
and put in it something like this
if [ $h -ge $start ] || [ $h -lt $stop ] ; then
# Start flux, give it any information you want, latitude...
xflux -l 45
# Stop flux
Then, make it executable :
sudo chmod +x /opt/flux/toogleFlux.sh
Second step : run it when needed
Now, you need to run it when needed. To to so, you can use a
cron that would run it at 8:05 PM and 3:05 AM. But if you do so, if you open your computer at 8:10PM, it would not run it. The first solution is to use
fcron, but I don't think it's packaged on distributions, so I'll use a combinaison of
cron and a file that runs when you open a session.
To run this script with cron, run the following command. If you need to run it as root, add
sudo before :
and then type :
05 20 * * * /opt/flux/toogleFlux.sh
05 3 * * * /opt/flux/toogleFlux.sh
now, you need to be sure that the script will run when you open your session. Depending on your GUI, you can configure it in your system settings, or sometimes putting this line in
.profile will be enough (the
xhost command is usefull to let the root user connect to the graphical interface) :
Now, run it
toogleFlux.sh to enable it for the current session :
and enjoy flux !