Commit 6569580b authored by Jamie Tanna's avatar Jamie Tanna
Browse files

Blogument brightness controls with `sysfs`

parent 57f26d6d
Pipeline #406533318 passed with stages
in 4 minutes and 52 seconds
title: "Controlling the Linux Backlight via the Command-Line"
description: "How to manage your screen backlight on the command-line, without installing any tools."
date: 2021-11-10T19:15:41+0000
- blogumentation
- command-line
- linux
license_code: "Apache-2.0"
license_prose: "CC-BY-NC-SA-4.0"
slug: "linux-backlight-cli"
Let's say that you've just installed your laptop, and you've forgotten to install `xbacklight` to manage your backlight settings, or you do have it, and it's randomly stopped working.
Fortunately on Linux, `sysfs` allows you to interact with the backlight system, just by writing to "files" on disk, nothing else needed!
First, you'll need to check which devices are available. For instance:
ls -l /sys/class/backlight/
# on my laptop:
total 0
lrwxrwxrwx 1 root root 0 Nov 10 12:08 intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight
Next, we can check what it's currently set to:
cat /sys/class/backlight/intel_backlight/brightness
And to check the maximum available for the device:
cat /sys/class/backlight/intel_backlight/max_brightness
And then if we want to control the brightness, we can write to the `brightness` file with the brightness value we want to set it to:
echo 200 | sudo tee /sys/class/backlight/intel_backlight/brightness
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment