midoshouse / ootr-multiworld

An alternative implementation of multiworld for the Ocarina of Time randomizer
https://midos.house/mw
MIT License
9 stars 1 forks source link

Dark theme ignored on Ubuntu #31

Closed fenhl closed 1 year ago

fenhl commented 1 year ago

The dark-light crate which we're using to detect the system theme currently does not work properly on Ubuntu. There is a gsettings command which in some situations reports the theme correctly but errors in others. Need to investigate whether it works correctly in normal use of the multiworld installer and app. It's also possible that the gio crate could be used instead of subprocesses.

fenhl commented 1 year ago

Here's code that works when used in an iced app launched from the Files app:

use gio::traits::SettingsExt;

enum Theme {
    Light,
    Dark,
}

fn theme() -> Option<Theme> {
    let settings = gio::Settings::new("org.gnome.desktop.interface");
    if settings.settings_schema().map_or(false, |schema| schema.has_key("color-scheme")) {
        match settings.string("color-scheme").as_str() {
            "prefer-light" => Some(Theme::Light),
            "prefer-dark" => Some(Theme::Dark),
            _ => None,
        }
    } else {
        None
    }
}