2019-01-06 20:46:09 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2019-04-12 06:05:43 +00:00
|
|
|
import os, sys, string, subprocess, json
|
2019-01-06 20:46:09 +00:00
|
|
|
|
|
|
|
def main():
|
2019-01-06 20:53:00 +00:00
|
|
|
cmd = "xrandr --verbose | grep {} -A 5 | grep Brightness | cut -f 2 -d ' '".format(display())
|
2019-01-06 20:46:09 +00:00
|
|
|
brightness = float(subprocess.getoutput(cmd))
|
|
|
|
|
|
|
|
if sys.argv[1] == "+" and brightness < 1:
|
|
|
|
brightness += .25
|
|
|
|
elif sys.argv[1] == "-" and brightness > 0:
|
|
|
|
brightness -= .25
|
2019-01-06 20:53:00 +00:00
|
|
|
os.system("xrandr --output {} --brightness {}".format(display(), brightness))
|
2019-01-06 20:46:09 +00:00
|
|
|
|
2019-01-06 20:53:00 +00:00
|
|
|
def display():
|
2019-04-12 06:05:43 +00:00
|
|
|
cmd = "xdotool getmouselocation --shell | head -n -3 | cut -d'=' -f2-"
|
2019-01-06 20:46:09 +00:00
|
|
|
cmd = subprocess.getoutput(cmd)
|
2019-04-12 06:05:43 +00:00
|
|
|
|
|
|
|
#print(getDisplay()['display0']);
|
2019-01-06 20:46:09 +00:00
|
|
|
|
2019-01-06 20:53:00 +00:00
|
|
|
if int(cmd) < 2560:
|
2019-04-12 06:05:43 +00:00
|
|
|
return getDisplay()['display1']
|
|
|
|
return getDisplay()['display0']
|
|
|
|
|
|
|
|
def getDisplay():
|
|
|
|
root_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
json_path = os.path.join(root_dir, 'settings.json')
|
|
|
|
with open(json_path, 'r') as json_data:
|
|
|
|
settings = json.load(json_data)
|
|
|
|
json_data.close()
|
|
|
|
return settings
|
2019-01-06 20:46:09 +00:00
|
|
|
|
|
|
|
if len(sys.argv) <= 1:
|
|
|
|
print("Usage: {} [+|-]".format(sys.argv[0]))
|
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
main()
|