Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to zbus 5.x #56

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 108 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ dirs = "5.0.1"
notify = "6.1.1"
tokio = { version = "1.40.0", features = ["macros", "net", "rt"] }
udev = "0.8.0"
zbus = { version = "4.4", default-features = false, features = ["tokio"] }
zbus = { version = "5.0", default-features = false, features = ["tokio"] }
tokio-stream = "0.1.16"
sunrise = "1.0.1"
geoclue2 = { git = "https://github.com/pop-os/dbus-settings-bindings" }
geoclue2 = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
cosmic-theme = { git = "https://github.com/pop-os/libcosmic", features = [
"export",
] }
Expand All @@ -26,8 +26,8 @@ cosmic-config = { git = "https://github.com/pop-os/libcosmic" }
chrono = "0.4.38"
libcosmic = { git = "https://github.com/pop-os/libcosmic" }
acpid_plug = "0.1.2"
upower_dbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
locale1 = { git = "https://github.com/pop-os/dbus-settings-bindings" }
upower_dbus = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
locale1 = { git = "https://github.com/pop-os/dbus-settings-bindings", branch = "zbus5" }
notify-rust = "4.11.3"
walkdir = "2.5.0"
memoize = "0.4.2"
Expand Down
2 changes: 1 addition & 1 deletion src/logind_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
interface = "org.freedesktop.login1.Session",
default_path = "/org/freedesktop/login1/session/auto"
)]
trait LogindSession {
pub trait LogindSession {
fn set_brightness(&self, subsystem: &str, name: &str, brightness: u32) -> zbus::Result<()>;
}
35 changes: 18 additions & 17 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ use tokio::{
use tokio_stream::StreamExt;
use zbus::{
names::{MemberName, UniqueName, WellKnownName},
object_server::SignalEmitter,
zvariant::ObjectPath,
Connection, MatchRule, MessageStream, SignalContext,
Connection, MatchRule, MessageStream,
};
mod battery;
mod brightness_device;
Expand Down Expand Up @@ -69,7 +70,7 @@ impl Config {
#[zbus::interface(name = "com.system76.CosmicSettingsDaemon.Config")]
impl Config {
#[zbus(signal)]
async fn changed(ctxt: &SignalContext<'_>, id: String, key: String) -> zbus::Result<()>;
async fn changed(emitter: &SignalEmitter<'_>, id: String, key: String) -> zbus::Result<()>;
}

impl Config {
Expand Down Expand Up @@ -162,7 +163,7 @@ impl SettingsDaemon {

async fn increase_display_brightness(
&self,
#[zbus(signal_context)] ctxt: zbus::SignalContext<'_>,
#[zbus(signal_emitter)] emitter: SignalEmitter<'_>,
) {
let value = self.display_brightness().await;
if let Some(brightness_device) = self.display_brightness_device.as_ref() {
Expand All @@ -173,20 +174,20 @@ impl SettingsDaemon {
} else {
self.set_display_brightness((value + step).max(0)).await;
}
_ = self.display_brightness_changed(&ctxt).await;
_ = self.display_brightness_changed(&emitter).await;
}
}

async fn decrease_display_brightness(
&self,

#[zbus(signal_context)] ctxt: zbus::SignalContext<'_>,
#[zbus(signal_emitter)] emitter: SignalEmitter<'_>,
) {
let value = self.display_brightness().await;
if let Some(brightness_device) = self.display_brightness_device.as_ref() {
let step = brightness_device.brightness_step() as i32;
self.set_display_brightness((value - step).max(0)).await;
_ = self.display_brightness_changed(&ctxt).await;
_ = self.display_brightness_changed(&emitter).await;
}
}

Expand Down Expand Up @@ -228,7 +229,7 @@ impl SettingsDaemon {
}
let path = config.path(id, version);
let name = config.name(id, version);
let conn = zbus::ConnectionBuilder::session()?
let conn = zbus::connection::Builder::session()?
.name(name.as_str())?
.serve_at(path.to_owned(), config)?
.build()
Expand Down Expand Up @@ -287,7 +288,7 @@ async fn backlight_monitor_task(
.await
.unwrap();

let ctxt = zbus::SignalContext::new(&connection, DBUS_PATH).unwrap();
let emitter = SignalEmitter::new(&connection, DBUS_PATH).unwrap();

match backlight_monitor() {
Ok(mut socket) => {
Expand All @@ -303,7 +304,7 @@ async fn backlight_monitor_task(
_ = interface
.get()
.await
.display_brightness_changed(&ctxt)
.display_brightness_changed(&emitter)
.await;
}
udev::EventType::Remove => {
Expand All @@ -313,14 +314,14 @@ async fn backlight_monitor_task(
_ = interface
.get()
.await
.display_brightness_changed(&ctxt)
.display_brightness_changed(&emitter)
.await;
}
udev::EventType::Change => {
_ = interface
.get()
.await
.display_brightness_changed(&ctxt)
.display_brightness_changed(&emitter)
.await;
}
_ => {}
Expand Down Expand Up @@ -461,7 +462,7 @@ async fn main() -> zbus::Result<()> {
watched_states: watched_states.clone(),
};

let connection = zbus::ConnectionBuilder::session()?
let connection = zbus::connection::Builder::session()?
.name(DBUS_NAME)?
.serve_at(DBUS_PATH, settings_daemon)?
.build()
Expand Down Expand Up @@ -569,7 +570,7 @@ async fn main() -> zbus::Result<()> {
};

if let Err(err) = Config::changed(
config.signal_context(),
config.signal_emitter(),
id.to_string(),
key.to_string(),
)
Expand All @@ -590,7 +591,7 @@ async fn main() -> zbus::Result<()> {
};

if let Err(err) = Config::changed(
state.signal_context(),
state.signal_emitter(),
id.to_string(),
key.to_string(),
)
Expand Down Expand Up @@ -622,7 +623,7 @@ async fn watch_config_message_stream(
) -> zbus::Result<()> {
let mut theme_oneshot_tx = Some(theme_oneshot_tx);
let config_rule = MatchRule::builder()
.msg_type(zbus::MessageType::MethodCall)
.msg_type(zbus::message::Type::MethodCall)
.member("WatchConfig")?
.interface("com.system76.CosmicSettingsDaemon")?
.build();
Expand All @@ -632,7 +633,7 @@ async fn watch_config_message_stream(
HashMap::new();

let state_rule = MatchRule::builder()
.msg_type(zbus::MessageType::MethodCall)
.msg_type(zbus::message::Type::MethodCall)
.member("WatchState")?
.interface("com.system76.CosmicSettingsDaemon")?
.build();
Expand All @@ -642,7 +643,7 @@ async fn watch_config_message_stream(
HashMap::new();

let name_changed_rule = MatchRule::builder()
.msg_type(zbus::MessageType::Signal)
.msg_type(zbus::message::Type::Signal)
.sender("org.freedesktop.DBus")?
.member("NameOwnerChanged")?
.interface("org.freedesktop.DBus")?
Expand Down