Brightness controls not working on Gigabyte display
Brightness controls not working on Gigabyte display

Brightness controls not working on Gigabyte display

We wrote some crummy code that adjusts it with xrandr – depending on whether the file is named brighter or darker – and then I bound it to some soft keys. The xrandr setting does not survive suspend though.

#! /usr/bin/python

import os,sys,time

delta=0.0
if sys.argv[0].find('brighter')>0:
    delta=0.05
elif sys.argv[0].find('darker')>0:
    delta=-0.05

default=0.4
minimum=0.05
maximum=1.5

brightfile=os.environ['HOME']+'/.bright'
try:
    brightness=float(open(brightfile,'r').read().strip())
except:
    brightness=0.4

brightness=max(min(brightness+delta,maximum),minimum)

cmd='xrandr --output eDP-1 --rate 60 --mode 1920x1080  --brightness %0.2f' % brightness
os.system(cmd)
if time.time()-os.stat(brightfile).st_mtime > 1.2:
    notify='''notify-send  -u low -a xrandr --icon=video-display 'OLED brightness' '%s' ''' % cmd
    os.system(notify)
open(brightfile,'w').write('%0.2f\n' % brightness)
5/5 - (1 vote)