feat: cosmic settings daemon (#8)

* feat: cosmic settings daemon

* refactor: simplify by unifying trait for state and config

* chore: add ping and pong methods

* refactor: remove ping & pong methods

* cleanup
This commit is contained in:
Ashley Wulber 2023-12-29 17:46:43 -05:00 committed by GitHub
parent 2ef53b2bfa
commit 3644bc9099
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 124 additions and 0 deletions

View file

@ -0,0 +1,33 @@
use futures::StreamExt;
#[tokio::main]
async fn main() -> zbus::Result<()> {
let connection = zbus::Connection::session().await?;
let proxy = cosmic_settings_daemon::CosmicSettingsDaemonProxy::new(&connection).await?;
println!("Display brightness: {}", proxy.display_brightness().await?);
println!(
"Keyboard brightness: {}",
proxy.keyboard_brightness().await?
);
let (config_path, name) = proxy
.watch_config("com.system76.CosmicTheme.Light", 1)
.await?;
dbg!(&config_path, &name);
let config_proxy = cosmic_settings_daemon::ConfigProxy::builder(&connection)
.path(config_path)?
.destination(name)?
.build()
.await?;
let mut stream = config_proxy.receive_changed().await?;
println!("Watching config for the libcosmic light theme...");
println!("Change the light theme in Settings > Appearance to trigger a signal.");
while let Some(c) = stream.next().await {
let c = c.args()?;
println!("Config changed: {} {}", c.id, c.key);
}
Ok(())
}