voidrice/.config/i3/kb-lights.py
Tommy Lane (Luke) 9d56c7d3b6 Adds support for Spotify controls. Fixes issue with keyboard backlight keybinds not being configured correctly.
Fixes issue with spelling in the i3_guide.md file.
    This commit adds comments to gmailrc file to alert users to danger of using their defualt plaintext password, and suggests generating a new app password.
    This closes #1, closes #6, closes #8, closes#11
2017-11-07 22:25:44 -06:00

36 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
# coding: utf-8
from sys import argv
import dbus
def kb_light_set(delta):
bus = dbus.SystemBus()
kbd_backlight_proxy = bus.get_object('org.freedesktop.UPower', '/org/freedesktop/UPower/KbdBacklight')
kbd_backlight = dbus.Interface(kbd_backlight_proxy, 'org.freedesktop.UPower.KbdBacklight')
current = kbd_backlight.GetBrightness()
maximum = kbd_backlight.GetMaxBrightness()
new = max(0, current + delta)
if 0 <= new <= maximum:
current = new
kbd_backlight.SetBrightness(current)
# Return current backlight level percentage
return 100 * current / maximum
if __name__ == '__main__':
if len(argv[1:]) == 1:
if argv[1] == "--up" or argv[1] == "+":
# ./kb-light.py (+|--up) to increment
print(kb_light_set(1))
elif argv[1] == "--down" or argv[1] == "-":
# ./kb-light.py (-|--down) to decrement
print(kb_light_set(-1))
else:
print("Unknown argument:", argv[1])
else:
print("Script takes exactly one argument.", len(argv[1:]), "arguments provided.")