By admin |

The process of adjusting monitor brightness and gamma—especially to reduce blue light and add warmth to the screen—is commonly referred to as screen temperature adjustment or blue light filtering. The specific technique of reducing brightness and gamma while increasing the color temperature to reduce blue light is often called night mode or night light.

These terms reflect the approach of lowering blue light and adjusting brightness to ease eye strain and support healthier sleep patterns, particularly in low-light environments or during evening hours.

"Night mode" or "night light" functionality is based on scientific research into the effects of light, particularly blue light, on human circadian rhythms. Here’s a deeper look at how it works and its benefits:

Argument as to Why Night Light is Important For Humans

Understanding the Role of Blue Light in Circadian Rhythm

  • Circadian Rhythm: The human body has a natural biological clock, known as the circadian rhythm, which regulates sleep-wake cycles. It responds to various external cues, with light being the most influential.
  • Blue Light: Blue light, which has a shorter wavelength and higher energy, is emitted by screens (monitors, phones, and tablets) as well as natural daylight. During the day, exposure to blue light helps regulate alertness and mood. However, at night, it can be disruptive. Blue light affects the production of melatonin, a hormone that promotes sleep, by sending signals to the brain that suppress melatonin levels. This suppression can lead to difficulty falling asleep or staying asleep.

How Night Mode Works

  • Reducing Blue Light: Night mode settings reduce the emission of blue light from screens and shift the color spectrum toward warmer tones (reds, oranges, and yellows), which are less likely to interfere with melatonin production.
  • Lowering Brightness: Dimming the screen brightness also reduces the intensity of light exposure, helping the eyes relax. Many night modes allow gradual dimming, which mimics natural sunset lighting and is less startling to the body.
  • Adjusting Gamma and Color Temperature: By shifting the screen’s gamma (contrast) and temperature, night modes can balance out colors for a more eye-comfortable view in darker environments.

Benefits of Night Mode on Sleep Quality

  • Reduces Eye Strain: Extended screen time in bright light conditions strains the eyes, especially in low ambient lighting. Night mode minimizes the harshness, reducing discomfort.
  • Improves Melatonin Production: By limiting blue light exposure, night mode settings allow melatonin to be released naturally. This hormone is critical for signaling the body to transition into the sleep cycle, helping individuals fall asleep more easily and maintain better sleep quality.
  • Supports Circadian Synchronization: A regular pattern of dimmer, warmer light in the evening, combined with bright light exposure during the day, can help reinforce the body’s internal clock, supporting better energy levels during the day and sleep at night.

Implementation of Night Mode in Various Devices and Software

  • Operating Systems: Modern OSs like Windows, macOS, and various Linux distros have built-in night mode settings (e.g., Windows Night Light, macOS Night Shift).
  • Applications and Browser Extensions: Apps like f.lux or browser extensions like Dark Reader on Chrome and Firefox also adjust screen color temperature based on the time of day.
  • Physical Adjustments: For individuals working on customized solutions, as in your case with a Linux setup and a bash script, tools like xrandr can be configured to gradually reduce blue light and brightness, giving full control over the intensity and timing.

Scientific Support and Considerations

  • Research on Light and Sleep: Studies show that blue light exposure in the evening delays the circadian clock and suppresses melatonin, leading to later bedtimes and reduced sleep quality. For instance, a study published by Harvard researchers highlighted the importance of reducing blue light exposure before bed to improve sleep duration and quality.
  • Health Implications: Beyond sleep, prolonged blue light exposure has been linked to digital eye strain, potential retinal damage, and a higher risk of sleep disorders. For those with sensitive eyes or chronic sleep issues, night mode provides a proactive measure to reduce these risks.

Additional Tips for Using Night Mode Effectively

  • Set a Gradual Transition: For best results, night mode should start gradually reducing blue light about 2-4 hours before your bedtime.
  • Pair with Reduced Screen Time: Reducing screen time entirely an hour before bed can amplify the benefits of night mode.
    Consider Lighting Environment: Supplement night mode with dim, warm-toned ambient lighting. Bright overhead lights also emit blue light and can counteract the effects of night mode.

Closing Remarks

Night mode isn’t a magic fix, but it can significantly reduce the disruptive impact of screen exposure in the evening. By combining night mode with conscious screen habits and lighting adjustments, you’re supporting not only better sleep but also your overall visual and mental health.

