Bump version

This commit is contained in:
Luke D Jones
2020-09-29 21:30:05 +13:00
parent f61f62c219
commit 9ffeb19c8c
8 changed files with 58 additions and 52 deletions

View File

@@ -16,15 +16,9 @@ pub struct CtrlCharge {
config: Arc<Mutex<Config>>,
}
trait Dbus {
fn set_limit(&mut self, charge: u8);
fn limit(&self) -> i8;
fn notify_charge(&self, limit: u8) -> zbus::Result<()>;
}
#[dbus_interface(name = "org.asuslinux.Daemon")]
impl Dbus for CtrlCharge {
fn set_limit(&mut self, limit: u8) {
impl CtrlCharge {
pub fn set_limit(&mut self, limit: u8) {
if let Ok(mut config) = self.config.try_lock() {
self.set(limit, &mut config)
.map_err(|err| {
@@ -41,7 +35,7 @@ impl Dbus for CtrlCharge {
}
}
fn limit(&self) -> i8 {
pub fn limit(&self) -> i8 {
if let Ok(config) = self.config.try_lock() {
return config.bat_charge_limit as i8;
}
@@ -49,7 +43,7 @@ impl Dbus for CtrlCharge {
}
#[dbus_interface(signal)]
fn notify_charge(&self, limit: u8) -> zbus::Result<()>;
pub fn notify_charge(&self, limit: u8) -> zbus::Result<()>;
}
impl crate::ZbusAdd for CtrlCharge {

View File

@@ -17,6 +17,8 @@ use std::sync::Mutex;
use zbus::fdo;
use zbus::Connection;
use std::convert::Into;
use std::convert::TryInto;
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut logger = env_logger::Builder::new();
@@ -134,6 +136,11 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
}
});
object_server.with(&"/org/asuslinux/Charge".try_into()?, |obj: &CtrlCharge| {
let x = obj.limit();
obj.notify_charge(x as u8)
})?;
loop {
if let Err(err) = object_server.try_handle_next() {
eprintln!("{}", err);