1

Online I found the command:

echo 1 > /sys/class/backlight/acpi_video0/brightness

to set my screen brightness to the lowest possible value, currently I am grepping my entire disk for that path, looking for where the laptop hotkey script is so I can change the step size to 1 (so pressing my hotkeys would only change the brightness by 1 percent). I know some people might find this slow, but I am really critical of my night-time screen brightness, and the lower end of the range is much more noticeable thus my desire to have fine control over it.

2
  • sorry but I don't see any mention of the hotkey script location there
    – nmz787
    Oct 19, 2014 at 6:39
  • I'm not sure, but I think the backlight brightness step size cannot be adjusted but is fixed in the device firmware. Oct 20, 2014 at 4:20

1 Answer 1

2

I couldn't find the answer to my question (which would be convenient), but instead coded up a Python GUI with a slider. I made two versions, one with wxPython and one with Tk.

Here's the tk version, which is shorter:

import os
import subprocess
from Tkinter import *

class BrightnessSlider(object):
    find_max_brightness_cmd = ['cat', '/sys/class/backlight/intel_backlight/max_brightness']
    find_brightness_cmd = ['cat', '/sys/class/backlight/intel_backlight/actual_brightness']

    def __init__(self, master):
        min_brightness = 92
        p1 = subprocess.Popen(self.find_brightness_cmd,
                              stdout=subprocess.PIPE)
        p2 = subprocess.Popen(self.find_max_brightness_cmd,
                              stdout=subprocess.PIPE)
        current_brightness, stderr = p1.communicate()
        max_brightness, stderr = p2.communicate()

        self.slider = Scale(master,
                  from_=int(min_brightness),
                  to=int(max_brightness),
                  orient=HORIZONTAL,
                  command=self.on_slide)
        self.slider.set(current_brightness)
        self.slider.pack()
        self.slider.focus_set()

    def on_slide(self, new_value):
        self.set_brightness(new_value)

    def set_brightness(self, new_val):
        with open('/sys/class/backlight/intel_backlight/brightness', 'w') as f:
            f.write(new_val)


if __name__ == "__main__":
    master = Tk()
    b = BrightnessSlider(master)
    mainloop()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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