1
0
Fork 0
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:
Rodrigo Batista de Moraes 2024-08-05 09:22:01 -03:00 committed by GitHub
parent 4f2f890c93
commit e307e15dc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 411 additions and 72 deletions

View file

@ -14,6 +14,8 @@ pub mod lua;
pub mod music;
#[cfg(feature = "network_manager")]
pub mod networkmanager;
#[cfg(feature = "sway")]
pub mod sway;
#[cfg(feature = "notifications")]
pub mod swaync;
#[cfg(feature = "tray")]
@ -31,6 +33,8 @@ pub struct Clients {
wayland: Option<Arc<wayland::Client>>,
#[cfg(feature = "workspaces")]
workspaces: Option<Arc<dyn compositor::WorkspaceClient>>,
#[cfg(feature = "sway")]
sway: Option<Arc<sway::Client>>,
#[cfg(feature = "clipboard")]
clipboard: Option<Arc<clipboard::Client>>,
#[cfg(feature = "cairo")]
@ -76,7 +80,7 @@ impl Clients {
let client = match &self.workspaces {
Some(workspaces) => workspaces.clone(),
None => {
let client = compositor::Compositor::create_workspace_client()?;
let client = compositor::Compositor::create_workspace_client(self)?;
self.workspaces.replace(client.clone());
client
}
@ -85,6 +89,21 @@ impl Clients {
Ok(client)
}
#[cfg(feature = "sway")]
pub fn sway(&mut self) -> ClientResult<sway::Client> {
let client = match &self.sway {
Some(client) => client.clone(),
None => {
let client = await_sync(async { sway::Client::new().await })?;
let client = Arc::new(client);
self.sway.replace(client.clone());
client
}
};
Ok(client)
}
#[cfg(feature = "cairo")]
pub fn lua(&mut self, config_dir: &Path) -> Rc<lua::LuaEngine> {
self.lua