This commit is contained in:
2026-04-04 04:24:35 +02:00
parent cb8b641447
commit 52cc041c42
+48 -48
View File
@@ -29,19 +29,19 @@ impl WaybarModule for DndModule {
})?; })?;
// Try toggling SwayNC // Try toggling SwayNC
if let Ok(proxy) = SwayncControlProxy::new(&connection).await { if let Ok(proxy) = SwayncControlProxy::new(&connection).await
if let Ok(is_dnd) = proxy.dnd().await { && let Ok(is_dnd) = proxy.dnd().await
let _ = proxy.set_dnd(!is_dnd).await; {
return Ok(WaybarOutput::default()); let _ = proxy.set_dnd(!is_dnd).await;
} return Ok(WaybarOutput::default());
} }
// Try toggling Dunst // Try toggling Dunst
if let Ok(proxy) = DunstControlProxy::new(&connection).await { if let Ok(proxy) = DunstControlProxy::new(&connection).await
if let Ok(is_paused) = proxy.paused().await { && let Ok(is_paused) = proxy.paused().await
let _ = proxy.set_paused(!is_paused).await; {
return Ok(WaybarOutput::default()); let _ = proxy.set_paused(!is_paused).await;
} return Ok(WaybarOutput::default());
} }
return Err(crate::error::FluxoError::Module { return Err(crate::error::FluxoError::Module {
@@ -118,52 +118,52 @@ impl DndDaemon {
info!("Connected to D-Bus for DND monitoring"); info!("Connected to D-Bus for DND monitoring");
// Try SwayNC // Try SwayNC
if let Ok(proxy) = SwayncControlProxy::new(&connection).await { if let Ok(proxy) = SwayncControlProxy::new(&connection).await
if let Ok(is_dnd) = proxy.dnd().await { && let Ok(is_dnd) = proxy.dnd().await
debug!("Found SwayNC, using it for DND state."); {
let _ = tx.send(DndState { is_dnd }); debug!("Found SwayNC, using it for DND state.");
let _ = tx.send(DndState { is_dnd });
if let Ok(props_proxy) = PropertiesProxy::builder(&connection) if let Ok(props_proxy) = PropertiesProxy::builder(&connection)
.destination("org.erikreider.swaync.control")? .destination("org.erikreider.swaync.control")?
.path("/org/erikreider/swaync/control")? .path("/org/erikreider/swaync/control")?
.build() .build()
.await .await
{ {
let mut stream = props_proxy.receive_properties_changed().await?; let mut stream = props_proxy.receive_properties_changed().await?;
while let Some(signal) = stream.next().await { while let Some(signal) = stream.next().await {
let args = signal.args()?; let args = signal.args()?;
if args.interface_name == "org.erikreider.swaync.control" if args.interface_name == "org.erikreider.swaync.control"
&& let Some(val) = args.changed_properties.get("dnd") && let Some(val) = args.changed_properties.get("dnd")
&& let Ok(is_dnd) = bool::try_from(val) && let Ok(is_dnd) = bool::try_from(val)
{ {
let _ = tx.send(DndState { is_dnd }); let _ = tx.send(DndState { is_dnd });
}
} }
} }
} }
} }
// Try Dunst // Try Dunst
if let Ok(proxy) = DunstControlProxy::new(&connection).await { if let Ok(proxy) = DunstControlProxy::new(&connection).await
if let Ok(is_dnd) = proxy.paused().await { && let Ok(is_dnd) = proxy.paused().await
debug!("Found Dunst, using it for DND state."); {
let _ = tx.send(DndState { is_dnd }); debug!("Found Dunst, using it for DND state.");
let _ = tx.send(DndState { is_dnd });
if let Ok(props_proxy) = PropertiesProxy::builder(&connection) if let Ok(props_proxy) = PropertiesProxy::builder(&connection)
.destination("org.freedesktop.Notifications")? .destination("org.freedesktop.Notifications")?
.path("/org/freedesktop/Notifications")? .path("/org/freedesktop/Notifications")?
.build() .build()
.await .await
{ {
let mut stream = props_proxy.receive_properties_changed().await?; let mut stream = props_proxy.receive_properties_changed().await?;
while let Some(signal) = stream.next().await { while let Some(signal) = stream.next().await {
let args = signal.args()?; let args = signal.args()?;
if args.interface_name == "org.dunstproject.cmd0" if args.interface_name == "org.dunstproject.cmd0"
&& let Some(val) = args.changed_properties.get("paused") && let Some(val) = args.changed_properties.get("paused")
&& let Ok(is_dnd) = bool::try_from(val) && let Ok(is_dnd) = bool::try_from(val)
{ {
let _ = tx.send(DndState { is_dnd }); let _ = tx.send(DndState { is_dnd });
}
} }
} }
} }