Skip to content

iced::system::theme_changes does not report system appearance changes on macOS 15.7 #3399

Description

@mattly

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I am attempting to use iced::system::theme_changes to create a subscription to notify my app when the system switches between light and dark mode, so my app can follow. It is not working on macOS 15.7. I found a relevant discussion in the discord from last December, but could not find any resolution for that issue. I have a minimal reproduction working:

[package]
name = "iced-theme-changes"
version = "0.1.0"
edition = "2024"

[dependencies]
iced = "0.14.0"
use iced::{
    Element, Length, Subscription, Task, Theme, system,
    theme::Mode,
    widget::{container, text},
};

enum Message {
    ThemeModeChanged(Mode),
}

struct App {
    theme_light: Theme,
    theme_dark: Theme,
    mode: Mode,
}

impl App {
    fn new() -> Self {
        Self {
            theme_light: Theme::Light,
            theme_dark: Theme::Dark,
            mode: Mode::None,
        }
    }

    fn update(&mut self, msg: Message) -> Task<Message> {
        match msg {
            Message::ThemeModeChanged(mode) => self.mode = mode,
        };
        Task::none()
    }

    fn theme(&self) -> Theme {
        match self.mode {
            Mode::None => self.theme_light.clone(),
            Mode::Light => self.theme_light.clone(),
            Mode::Dark => self.theme_dark.clone(),
        }
    }

    fn subscription(&self) -> Subscription<Message> {
        system::theme_changes().map(|mode| {
            std::println!("theme changed! {mode:?}");
            Message::ThemeModeChanged(mode)
        })
    }

    fn view(&self) -> Element<'_, Message> {
        container(text!("Hello Theme Changes"))
            .center(Length::Fill)
            .into()
    }
}

fn main() -> Result<(), iced::Error> {
    iced::application(App::new, App::update, App::view)
        .subscription(App::subscription)
        .theme(App::theme)
        .run()
}

What is the expected behavior?

When I change from "Light" to "Dark" or vice-versa in the macOS Settings app's Appearance pane, it should print a message and change the appearance of the app.

Version

crates.io release

Operating System

macOS

Do you have any log output?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions