37

I use to work at night and it is eye-hurting to watch at lightbulb-bright screens (I've got two - laptop's built-in panel and an external 18-inch CRT) in a dark environment. So I adjust my screens to be darker.

Can I do this a software way instead of pressing monitors' buttons that many times every time?

10 Answers 10

27

Redshift
I have been using this. Its very nice.

sudo apt-get install redshift

To use it just type in the terminal redshift

gtk-redshift is just the gui, not required.


f.lux is also an option.

  • 6
    No need for ppas any longer. Redshift is included in natty. Just do sudo aptitude install redshift or sudo aptitude install gtk-redshift (the latter for the gtk variant which comes with an icon for the tray). – N.N. Jun 14 '11 at 11:56
  • 1
    I cannot use Redshift for manually correcting gamma – Anwar Aug 20 '15 at 5:58
  • @Anwar Please see my answer just posted below. I'd like to hear more about your gamma problems to incorporate in future revisions. – WinEunuuchs2Unix Mar 21 '18 at 0:54
8

To adjust gamma (which is a good substitute for adjusting contrast), you can write:

xgamma -gamma 0.3

on the command line (Terminal). You should see a very noticeable difference. Experiment with different values.

1.0 is the normal (uncorrected) gamma value. Setting a lower gamma (for example 0.7) will increase the contrast of bright luminances, which makes midtones darker and decreases white washing. Setting a higher gamma (for example 1.5) will make midtones brighter and increase the contrast of dark luminances, but also increases white washing.

For my inexpensive laptop, I use gamma 0.8 to compensate for the too bright factory setting for the LCD and I find that the gamma correction helps with color reproduction too, which is nice because so far I haven't managed to get any color calibration working on this LCD.

  • 1
    That's exactly the way i do it, and xgamma comes preinstalled which is awesome – Sergiy Kolodyazhnyy Jul 16 '16 at 21:08
5

The software you're looking for is Redshift redshift

5

TL;DR

Use:

  • xbacklight
  • ddccontrol
  • redshift
  • xgamma

Backlight vs pixel values

First and most importantly, if at all possible adjust the display backlight, rather than using software correction of pixel values. If you dim the backlight you still get full or near-full dynamic range, giving you a clearer, "deeper" image that tends to be more readable.

Software adjustment can't make the blacks darker, it just makes white greyer and reduces contrast. So instead of using pixel values from 0-255 it might use from 0-180 for example. Everything looks flatter.

A tool like Redshift can be useful for changing colour balance, but as much as possible you should try to change brightness with backlight adjustment.

DDC/CI

Last I checked, most displays unfortunately do(did?) not implement backlight control from software. There's a standard for it, DDC/CI but adoption has been limited. Try the ddccontrol tool with your monitor and see if you have any luck.

I've only seen it in very high end displays intended for calibrated photo and video work ... and even many of those use a USB connection and custom USB HID based driver instead of the DDC/CI standard. I'm pretty outdated though, and the linked article claims that basic options like brightness and contrast are widely supported now.

Fake brightness controls on cheap displays

Some cheap displays don't support backlight control at all. The brightness controls on the display just adjust the pixel values on the LCD, just like software control does. Do not use these controls if you have such a monitor; it's usually better to do the correction in software, certainly no worse.

Doesn't go dim enough?

All too many displays do have backlight control, but minimum brightness is still eye-searing. They can sometimes be modified, but otherwise your best bet is setting them to minimum backlight brightness and then living with changing pixel values to get them even dimmer.

It really annoys me that displays have such a limited backlight intensity range, often artifically and arbitrarily limited, starting at eye-searing to "the power of a million suns". I look for dim backlights when I'm speccing out displays to buy.

Laptops

On a laptop, the backlight is usually controlled by software. Yay!

(If your laptop is still old enough to use APM control instead of ACPI or custom drivers, get off my lawn).

The details are somewhat driver and software specific, but your laptop should offer convenient Fn keys that make it easy, and the OS should have a simple display brightness slider. The xbacklight utility offers a convenient command line control for this, though on my system it doesn't seem to like to go below 1% brightness and goes straight to black.

