There are dbus services from mce
but I haven’t been able to call them successfully.
Maybe just listening on the signal works?
nemo@PGXperiiia10:~ $ busctl tree com.nokia.mce
└─/com
└─/com/nokia
└─/com/nokia/mce
├─/com/nokia/mce/request
└─/com/nokia/mce/signal
nemo@PGXperiiia10:~ $ busctl introspect com.nokia.mce /com/nokia/mce/signal | grep batt
.battery_level_ind signal i - -
.battery_state_ind signal s - -
.battery_status_ind signal s - -
nemo@PGXperiiia10:~ $ busctl introspect com.nokia.mce /com/nokia/mce/request | grep batt
.get_battery_level method - i -
.get_battery_state method - s -
.get_battery_status method - s -
This does get you the percentages, but only after they have changed
dbus-monitor --system sender=com.nokia.mce,interface=com.nokia.mce.signal,member=battery_level_ind
Or in QML:
import QtQuick 2.6
import Sailfish.Silica 1.0
import Nemo.DBus 2.0
ApplicationWindow {
id: app
property int battery
DBusInterface {
signalsEnabled: true
bus: DBus.SystemBus
service: 'com.nokia.mce'
path: '/com/nokia/mce/signal'
iface: 'com.nokia.mce.signal'
function battery_level_ind(v){
console.debug ("Battery Level:", v)
app.battery = v
}
}
initialPage: Component { Page{
SilicaFlickable {
anchors.fill: parent
Label {
anchors.centerIn: parent
font.pixelSize: 155
text: app.battery
}
} }
}
}