Ubuntu – Can f.lux’s automatic behaviour be overridden

colorsdisplayf.luxUbuntu

I found out about f.lux when someone mentioned it on another question here on SU that I happened to stumble upon. I've been using it ever since because it's a simple, original, useful piece of software.

However, sometimes I find that I want to disable it during the night, to edit photos or perform other colour-sensitive tasks. Similarly, it also happens that sometimes I want to enable it during the day, when I close my room's window leaving it completely dark and preparing it for my siesta (where I come from, we take naps just about every day).

Taking this into account I have come to realise a non-automatic version of f.lux would the ideal one for my needs. I know there's an option to pause it during the night, when it activates automatically, but I would like it not to activate unless I tell it to.

So, I leave you the screenshot, where (if you see the same things I see) you'll notice there isn't an option to activate/deactivate at will. Does anybody know how to do this?

Perhaps there is a different GUI for f.lux on Ubuntu?

package 'fluxgui' version 1.1.8 running on Ubuntu oneiric (11.10)

Best Answer

I also had this problem. Redshift is an open source tool with features from f.lux, and the ability to manually set the color temperature.

f.lux will only change the color temperature if it thinks it is night where you are, so I also wrote a python script to trick f.lux into running during the day. It calculates the opposite point on the globe and gives flux those co-ords.

To use it, you need to save this code in a file, e.g. flux.py in your home directory. Then, open a terminal and run the file with python ~/flux.py.

#!/usr/bin/env python
# encoding: utf-8

""" Run flux (http://stereopsis.com/flux/)
    with the addition of default values and
    support for forcing flux to run in the daytime.
"""

import argparse
import subprocess
import sys


def get_args():
    """ Get arguments from the command line. """

    parser = argparse.ArgumentParser(
            description="Run flux (http://stereopsis.com/flux/)\n" +
                        "with the addition of default values and\n" +
                        "support for forcing flux to run in the daytime.",
            formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument("-lo", "--longitude",
            type=float,
            default=0.0,
            help="Longitude\n" +
                "Default : 0.0")

    parser.add_argument("-la", "--latitude",
            type=float,
            default=0.0,
            help="Latitude\n" +
                "Default : 0.0")

    parser.add_argument("-t", "--temp",
            type=int,
            default=3400,
            help="Color temperature\n" +
                "Default : 3400")

    parser.add_argument("-b", "--background",
            action="store_true",
            help="Let the xflux process go to the background.\n" +
                "Default : False")

    parser.add_argument("-f", "--force",
            action="store_true",
            help="Force flux to change color temperature.\n"
                "Default : False\n"
                "Note    : Must be disabled at night.")

    args = parser.parse_args()
    return args


def opposite_long(degree):
    """ Find the opposite of a longitude. """

    if degree > 0:
        opposite = abs(degree) - 180
    else:
        opposite = degree + 180

    return opposite


def opposite_lat(degree):
    """ Find the opposite of a latitude. """

    if degree > 0:
        opposite = 0 - abs(degree)
    else:
        opposite = 0 + degree

    return opposite


def main(args):
    """ Run the xflux command with selected args,
        optionally calculate the antipode of current coords
        to trick xflux into running during the day.
    """

    if args.force == True:
        pos_long, pos_lat = (opposite_long(args.longitude),
                            opposite_lat(args.latitude))
    else:
        pos_long, pos_lat = args.longitude, args.latitude

    if args.background == True:
        background = ''
    else:
        background = ' -nofork'

    xflux_cmd = 'xflux -l {pos_lat} -g {pos_long} -k {temp}{background}'

    subprocess.call(xflux_cmd.format(
        pos_lat=pos_lat, pos_long=pos_long,
        temp=args.temp, background=background),
        shell=True)


if __name__ == '__main__':
    try:
        main(get_args())
    except KeyboardInterrupt:
        sys.exit()
Related Question