It occurs to me I only answered half the question.
#! /usr/bin/env python3
from subprocess import check_output, call
import argparse as ap
p = ap.ArgumentParser()
p.add_argument("direction", choices = ["+", "-"])
args = p.parse_args()
MAXBRIGHTNESS = 4000 # TODO: UPDATE THIS
STEP = MAXBRIGHTNESS / 10 # We want 10-percent increments
# Get current brightness value
current = check_output(
"pkexec mate-power-backlight-helper --get-brightness",
shell = True
)
# Update brightness value
current = float(current)
new = current
if args.direction == "+":
new += STEP
else:
new -= STEP
# Prevent (under/over)flow of new value
if new < 0:
new = 0
elif new > MAXBRIGHTNESS:
new = MAXBRIGHTNESS
# Update brightness
call(
"pkexec mate-power-backlight-helper --set-brightness " + str(int(new)),
shell = True
)
Save this code into a file, for instance in your home folder in a subfolder named "bin" and with the name "modbrightness.py" and edit inside the file the value for MAXBRIGHTNESS with the one you got previously.
Note: you can also edit the STEP value if you feel a 10% increment is too little.
ouroumov@Bloc:~/Desktop$ ls ~/bin/modbrightness.py
/home/ouroumov/bin/modbrightness.py
ouroumov@Bloc:~/Desktop$
Make it executable using the command:
chmod +x ~/bin/modbrightness.py
Then go to keyboard shortcut preferences, and create a new shortcut (click add):
Note: you have to give the full path to the file including the "/home/your_username
" part.
Then define the key combination you want:
(click 'Disabled')