Skip to content

Commit 73446ca

Browse files
authored
Support disabling WM support (#45)
Most people profit from a bar that supports multiple compositors. But some (like me), depend on special features of a compositor and as such only ever use one of the supported compositors. Being able to disable support for the others, at compile time, allows them to remove dead code from their system.
1 parent c9cee90 commit 73446ca

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ serde_json = "1"
1616
serde = { version = "1", features = ["derive"] }
1717
signal-hook = { version = "0.3", default-features = false }
1818
toml = { version = "0.8", default-features = false, features = ["parse"] }
19-
wayrs-client = "1.0"
19+
wayrs-client = "1.0"
2020
wayrs-protocols = { version = "0.14", features = ["wlr-layer-shell-unstable-v1", "viewporter", "fractional-scale-v1"] }
2121
wayrs-utils = { version = "0.17", features = ["cursor", "shm_alloc", "seats"] }
2222
clap = { version = "4.3", default-features = false, features = ["derive", "std", "help", "usage"] }
2323
libc = "0.2"
2424

25+
[features]
26+
default = ["river", "niri", "hyprland"]
27+
river = []
28+
niri = []
29+
hyprland = []
30+
2531
[profile.release]
2632
lto = "fat"
2733
strip = true

src/shared_state.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ impl SharedState {
2222
<dyn Any>::downcast_mut(self.wm_info_provider.as_mut())
2323
}
2424

25+
#[cfg(feature = "river")]
2526
pub fn get_river(&mut self) -> Option<&mut wm_info_provider::RiverInfoProvider> {
2627
self.downcast_provider()
2728
}
2829

30+
#[cfg(feature = "hyprland")]
2931
pub fn get_hyprland(&mut self) -> Option<&mut wm_info_provider::HyprlandInfoProvider> {
3032
self.downcast_provider()
3133
}
3234

35+
#[cfg(feature = "niri")]
3336
pub fn get_niri(&mut self) -> Option<&mut wm_info_provider::NiriInfoProvider> {
3437
self.downcast_provider()
3538
}

src/wm_info_provider.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ use crate::state::State;
1212
mod dummy;
1313
pub use dummy::*;
1414

15+
#[cfg(feature = "river")]
1516
mod river;
17+
#[cfg(feature = "river")]
1618
pub use river::*;
1719

20+
#[cfg(feature = "hyprland")]
1821
mod hyprland;
22+
#[cfg(feature = "hyprland")]
1923
pub use hyprland::*;
2024

25+
#[cfg(feature = "niri")]
2126
mod niri;
27+
#[cfg(feature = "niri")]
2228
pub use niri::*;
2329

2430
pub trait WmInfoProvider: Any {
@@ -49,14 +55,17 @@ pub trait WmInfoProvider: Any {
4955
}
5056

5157
pub fn bind(conn: &mut Connection<State>, config: &WmConfig) -> Box<dyn WmInfoProvider> {
58+
#[cfg(feature = "river")]
5259
if let Some(river) = RiverInfoProvider::bind(conn, config) {
5360
return Box::new(river);
5461
}
5562

63+
#[cfg(feature = "hyprland")]
5664
if let Some(hyprland) = HyprlandInfoProvider::new() {
5765
return Box::new(hyprland);
5866
}
5967

68+
#[cfg(feature = "niri")]
6069
if let Some(niri) = NiriInfoProvider::new() {
6170
return Box::new(niri);
6271
}

0 commit comments

Comments
 (0)