From 98e633e81253ee439916530d00d706aeccf55d1f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 6 Jan 2019 20:46:09 +0000 Subject: [PATCH] Inital commit --- brightness.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 brightness.py diff --git a/brightness.py b/brightness.py new file mode 100755 index 0000000..91ca96a --- /dev/null +++ b/brightness.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import os, sys, string, subprocess + +def main(): + cmd = "xrandr --verbose | grep {} -A 5 | grep Brightness | cut -f 2 -d ' '".format(test()) + brightness = float(subprocess.getoutput(cmd)) + + if sys.argv[1] == "+" and brightness < 1: + brightness += .25 + elif sys.argv[1] == "-" and brightness > 0: + brightness -= .25 + os.system("xrandr --output {} --brightness {}".format(test(), brightness)) + +def test(): + cmd = "xdotool getmouselocation --shell | head -n -3 | sed 's/[^0-9]*//g'" + cmd = subprocess.getoutput(cmd) + mouse = cmd.split() + + if int(mouse[0]) < 2560: + return "DP-1" + return "DP-2" + +def display(): + cmd = "i3-msg -t get_workspaces | jq '.[] | select(.focused==true).name'" + cmd = subprocess.getoutput(cmd).replace("\"", "") + + if cmd == "8: ": + return "DP-1" + return "DP-2" + +if len(sys.argv) <= 1: + print("Usage: {} [+|-]".format(sys.argv[0])) + sys.exit(1) +else: + main()