mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
feat: new sway-mode module (#671)
* feat: add sway-mode module * refactor: Avoid making multiple connections to SwayIPC Now `sway::Client` is store in `ironbar.clients`, and allow dynamically registering event listeners, instead of hardcoding events for Workspace updates. Remove the use of `swayipc::Connection` from `sway-mode` module, and replace it with the new event listener system. #671
This commit is contained in:
parent
4f2f890c93
commit
e307e15dc4
11 changed files with 411 additions and 72 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::{await_sync, register_fallible_client};
|
||||
use crate::register_fallible_client;
|
||||
use cfg_if::cfg_if;
|
||||
use color_eyre::{Help, Report, Result};
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
|
@ -56,13 +56,16 @@ impl Compositor {
|
|||
|
||||
/// Creates a new instance of
|
||||
/// the workspace client for the current compositor.
|
||||
pub fn create_workspace_client() -> Result<Arc<dyn WorkspaceClient + Send + Sync>> {
|
||||
pub fn create_workspace_client(
|
||||
clients: &mut super::Clients,
|
||||
) -> Result<Arc<dyn WorkspaceClient + Send + Sync>> {
|
||||
let current = Self::get_current();
|
||||
debug!("Getting workspace client for: {current}");
|
||||
match current {
|
||||
#[cfg(feature = "workspaces+sway")]
|
||||
Self::Sway => await_sync(async { sway::Client::new().await })
|
||||
.map(|client| Arc::new(client) as Arc<dyn WorkspaceClient + Send + Sync>),
|
||||
Self::Sway => clients
|
||||
.sway()
|
||||
.map(|client| client as Arc<dyn WorkspaceClient + Send + Sync>),
|
||||
#[cfg(feature = "workspaces+hyprland")]
|
||||
Self::Hyprland => Ok(Arc::new(hyprland::Client::new())),
|
||||
Self::Unsupported => Err(Report::msg("Unsupported compositor")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue