How to automatically enable Xflux in Linux


I originally made this as an assignment in ICT Service Operations-class, and decided to share it here.

Intended for: Intermediate Linux-users on lower-end window managers/desktop environments.
Explains: How to automatically start and enable Xflux on x-environments using a CLI-command.
Purpose: To help users protect their eyes after dawn while keeping resources at a minimal.

In this slightly exaggerated example, the bottom-left half shows how the display looks like with Xflux running.

1. What is Xflux

Xflux is an open-source fork of MacOS’ f.lux for X-environments. It’s meant to protect your eyes when browsing at night by enabling a red filter over the display while cutting back on blue colors. The absence of blue light is also shown to have a positive impact on the sleeping cycle. Perhaps you’re familiar with Redshift or Gnome’s Night Light, they’ve got their own GUI and indicators, but this is a guide for those who want to keep things absolutely minimal.

2. Downloading and installing Xflux


For 64-bit systems, open a terminal and execute:

wget https://justgetflux.com/linux/xflux64.tgz

Extract the downloaded file:

tar -xf xflux64.tgz

For 32-bit systems, open terminal and execute:

wget https://justgetflux.com/linux/xflux-pre.tgz

Extract the downloaded file:

tar -xf xflux-pre.tgz

Move the file into your system:

sudo mv ~/xflux /usr/bin/xflux

Give yourself full permissions to read the file:

sudo chmod 755 /usr/bin/xflux

3. Finding your coordinates

Xflux will turn on the filter when it’s dawn in your local area, and turn itself off at dusk. Because of this, you need to tell it where you live. Google YourAreacoordinates. In my case, it looks like this:

As you can see, I’ve circled the coordinates and rounded them up or down to only one decimal.

My finished Xflux command looks like this:

xflux -l 59.0 -g 5.7 -k 3000

The -l is for latitude, while the -g is for longitude.
If you’re in the US, you can skip -l and -g for -z and insert your own zipcode instead.

The -k stands for kelvin temperature. It can be anywhere between 2000-10000. The default setting is 3400. Lower numbers gives more redness. For me, 3000 is a perfect fit.

4. Enabling Xflux automatically on boot

Simply edit your .bashrc file (or .zshrc if you’re a zsh’er) in your local directory and insert your personal Xflux-command at the bottom of the file. Save the file and reboot your computer .

Congratulations! Now Xflux will automatically run every time you restart your computer.
Please remember, enabling several instances of Xflux at the same time causes unpleasant flickering.