Option to pause Variety when on battery power
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Variety |
Triaged
|
Medium
|
Peter Levi |
Bug Description
As confirmed already, Variety's use of Python 2's threading.
We may provide an option to pause Variety entirely when on battery power.
For more detailed setup (e.g. not pause, but reduce the rate of change/download), we need to have support for profiles and let the user switch profiles when on battery - this is overkill for now. AND this won't actually kill the interruptions, which happen no matter what the wait() timeout is.
To listen for battery changes:
dbus and UPower
http://
http://
Monitor changed, and then check the "OnBattery" property.
Ivo Anjo (knuckles) wrote 56 minutes ago: #19
Ok, so to be more exact, I hacked the example, and it seems to work on my laptop. I ran with python -mtrace --trace and python is really doing nothing, and it doesn't show up on powertop.
Would something like this be an acceptable solution? :)
#######
import dbus # for dbus communication (obviously)
import gobject # main loop
from dbus.mainloop.glib import DBusGMainLoop # integration into the main loop
DBusGMainLoop(
bus = dbus.SystemBus() # connect to dbus system wide
proxy = bus.get_
properties_manager = dbus.Interface(
def changed():
print "Onbattery:" + str(properties_
bus.add_
changed, # name of callback function
'Changed', # singal name
'org.
'org.
)
changed()
loop = gobject.MainLoop() # define mainloop
loop.run() # run main loop
#######
You asked in the original bug report:
Can you give this a try with dbus.SessionBus() instead of dbus.SystemBus() (I'm not on a laptop now and don't have a battery...) - this is what Variety uses already for command line communication.
I tried it and it's not there. I guess that since it's a system-wide service it doesn't connect to the session dbus.
Also, while you can't try "unplugging" your desktop, the property is still there on a desktop, just always returns false.