Skip to content

Instantly share code, notes, and snippets.

@sl5net
Created November 6, 2020 06:24
Show Gist options
  • Save sl5net/ba9283269432eeffa346e5b904deeb52 to your computer and use it in GitHub Desktop.
Save sl5net/ba9283269432eeffa346e5b904deeb52 to your computer and use it in GitHub Desktop.
# https://askubuntu.com/a/149264/1017209
# xrandr -q | grep " connected"
# bug report:
# there is sometimes a toggle. severel versions of this scripts run sometimes.
# for minutes i have tested this script with "1" and then with with "0.2".
# during this video it jumps back to "1" ?? whey? lets try kill autokey and start it again
# you could see. it dont toggle. if autokey is off. brightness stays. not toggle.
# ups. noooo. i doesent !!!!!!. my system automatically set brightness to 1???? whey??
# so i need a loop that every 10 seconds set the brithness again :( hmmmm. thats not the best solution.
import os, time, subprocess
brightnessNR = "0.2" # night
# brightnessNR = "1" # day
showPopen = False
def popupNotify(text):
if showPopen:
subprocess.Popen(['notify-send', text]) # will be showed right top
for i in range(0, 1000):
time.sleep(.2)
myCmd = 'xrandr --output HDMI-0 --brightness ' + brightnessNR
os.system(myCmd)
popupNotify(myCmd)
#quit()
myCmd = 'xrandr --output DVI-D-0 --brightness ' + brightnessNR
os.system(myCmd)
popupNotify(myCmd)
#quit()
showPopen = True
for i in range(0, 2):
time.sleep(2)
popupNotify("EOF: " + myCmd + " bye bye")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment