#!/usr/bin/env python
#
# A small wrapper around `light`. Changes the brightness in different deltas
# depending on the current brightness.

# XXX: Maybe log scale makes sense...?

import subprocess
import sys

current = float(subprocess.getoutput("light").strip())

if current < 15:
    value = 1
elif current < 30:
    value = 5
else:
    value = 10

if sys.argv[1] == "increase":
    command = "-A"
elif sys.argv[1] == "decrease":
    command = "-U"
elif sys.argv[1] == "high":
    command = "-S"
    value = 40
elif sys.argv[1] == "low":
    command = "-S"
    value = 1
else:
    raise Exception("Unknown command")

# Apply changes:
subprocess.getoutput(f"light {command} {value}").strip()

# Print new value:
print("New brightness:", int(float(subprocess.getoutput("light").strip())))
