Created
February 7, 2016 18:14
-
-
Save knikolla/fc6983df5913608bcb09 to your computer and use it in GitHub Desktop.
Send a dbus message to upower to refresh device state every 5 seconds.
This file contains hidden or 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
| #!/usr/bin/python | |
| # There is an issue with the power indicator on rMBP 13". | |
| # upower doesn't indicate AC/Batt event change until it polls | |
| # the device after 30 seconds of inactivity. | |
| # Since 30 seconds is too long, using this script I force it | |
| # to refresh after 5 seconds by using the dbus. | |
| import os | |
| import time | |
| while True: | |
| os.system('dbus-send --print-reply \ | |
| --system \ | |
| --dest=org.freedesktop.UPower \ | |
| /org/freedesktop/UPower/devices/battery_BAT0 \ | |
| org.freedesktop.UPower.Device.Refresh') | |
| time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment