Docs are work in progress
Skip to main content

Display

Changing Display Brightness Using /sys/class/backlight

Managing display brightness on a Linux system can often be done through the /sys/class/backlight interface, particularly if you have root access. This guide will show you how to view the current brightness, set a new brightness value, and check the maximum brightness level for your display.

Understanding /sys/class/backlight

The /sys/class/backlight directory provides a method to control the brightness of displays. This is particularly useful for laptops or devices where direct hardware controls are accessible via the Linux kernel. To control external displays via DDC/CI, you will need the ddcci-backlight kernel driver.

Viewing and Modifying Brightness

1. Find the Current Brightness Value

First, you can view the current brightness value by reading the brightness file in the /sys/class/backlight directory:

cat /sys/class/backlight/*/brightness

This command will return the current brightness level of your display.

2. Check the Maximum Brightness Value

Before setting a new brightness value, it's important to know the maximum brightness your display supports. You can find this by reading the max_brightness file:

cat /sys/class/backlight/*/max_brightness

This will return the maximum value you can set for the brightness.

3. Set a New Brightness Value

To set a new brightness value, you'll need to write to the brightness file. The new value should be between 0 and the maximum value obtained in the previous step. Replace <new_value> with your desired brightness level:

echo <new_value> | sudo tee /sys/class/backlight/*/brightness

For example, if you want to set the brightness to 100, and your device uses intel_backlight, you would execute:

echo 100 | sudo tee /sys/class/backlight/*/brightness
warning

"*" should be replace by actual display device name that you're working with

Conclusion

By using the /sys/class/backlight directory, you can easily manage your display's brightness on a Linux system with root access. This method is particularly useful for devices with hardware-supported brightness control. Always ensure the brightness value you set is within the allowable range to avoid display issues.