Add dbus methods and CLI args for battery charge limit

This commit is contained in:
Luke
2020-06-26 16:23:37 +12:00
5 changed files with 127 additions and 7 deletions

View File

@@ -121,6 +121,19 @@ impl AuraDbusWriter {
Err(Box::new(dbus::Error::new_custom("name", "message")))
}
#[inline]
pub fn write_charge_limit(&self, level: u8) -> Result<String, Box<dyn std::error::Error>> {
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "ChargeLimit")?
.append1(level);
let r = self
.connection
.send_with_reply_and_block(msg, Duration::from_millis(5000))?;
if let Some(reply) = r.get1::<&str>() {
return Ok(reply.to_owned());
}
Err(Box::new(dbus::Error::new_custom("name", "message")))
}
#[inline]
pub fn write_builtin_mode(
&self,