My Implementation of Night Mode/Night Shift For My Monitor Using Linux

There are some Linux distros that implement "night mode" when invoked through the Display Settings, but the term that is used is "Redshift" rather than "night mode" or "nightshift." This is usually found in Xfce and KDE under this name. 

After searching in MX Linux, the distribution of Linux that I'm currently running as my Daily Driver, I was unable to find an application that did this for me automatically. So, I developed my own using Bash scripting. Here is the process that I'm using now that decreases the monitor display brightness to 90% at 5pm then incrementally decreasing this brightness level by 10% hourly up to 8pm to a final level of 60%. In addition, my Bash script also reduces Gamma levels from 1.0:1.0:1.0 for Red:Green:Blue to 1.0:0.95:0.85 starting at 6 pm and maintaining those levels through the night until 6am the following morning when the brightness and Gamma levels are returned to normal. The overall process is in two phases:

Phase 1

Create a Bash script which looks like the following:

Bash script

The code can be copied by cutting and pasting the following into an empty file in Linux:

#!/usr/bin/env bash

export DISPLAY=:0

m1="HDMI-0"

notif() {
 notify-send -t 3000 -h string:bgcolor:#ebcb8b "Brightness adjusted!"
}

[ "$1" = 10 ] && percent="1" || percent="0.$1"

[ "$2" = night ] && gamma="1.0:0.95:0.85" || gamma="1.0:1.0:1.0"

xrandr --output "$m1" --brightness "$percent" --gamma "$gamma" && notif

After creating this empty file using a text editor or by touching the file, name the file dimmer. Save the file in any location that you feel appropriate. I saved my dimmer file as ~/dimmer. 

Now that you've saved the file and given it a name, make the file executable by running:

$ chmod +x ~/dimmer

This Bash script uses the export DISPLAY = :0 assignment, which is essential for the xrandr package in Linux to recognize and use it.

m1="HDMI-0" is the variable I selected for my 1st monitor (which happens to be my only monitor in use) and its assignment to HDMI-0 was determined using the xrandr command:

$ xrandr | grep "connected"

In my particular case, the stdout following the running of this command was:

Identifying Your Monitor for xrandr

As noted above, my monitor is using the HDMI-0 (port 0) since it is connected using screen resolution 1920X1080. The VGA port 0 and DVI-D port 0 are disconnected and not in use. You will need to run the xrandr command above to determine how xrandr sees your monitor, then adjust the dimmer file accordingly before it is run.

Phase 2

In this phase, I set up a Cron job that runs the bash script on a schedule as follows:

crontab for datapioneer

To create the above crontab file, run the following command in Linux:

$ crontab -e

For Debian-based Linux distros like MX Linux, Ubuntu, and Debian, this command opens the following file that it creates on the fly for editing in the location /var/spool/cron/crontabs/<username>. The <username> is the currently logged in user on your Linux account.

After adding the contents of what you see at the end of the file that I created for my user, datapioneer, save the file and this will automatically enable the cronjob. If you later wish to edit this file, you'll need to run the following command in Linux:

$ crontab - u <username> -e     , where <username> was defined earlier.

Attempting to edit the file using a text editor, even as root, will fail, yielding a "permission denied" warning. The 10, 9, ... , 6 settings seen in the crontab file correspond to the $1 Bash variable in the dimmer Bash script. The reference to night corresponds to the $2 Bash variable in that file. Effectively, the Phase 1 and Phase 2 implementations of this Night Mode project in Linux causes the monitor's brightness to decrease by 10% starting at 5pm and incrementally decreasing by 10% through 8pm until such time as the monitor brightness will be at 60% of the normal level. Additionally, the Gamma shift will begin occurring at 6pm and continue on through 8pm where both Brightness and Gamma levels will remain until 6am the following morning at which time the monitor will be reset to normal brightness and Gamma levels. 

Give this a try in your Linux system. I've tested this process out and it works perfectly in MX Linux. Happy computing!

Note:  After testing, I have adjusted my crontab file to protect the dimmer bash script a little better and to not decrease the monitor brightness beyond 70%. The new crontab file looks like this:

0 6 * * * /home/datapioneer/.local/bin/dimmer 10
0 18 * * * /home/datapioneer/.local/bin/dimmer 9 night
0 19 * * * /home/datapioneer/.local/bin/dimmer 8 night
0 20 * * * /home/datapioneer/.local/bin/dimmer 7 night