James Ridgway - Software Engineer

Fixing Linux Mint screen brightness controls

I've recently installed Linux Mint on my Thinkpad T450s. After installing Mint I noticed that the screen was constantly on full brightness and I couldn't change the brightness using the function keys. With this solution you can adjust the brightness, and ensured that the settings are remembered on restart.

Fixing change brightness

The first step is to determine the graphics card details. By opening System Settings > Sysetm Info, I found that the graphics card is an Intel Corporation Broadwell-U Integrated Graphics.

Run the following in terminal:

$ ls -l /sys/class/backlight/

As we have an Intel graphics card the intel_backlight folder is what we'll need to use:

total 0
lrwxrwxrwx 1 root root 0 Mar 22 15:59 acpi_video0 -> ../../devices/pci0000:00/0000:00:02.0/backlight/acpi_video0
lrwxrwxrwx 1 root root 0 Mar 22 15:30 intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight

Create the file /usr/share/X11/xorg.conf.d/20-intel.conf if it does not already exist and add the following to it:

Section "Device"
    Identifier  "card0"
    Driver      "intel"
    Option      "Backlight"  "intel_backlight"
    BusID       "PCI:0:2:0"
EndSection

Save the file and logout then login for the changes to take affect. You should now find that you can change the brightness settings using keyboard function keys.

Remembering brightness settings

Although the fix in the above section makes brightness settings and brightness keys work, I found that whenever I turned on the laptop the brightness would be restored to maximum. A large number of solutions suggested changing the default upon boot by modifying the /etc/rc.local file to contain the following:

echo 250 > /sys/class/backlight/intel_backlight/brightness

This would set the brightness to 250 when the system boots. This didn't feel like a proper solution to the problem. Instead I wanted something that would save the settings on shutdown and re-apply them on startup. Just before I went about writing my own script to do this I stumbled across the following that I originally found here:

/etc/rc6.d/S25backlight
#! /bin/sh
### BEGIN INIT INFO
# Provides:          brightness
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Save and restore brightness level between restarts.
# Description:       This script saves the brightness level between restarts.
#                    It is called from the boot, halt and reboot scripts.
### END INIT INFO

PATH=/sbin:/bin
SAVEDFILE=/var/lib/brightness-level
DEFAULT_LEVEL=4
BRIGHTNESS_CONTROL=/sys/class/backlight/intel_backlight/brightness

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_status () {
    echo -n "Current brightness level is `cat $BRIGHTNESS_CONTROL`"

    if [ -f $SAVEDFILE ] ; then
        echo ", saved value is `cat $SAVEDFILE`."
        return 0
    else
        echo ", there is no saved value."
        return 4
    fi
}

case "$1" in
  start|"")
    [ "$VERBOSE" = no ] || log_action_begin_msg "Initializing brightness level"
    # Restore brightness level
    if [ ! -f "$SAVEDFILE" ]
    then
        echo "$DEFAULT_LEVEL" > "$SAVEDFILE"
    fi
    cat "$SAVEDFILE" > "$BRIGHTNESS_CONTROL"
    ES=$?

    [ "$VERBOSE" = no ] || log_action_end_msg $ES
    ;;
  stop)
    # Save brightness level
    [ "$VERBOSE" = no ] || log_action_begin_msg "Saving brightness level"
    cat "$BRIGHTNESS_CONTROL" > "$SAVEDFILE"
    ES=$?
    [ "$VERBOSE" = no ] || log_action_end_msg $ES
    ;;
  status)
    do_status
    exit 0
    ;;
  restart|reload|force-reload)
    echo "Error: argument '$1' not supported" >&2
    exit 3
    ;;
  *)
    echo "Usage: brightness start|stop" >&2
    exit 3
    ;;
esac

Place the above script in /etc/rc6.d/S25backlight and create the following symbolic links:

$ ln -s /etc/init.d/brightness /etc/rc0.d/S25backlight
$ ln -s /etc/init.d/brightness /etc/rcS.d/S25backlight
$ ln -s /etc/init.d/brightness /etc/rc6.d/S25backlight

Once you have rebooted, you will find that the current briightness level wil be saved everytime you shutdown, and will be restored upon boot.

Read More