mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Janky config save/load. Fine for builtin modes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::{core::RogCore, DBUS_IFACE, DBUS_PATH};
|
||||
use crate::{config::Config, core::RogCore, DBUS_IFACE, DBUS_PATH};
|
||||
use dbus::{
|
||||
blocking::Connection,
|
||||
tree::{Factory, MethodErr},
|
||||
@@ -7,12 +7,18 @@ use std::error::Error;
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
let mut config = Config::default().read();
|
||||
let mut core = RogCore::new()?;
|
||||
core.aura_set_mode(&config.builtin)?;
|
||||
let bright = RogCore::aura_brightness_bytes(config.brightness)?;
|
||||
core.aura_set_mode(&bright)?;
|
||||
|
||||
let mut c = Connection::new_system()?;
|
||||
c.request_name(DBUS_IFACE, false, true, false)?;
|
||||
|
||||
// The choice of factory tells us what type of tree we want,
|
||||
// and if we want any extra data inside. We pick the simplest variant.
|
||||
let f = Factory::new_fn::<()>();
|
||||
let f = Factory::new_fnmut::<()>();
|
||||
|
||||
// We create a tree with one object path inside and make that path introspectable.
|
||||
let tree = f.tree(()).add(
|
||||
@@ -30,6 +36,13 @@ pub fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
if let Ok(mut core) = RogCore::new() {
|
||||
match core.aura_set_mode(&bytes[..]) {
|
||||
Ok(_) => {
|
||||
// TODO: create statics out of header bytes
|
||||
if bytes[0] == 0x5a && bytes[1] == 0xba {
|
||||
config.brightness = bytes[4];
|
||||
} else if bytes[0] == 0x5d && bytes[1] == 0xb3 {
|
||||
config.builtin = bytes;
|
||||
}
|
||||
config.write();
|
||||
let mret = m.msg.method_return().append1(s);
|
||||
Ok(vec![mret])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user