1

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.

Zanna
  • 70,465
  • 1
    Vim can't "edit" files /sys because they're not really files. Try something like this – muru Jul 05 '17 at 06: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 05 '17 at 07:43

2 Answers2

2

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])
print(b)
b += int(sys.argv[1])
print(b)
os.system('echo "' + str(b) + '" > /sys/class/backlight/intel_backlight/brightness')
1

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

endrias
  • 597