improv: enable dbus-config by default, but only for Linux targets

This commit is contained in:
Michael Aaron Murphy 2025-08-20 16:09:17 +02:00 committed by Michael Murphy
parent 6e7a634398
commit e7b7c3a126
4 changed files with 14 additions and 12 deletions

View file

@ -8,7 +8,7 @@ rust-version = "1.85"
name = "cosmic"
[features]
default = ["multi-window", "a11y"]
default = ["dbus-config", "multi-window", "a11y"]
# Accessibility support
a11y = ["iced/a11y", "iced_accessibility"]
# Enable about widget
@ -27,8 +27,8 @@ applet = [
"multi-window",
]
applet-token = ["applet"]
# Use the cosmic-settings-daemon for config handling
dbus-config = ["cosmic-config/dbus", "dep:zbus", "cosmic-settings-daemon"]
# Use the cosmic-settings-daemon for config handling on Linux targets
dbus-config = []
# Debug features
debug = ["iced/debug"]
# Enables pipewire support in ashpd, if ashpd is enabled
@ -107,7 +107,6 @@ cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-c
chrono = "0.4.40"
cosmic-config = { path = "cosmic-config" }
cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon", optional = true }
cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true }
css-color = "0.2.8"
derive_setters = "0.1.6"
futures = "0.3"
@ -135,6 +134,12 @@ unicode-segmentation = "1.12"
url = "2.5.4"
zbus = { version = "5.7.1", default-features = false, optional = true }
# Enable DBus feature on Linux targets
[target.'cfg(target_os = "linux")'.dependencies]
cosmic-config = { path = "cosmic-config", features = ["dbus"] }
cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings" }
zbus = { version = "5.7.1", default-features = false }
[target.'cfg(unix)'.dependencies]
freedesktop-icons = { package = "cosmic-freedesktop-icons", git = "https://github.com/pop-os/freedesktop-icons" }
freedesktop-desktop-entry = { version = "0.7.11", optional = true }

View file

@ -101,7 +101,7 @@ where
pub fn init(
(mut core, flags): (Core, T::Flags),
) -> (Self, iced::Task<crate::Action<T::Message>>) {
#[cfg(feature = "dbus-config")]
#[cfg(all(feature = "dbus-config", target_os = "linux"))]
{
use iced_futures::futures::executor::block_on;
core.settings_daemon = block_on(cosmic_config::dbus::settings_daemon_proxy()).ok();

View file

@ -89,7 +89,7 @@ pub struct Core {
#[cfg(feature = "single-instance")]
pub(crate) single_instance: bool,
#[cfg(feature = "dbus-config")]
#[cfg(all(feature = "dbus-config", target_os = "linux"))]
pub(crate) settings_daemon: Option<cosmic_settings_daemon::CosmicSettingsDaemonProxy<'static>>,
pub(crate) main_window: Option<window::Id>,
@ -146,7 +146,7 @@ impl Default for Core {
applet: crate::applet::Context::default(),
#[cfg(feature = "single-instance")]
single_instance: false,
#[cfg(feature = "dbus-config")]
#[cfg(all(feature = "dbus-config", target_os = "linux"))]
settings_daemon: None,
portal_is_dark: None,
portal_accent: None,
@ -353,7 +353,7 @@ impl Core {
&self,
config_id: &'static str,
) -> iced::Subscription<cosmic_config::Update<T>> {
#[cfg(feature = "dbus-config")]
#[cfg(all(feature = "dbus-config", target_os = "linux"))]
if let Some(settings_daemon) = self.settings_daemon.clone() {
return cosmic_config::dbus::watcher_subscription(settings_daemon, config_id, false);
}
@ -370,7 +370,7 @@ impl Core {
&self,
state_id: &'static str,
) -> iced::Subscription<cosmic_config::Update<T>> {
#[cfg(feature = "dbus-config")]
#[cfg(all(feature = "dbus-config", target_os = "linux"))]
if let Some(settings_daemon) = self.settings_daemon.clone() {
return cosmic_config::dbus::watcher_subscription(settings_daemon, state_id, true);
}

View file

@ -18,9 +18,6 @@ use iced_runtime::{Appearance, DefaultStyle};
use std::sync::{Arc, Mutex};
pub use style::*;
#[cfg(feature = "dbus-config")]
use cosmic_config::dbus;
pub type CosmicColor = ::palette::rgb::Srgba;
pub type CosmicComponent = cosmic_theme::Component;
pub type CosmicTheme = cosmic_theme::Theme;