Created
March 15, 2019 21:49
-
-
Save barraponto/1dc795bb26e6d3d97054bc5de7750fa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Cycles keyboard brightness levels using DBus.''' | |
import dbus | |
def main(): | |
bus = dbus.SystemBus() | |
proxy = bus.get_object('org.freedesktop.UPower', | |
'/org/freedesktop/UPower/KbdBacklight') | |
interface = dbus.Interface(proxy, 'org.freedesktop.UPower.KbdBacklight') | |
current_level = interface.GetBrightness() | |
max_level = interface.GetMaxBrightness() | |
interface.SetBrightness((current_level+1) % (max_level+1)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment