This question already has an answer here:

I'm trying to edit the brightness of my System76 laptop screen from my window manager i3wm. I've tried the following:

xbacklight -dec 10

does nothing

sudo vim /sys/class/backlight/intel_backlight/brightness

Even with sudo, and chmod 777 I can't edit this file. Vim says "Fsync failed" when I try to write to it, and I have plenty of disk space available so that is not the problem

xrandr --output eDP-1 --brightness 0.5

this works, but it modulates brightness in software and doesn't have the increment/decrement abilities I want.

marked as duplicate by LiveWireBT, Eric Carvalho, karel, user364819, Zanna Jul 7 '17 at 21:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Vim can't "edit" files /sys because they're not really files. Try something like this – muru Jul 5 '17 at 6:58
  • Yeah that works, thanks. Is there a reason xbacklight isn't doing anything? The brightness file doesn't really fit my needs since I want an increment/decrement feature. I could implement this myself, but it feels like a feature that should work out of the box. – Sauhaarda Chowdhuri Jul 5 '17 at 7:43

Wrote a script that merges answers from @endiras and @muru. Here it is:

import sys
import os
b = int(open('/sys/class/backlight/intel_backlight/brightness').read()[:-1])
b += int(sys.argv[1])
os.system('echo "' + str(b) + '" > /sys/class/backlight/intel_backlight/brightness')

This is a simple script I wrote to solve a similar problem. Clone it from my github and run the backlight.sh script with the brightness level number. If the number you passed to the script as an argument is wrong, there will be an error message which will contain the possible brightness level range.

  1. clone my github repository: git clone https://github.com/el-beth/backlight.sh.git

  2. copy the script which is in backlight.sh/backlight.sh to /bin. use this command:

sudo cp backlight.sh/backlight.sh /bin

  1. make the script executable: sudo chmod +x /bin/backlight.sh

that's all, now from any terminal, you can adjust your screen's brightness.

sudo backlight.sh SOME-VALUE ## replace some value with a number

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