I twiddle the driver controls because my T460 is very bright - wonderful during the day, but horrible at night. The minimum brightness step offered by the fn key adjustments is still way too bright, but the driver provides much finer grained control. xbacklight only lets me get down to brighness 8/255 and I'd like So I tell it to run at 4/255 brightness:

echo 4 | sudo tee -a  /sys/class/backlight/intel_backlight/brightness

This works on a Lenovo T460 with Intel graphics, but other drivers and hardware may have different entries under /sys/class/backlight with different range limits etc.

The arch wiki has some useful info.

Gamma adjustment

When you lower brightness you might want to increase contrast in software a bit, especially if working on text. It'll cost you image quality, but gain you readability at low brightness. The xgamma utility will let you do that, e.g.

xgamma -gamma 0.8

Someone want to patch Redshift with brightness controls?

So, you know what'd be cool?

If Redshift could fade display brightness based on an ambient light sensor and/or time of day, via the same xrandr controls used by xbacklight.

2

XRandR

xrandr is similar to xgamma, also let you select the level for each three colors. For example

xrandr --output HDMI2  --gamma 1:1:1

Will set to default value. Select the output choosing from one of the connected devices listed with just xrandr (or xrandr |grep -vE "^ " |grep -v disconnect).

Note: if you use Redshift or flux (closed-source) they will override xrandr setup.

From man page:

  • --gamma red:green:blue Set the specified floating point values as gamma correction on the crtc currently attached to this output. Note that you cannot get two different values for cloned outputs (i.e.: which share the same crtc) and that switching an output to another crtc doesn't change the crtc gamma corrections at all.
  • --brightness brightness Multiply the gamma values on the crtc currently attached to the output to specified floating value. Useful for overly bright or overly dim outputs. However, this is a software only modification, if your hardware has support to actually change the brightness, you will probably prefer to use xbacklight.
1

To those who have problem with brightness configuration after installing Ubuntu 10.10 and are using Acer Aspire 4741, here's a solution for you:

gksu gedit /etc/default/grub

Change the line GRUB_CMDLINE_LINUX="" into GRUB_CMDLINE_LINUX="acpi_osi=Linux"

sudo update-grub

Restart your linux

0

You can always do Windows-M or Windows-N. The first inverts colors of all windows showing, the second does it to the current window in focus.

Really helps when reading PDFs with tired eyes

0

These days there's an additional solution that is very much like Redshift: it's available as a built-in feature in the GNOME desktop environment. Just go to Settings -> Displays and turn Night Light on. It lets you tweak the settings too.

GNOME Night Light feature

0

The title of your question suggests you are looking for a generic tool to adjust brightness/contrast and gamma of your desktop. The body of your question suggests you are looking for automatic adjustment matching the time of day. I was looking for an answer to the first variant and found only xcalib, a command-line utility. Thus I have written a gui front-end for xcalib, which can be found on https://github.com/Ablinne/kolorcontrol.

It provides sliders for brightness/color and gamma for red/green and blue channels respectively. It will display the commands for an autostart script.

  • I'm not sure what you mean by "It will display the commands for an autostart script". Could you perhaps take a screen shot and include it in your answer? – WinEunuuchs2Unix Mar 21 '18 at 1:04
0

If you have a laptop you can control the backlight brightness. When you suspend and resume or reboot the last setting is automatically restored in Ubuntu 16.04. With Ubuntu 14.04 and earlier you sometimes had to write your own scripts to restore the brightness else it would be full brightness and fry your eyeballs.

The basic problem with a default Ubuntu 16.04 installation is you need to adjust brightness lower starting at sunset and adjust it higher after sunrise. To automate the process I developed this bash script: Automatically adjust display brightness based on sunrise and sunset

Key Features

  • Automatically get sunrise and sunset times each day with cron.
  • Start display-auto-brightness automatically every boot with cron.
  • Set different daytime and nighttime brightness settings.
  • Set different transition length in minutes after sunrise and before sunset. Usually 60 to 120 minutes.
  • Brightness adjusts every minute for transparent unnoticeable operation.
  • Instant/transparent brightness adjustment resuming from suspend.

Future Development

  • Plans for software controls of External Monitors that do not have ambient light sensors by using xrandr.
  • Plans for Windows 10 support when Ubuntu on Bash on Windows (WSL) is installed along with VcXsrv and Ubuntu Desktop GUI in Windows 10.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.