#! /usr/bin/env python3 # /opt/bin/backlight # updated for Plasma 5.3 and later import sys import dbus import notify2 # set whatever you like icon = "/usr/share/icons/oxygen/32x32/devices/video-display.png" bus = dbus.SessionBus() power = bus.get_object('org.kde.Solid.PowerManagement', '/org/kde/Solid/PowerManagement/Actions/BrightnessControl') iface = dbus.Interface(power, 'org.kde.Solid.PowerManagement.Actions.BrightnessControl') def main(): brightness = int(iface.brightness()) new_value = brightness + int(sys.argv[1])*2 if new_value > 200: new_value=200 if new_value < 0: new_value=0 if brightness == new_value: return iface.setBrightness(new_value) if not notify2.init('backlight'): sys.exit(0) # notify2 is out of reach ni = notify2.Notification("Backlight", str(new_value//2), icon) ni.timeout = 5000 if not ni.show(): sys.exit(1) # notify2 is not operational if __name__ == '__main__': main()