Skip to content

Instantly share code, notes, and snippets.

@d9k
Created July 24, 2015 05:46
Show Gist options
  • Save d9k/275d9f970b4fd3b478dc to your computer and use it in GitHub Desktop.
Save d9k/275d9f970b4fd3b478dc to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# change brightness level on all monitors simultaneously on linux ubuntu
import os
import re
from sys import argv
try:
brightness_level = float(argv[1])
except IndexError:
brightness_level = 1.0
if brightness_level <= 0:
brightness_level = 0.1
xrandr_lines = os.popen("xrandr").read()
outputs = re.findall(r'([\-\w]+) connected', xrandr_lines, re.M)
for output in outputs:
os.popen("xrandr --output " + output + " --brightness " + str(brightness_level))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment