UI(Tauri): Replace local rust-dark-light with published dark-light crate
https://github.com/safing/portmaster/issues/2051
This commit is contained in:
4
desktop/tauri/rust-dark-light/.gitignore
vendored
4
desktop/tauri/rust-dark-light/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
/target
|
||||
/examples/*/target
|
||||
Cargo.lock
|
||||
.vscode
|
||||
@@ -1,34 +0,0 @@
|
||||
[package]
|
||||
name = "dark-light"
|
||||
version = "1.1.1"
|
||||
authors = ["Corey Farwell <coreyf@rwell.org>"]
|
||||
edition = "2018"
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/frewsxcv/rust-dark-light"
|
||||
description = "Detect if dark mode or light mode is enabled"
|
||||
readme = "README.md"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3.30"
|
||||
anyhow = "1.0.79"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1.23.0", features = ["full"] }
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||
detect-desktop-environment = "1.0.0"
|
||||
dconf_rs = "0.3"
|
||||
zbus = "3.0"
|
||||
rust-ini = "0.20"
|
||||
ashpd = "0.7.0"
|
||||
xdg = "2.4.1"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winreg = "0.52.0"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
objc = "0.2"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
web-sys = { version = "0.3", features = ["MediaQueryList", "Window"] }
|
||||
@@ -1,39 +0,0 @@
|
||||
# rust-dark-light
|
||||
|
||||
Rust crate to detect if dark mode or light mode is enabled. Supports macOS, Windows, Linux, BSDs, and WASM. On Linux and BSDs, first the XDG Desktop Portal dbus API is checked for the `color-scheme` preference, which works in Flatpak sandboxes without needing filesystem access. If that does not work, fallback methods are used for KDE, GNOME, Cinnamon, MATE, XFCE, and Unity.
|
||||
|
||||
[API Documentation](https://docs.rs/dark-light/)
|
||||
|
||||
## Usage
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
let mode = dark_light::detect();
|
||||
|
||||
match mode {
|
||||
// Dark mode
|
||||
dark_light::Mode::Dark => {},
|
||||
// Light mode
|
||||
dark_light::Mode::Light => {},
|
||||
// Unspecified
|
||||
dark_light::Mode::Default => {},
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```
|
||||
cargo run --example detect
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Licensed under either of
|
||||
|
||||
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||
|
||||
at your option.
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
fn main() {
|
||||
if let Ok("apple") = std::env::var("CARGO_CFG_TARGET_VENDOR").as_deref() {
|
||||
println!("cargo:rustc-link-lib=framework=AppKit");
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
use detect_desktop_environment::DesktopEnvironment;
|
||||
use ini::Ini;
|
||||
use std::path::{Path, PathBuf};
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
use crate::Mode;
|
||||
|
||||
const XDG_KDEGLOBALS: &str = "/etc/xdg/kdeglobals";
|
||||
|
||||
fn get_freedesktop_color_scheme() -> Option<Mode> {
|
||||
let conn = Connection::session();
|
||||
if conn.is_err() {
|
||||
return None;
|
||||
}
|
||||
let reply = conn.unwrap().call_method(
|
||||
Some("org.freedesktop.portal.Desktop"),
|
||||
"/org/freedesktop/portal/desktop",
|
||||
Some("org.freedesktop.portal.Settings"),
|
||||
"Read",
|
||||
&("org.freedesktop.appearance", "color-scheme"),
|
||||
);
|
||||
if let Ok(reply) = &reply {
|
||||
let theme = reply.body().deserialize::<u32>();
|
||||
if theme.is_err() {
|
||||
return None;
|
||||
}
|
||||
|
||||
match theme.unwrap() {
|
||||
1 => Some(Mode::Dark),
|
||||
2 => Some(Mode::Light),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn detect_gtk(pattern: &str) -> Mode {
|
||||
match dconf_rs::get_string(pattern) {
|
||||
Ok(theme) => Mode::from(theme.to_lowercase().contains("dark")),
|
||||
Err(_) => Mode::Light,
|
||||
}
|
||||
}
|
||||
|
||||
fn detect_kde(path: &str) -> Mode {
|
||||
match Ini::load_from_file(path) {
|
||||
Ok(cfg) => {
|
||||
let section = match cfg.section(Some("Colors:Window")) {
|
||||
Some(section) => section,
|
||||
None => return Mode::Light,
|
||||
};
|
||||
let values = match section.get("BackgroundNormal") {
|
||||
Some(string) => string,
|
||||
None => return Mode::Light,
|
||||
};
|
||||
let rgb = values
|
||||
.split(',')
|
||||
.map(|s| s.parse::<u32>().unwrap_or(255))
|
||||
.collect::<Vec<u32>>();
|
||||
let rgb = if rgb.len() > 2 {
|
||||
rgb
|
||||
} else {
|
||||
vec![255, 255, 255]
|
||||
};
|
||||
let (r, g, b) = (rgb[0], rgb[1], rgb[2]);
|
||||
Mode::rgb(r, g, b)
|
||||
}
|
||||
Err(_) => Mode::Light,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn detect() -> Mode {
|
||||
match get_freedesktop_color_scheme() {
|
||||
Some(mode) => mode,
|
||||
// Other desktop environments are still being worked on, fow now, only the following implementations work.
|
||||
None => match DesktopEnvironment::detect() {
|
||||
DesktopEnvironment::Kde => {
|
||||
let path = if Path::new(XDG_KDEGLOBALS).exists() {
|
||||
PathBuf::from(XDG_KDEGLOBALS)
|
||||
} else {
|
||||
dirs::home_dir().unwrap().join(".config/kdeglobals")
|
||||
};
|
||||
detect_kde(path.to_str().unwrap())
|
||||
}
|
||||
DesktopEnvironment::Cinnamon => detect_gtk("/org/cinnamon/desktop/interface/gtk-theme"),
|
||||
DesktopEnvironment::Gnome => detect_gtk("/org/gnome/desktop/interface/gtk-theme"),
|
||||
DesktopEnvironment::Mate => detect_gtk("/org/mate/desktop/interface/gtk-theme"),
|
||||
DesktopEnvironment::Unity => detect_gtk("/org/gnome/desktop/interface/gtk-theme"),
|
||||
_ => Mode::Default,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
//! Detect if dark mode or light mode is enabled.
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! ```
|
||||
//! let mode = dark_light::detect();
|
||||
//!
|
||||
//! match mode {
|
||||
//! // Dark mode
|
||||
//! dark_light::Mode::Dark => {},
|
||||
//! // Light mode
|
||||
//! dark_light::Mode::Light => {},
|
||||
//! // Unspecified
|
||||
//! dark_light::Mode::Default => {},
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
mod platforms;
|
||||
use platforms::platform;
|
||||
|
||||
mod utils;
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
use utils::rgb::Rgb;
|
||||
|
||||
/// Enum representing dark mode, light mode, or unspecified.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum Mode {
|
||||
/// Dark mode
|
||||
Dark,
|
||||
/// Light mode
|
||||
Light,
|
||||
/// Unspecified
|
||||
Default,
|
||||
}
|
||||
|
||||
impl Mode {
|
||||
#[allow(dead_code)]
|
||||
fn from_bool(b: bool) -> Self {
|
||||
if b {
|
||||
Mode::Dark
|
||||
} else {
|
||||
Mode::Light
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
/// Convert an RGB color to [`Mode`]. The color is converted to grayscale, and if the grayscale value is less than 192, [`Mode::Dark`] is returned. Otherwise, [`Mode::Light`] is returned.
|
||||
fn from_rgb(rgb: Rgb) -> Self {
|
||||
let window_background_gray = (rgb.0 * 11 + rgb.1 * 16 + rgb.2 * 5) / 32;
|
||||
if window_background_gray < 192 {
|
||||
Self::Dark
|
||||
} else {
|
||||
Self::Light
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Detect if light mode or dark mode is enabled. If the mode can’t be detected, fall back to [`Mode::Default`].
|
||||
pub use platform::detect::detect;
|
||||
/// Notifies the user if the system theme has been changed.
|
||||
pub use platform::notify::subscribe;
|
||||
@@ -1,47 +0,0 @@
|
||||
use detect_desktop_environment::DesktopEnvironment;
|
||||
|
||||
use crate::Mode;
|
||||
|
||||
use super::{dconf_detect, gsetting_detect, kde_detect, CINNAMON, GNOME, MATE};
|
||||
|
||||
pub fn detect() -> Mode {
|
||||
NonFreeDesktop::detect()
|
||||
}
|
||||
|
||||
/// Detects the color scheme on a platform.
|
||||
trait ColorScheme {
|
||||
fn detect() -> Mode;
|
||||
}
|
||||
|
||||
/// Represents the FreeDesktop platform.
|
||||
struct FreeDesktop;
|
||||
|
||||
/// Represents non FreeDesktop platforms.
|
||||
struct NonFreeDesktop;
|
||||
|
||||
/// Detects the color scheme on FreeDesktop platforms. It makes use of the DBus interface.
|
||||
impl ColorScheme for FreeDesktop {
|
||||
fn detect() -> Mode {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
/// Detects the color scheme on non FreeDesktop platforms, having a custom implementation for each desktop environment.
|
||||
impl ColorScheme for NonFreeDesktop {
|
||||
fn detect() -> Mode {
|
||||
match DesktopEnvironment::detect() {
|
||||
Some(mode) => match mode {
|
||||
DesktopEnvironment::Kde => match kde_detect() {
|
||||
Ok(mode) => mode,
|
||||
Err(_) => Mode::Default,
|
||||
},
|
||||
DesktopEnvironment::Cinnamon => dconf_detect(CINNAMON),
|
||||
DesktopEnvironment::Gnome => gsetting_detect(),
|
||||
DesktopEnvironment::Mate => dconf_detect(MATE),
|
||||
DesktopEnvironment::Unity => dconf_detect(GNOME),
|
||||
_ => Mode::Default,
|
||||
},
|
||||
None => Mode::Default,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
use std::{process::Command, str::FromStr};
|
||||
|
||||
use anyhow::Context;
|
||||
use ini::Ini;
|
||||
|
||||
use crate::{utils::rgb::Rgb, Mode};
|
||||
|
||||
pub mod detect;
|
||||
pub mod notify;
|
||||
|
||||
const MATE: &str = "/org/mate/desktop/interface/gtk-theme";
|
||||
const GNOME: &str = "/org/gnome/desktop/interface/gtk-theme";
|
||||
const CINNAMON: &str = "/org/cinnamon/desktop/interface/gtk-theme";
|
||||
|
||||
fn dconf_detect(path: &str) -> Mode {
|
||||
match dconf_rs::get_string(path) {
|
||||
Ok(theme) => {
|
||||
println!("dconf output: {}", theme);
|
||||
if theme.is_empty() {
|
||||
Mode::Default
|
||||
} else {
|
||||
if theme.to_lowercase().contains("dark") {
|
||||
Mode::Dark
|
||||
} else {
|
||||
Mode::Light
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => Mode::Default,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gsetting_detect() -> Mode {
|
||||
let mode = match Command::new("gsettings")
|
||||
.arg("get")
|
||||
.arg("org.gnome.desktop.interface")
|
||||
.arg("color-scheme")
|
||||
.output()
|
||||
{
|
||||
Ok(output) => {
|
||||
if let Ok(scheme) = String::from_utf8(output.stdout) {
|
||||
if scheme.contains("prefer-dark") {
|
||||
Mode::Dark
|
||||
} else if scheme.contains("prefer-light") {
|
||||
Mode::Dark
|
||||
} else {
|
||||
Mode::Default
|
||||
}
|
||||
} else {
|
||||
Mode::Default
|
||||
}
|
||||
}
|
||||
Err(_) => Mode::Default,
|
||||
};
|
||||
|
||||
// Fallback to dconf
|
||||
if mode == Mode::Default {
|
||||
return dconf_detect(GNOME);
|
||||
}
|
||||
|
||||
mode
|
||||
}
|
||||
|
||||
fn kde_detect() -> anyhow::Result<Mode> {
|
||||
let xdg = xdg::BaseDirectories::new()?;
|
||||
let path = xdg
|
||||
.find_config_file("kdeglobals")
|
||||
.context("Path not found")?;
|
||||
let cfg = Ini::load_from_file(path)?;
|
||||
let properties = cfg
|
||||
.section(Some("Colors:Window"))
|
||||
.context("Failed to get section Colors:Window")?;
|
||||
let background = properties
|
||||
.get("BackgroundNormal")
|
||||
.context("Failed to get BackgroundNormal inside Colors:Window")?;
|
||||
let rgb = Rgb::from_str(background).unwrap();
|
||||
Ok(Mode::from_rgb(rgb))
|
||||
}
|
||||
|
||||
impl From<ashpd::desktop::settings::ColorScheme> for Mode {
|
||||
fn from(value: ashpd::desktop::settings::ColorScheme) -> Self {
|
||||
match value {
|
||||
ashpd::desktop::settings::ColorScheme::NoPreference => Mode::Default,
|
||||
ashpd::desktop::settings::ColorScheme::PreferDark => Mode::Dark,
|
||||
ashpd::desktop::settings::ColorScheme::PreferLight => Mode::Light,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
use ashpd::desktop::settings::{ColorScheme, Settings};
|
||||
use futures::{stream, Stream, StreamExt};
|
||||
use std::task::Poll;
|
||||
|
||||
use crate::{detect, Mode};
|
||||
|
||||
pub async fn subscribe() -> anyhow::Result<impl Stream<Item = Mode> + Send> {
|
||||
let stream = if get_freedesktop_color_scheme().await.is_ok() {
|
||||
let proxy = Settings::new().await?;
|
||||
proxy
|
||||
.receive_color_scheme_changed()
|
||||
.await?
|
||||
.map(Mode::from)
|
||||
.boxed()
|
||||
} else {
|
||||
let mut last_mode = detect();
|
||||
stream::poll_fn(move |ctx| -> Poll<Option<Mode>> {
|
||||
let current_mode = detect();
|
||||
if current_mode != last_mode {
|
||||
last_mode = current_mode;
|
||||
Poll::Ready(Some(current_mode))
|
||||
} else {
|
||||
ctx.waker().wake_by_ref();
|
||||
Poll::Pending
|
||||
}
|
||||
})
|
||||
.boxed()
|
||||
};
|
||||
|
||||
Ok(stream)
|
||||
}
|
||||
|
||||
async fn get_freedesktop_color_scheme() -> anyhow::Result<Mode> {
|
||||
let proxy = Settings::new().await?;
|
||||
let color_scheme = proxy.color_scheme().await?;
|
||||
let mode = match color_scheme {
|
||||
ColorScheme::PreferDark => Mode::Dark,
|
||||
ColorScheme::PreferLight => Mode::Light,
|
||||
ColorScheme::NoPreference => Mode::Default,
|
||||
};
|
||||
Ok(mode)
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// Dark/light mode detection on macOS.
|
||||
// Written with help from Ryan McGrath (https://rymc.io/).
|
||||
|
||||
use crate::Mode;
|
||||
use objc::runtime::Object;
|
||||
use objc::{class, msg_send, sel, sel_impl};
|
||||
|
||||
extern "C" {
|
||||
static NSAppearanceNameAqua: *const Object;
|
||||
static NSAppearanceNameAccessibilityHighContrastAqua: *const Object;
|
||||
static NSAppearanceNameDarkAqua: *const Object;
|
||||
static NSAppearanceNameAccessibilityHighContrastDarkAqua: *const Object;
|
||||
}
|
||||
|
||||
fn is_dark_mode_enabled() -> bool {
|
||||
unsafe {
|
||||
let mut appearance: *const Object = msg_send![class!(NSAppearance), currentAppearance];
|
||||
if appearance.is_null() {
|
||||
appearance = msg_send![class!(NSApp), effectiveAppearance];
|
||||
}
|
||||
|
||||
let objects = [
|
||||
NSAppearanceNameAqua,
|
||||
NSAppearanceNameAccessibilityHighContrastAqua,
|
||||
NSAppearanceNameDarkAqua,
|
||||
NSAppearanceNameAccessibilityHighContrastDarkAqua,
|
||||
];
|
||||
let names: *const Object = msg_send![
|
||||
class!(NSArray),
|
||||
arrayWithObjects:objects.as_ptr()
|
||||
count:objects.len()
|
||||
];
|
||||
|
||||
// `bestMatchFromAppearancesWithNames` is only available in macOS 10.14+.
|
||||
// Gracefully handle earlier versions.
|
||||
let responds_to_selector: objc::runtime::BOOL = msg_send![
|
||||
appearance,
|
||||
respondsToSelector: sel!(bestMatchFromAppearancesWithNames:)
|
||||
];
|
||||
if responds_to_selector == objc::runtime::NO {
|
||||
return false;
|
||||
}
|
||||
|
||||
let style: *const Object = msg_send![
|
||||
appearance,
|
||||
bestMatchFromAppearancesWithNames:&*names
|
||||
];
|
||||
|
||||
style == NSAppearanceNameDarkAqua
|
||||
|| style == NSAppearanceNameAccessibilityHighContrastDarkAqua
|
||||
}
|
||||
}
|
||||
|
||||
pub fn detect() -> crate::Mode {
|
||||
Mode::from_bool(is_dark_mode_enabled())
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod detect;
|
||||
pub mod notify;
|
||||
@@ -1,23 +0,0 @@
|
||||
use std::task::Poll;
|
||||
|
||||
use futures::{stream, Stream};
|
||||
|
||||
use crate::{detect, Mode};
|
||||
|
||||
pub async fn subscribe() -> anyhow::Result<impl Stream<Item = Mode> + Send> {
|
||||
let mut last_mode = detect();
|
||||
|
||||
let stream = stream::poll_fn(move |ctx| -> Poll<Option<Mode>> {
|
||||
let current_mode = detect();
|
||||
|
||||
if current_mode != last_mode {
|
||||
last_mode = current_mode;
|
||||
Poll::Ready(Some(current_mode))
|
||||
} else {
|
||||
ctx.waker().wake_by_ref();
|
||||
Poll::Pending
|
||||
}
|
||||
});
|
||||
|
||||
Ok(stream)
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod macos;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use macos as platform;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub mod windows;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use windows as platform;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
pub mod freedesktop;
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
pub use freedesktop as platform;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub mod websys;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub use websys as platform;
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "windows",
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_arch = "wasm32"
|
||||
)))]
|
||||
pub mod platform {
|
||||
pub fn detect() -> crate::Mode {
|
||||
super::Mode::Light
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
use crate::Mode;
|
||||
|
||||
pub fn detect() -> crate::Mode {
|
||||
if let Some(window) = web_sys::window() {
|
||||
let query_result = window.match_media("(prefers-color-scheme: dark)");
|
||||
if let Ok(Some(mql)) = query_result {
|
||||
return Mode::from_bool(mql.matches());
|
||||
}
|
||||
}
|
||||
Mode::Light
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod detect;
|
||||
pub mod notify;
|
||||
@@ -1,23 +0,0 @@
|
||||
use std::task::Poll;
|
||||
|
||||
use futures::{stream, Stream};
|
||||
|
||||
use crate::{detect, Mode};
|
||||
|
||||
pub async fn subscribe() -> anyhow::Result<impl Stream<Item = Mode> + Send> {
|
||||
let mut last_mode = detect();
|
||||
|
||||
let stream = stream::poll_fn(move |ctx| -> Poll<Option<Mode>> {
|
||||
let current_mode = detect();
|
||||
|
||||
if current_mode != last_mode {
|
||||
last_mode = current_mode;
|
||||
Poll::Ready(Some(current_mode))
|
||||
} else {
|
||||
ctx.waker().wake_by_ref();
|
||||
Poll::Pending
|
||||
}
|
||||
});
|
||||
|
||||
Ok(stream)
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
use crate::Mode;
|
||||
use winreg::RegKey;
|
||||
|
||||
const SUBKEY: &str = "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
||||
const VALUE: &str = "AppsUseLightTheme";
|
||||
|
||||
pub fn detect() -> Mode {
|
||||
let hkcu = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
|
||||
if let Ok(subkey) = hkcu.open_subkey(SUBKEY) {
|
||||
if let Ok(dword) = subkey.get_value::<u32, _>(VALUE) {
|
||||
return Mode::from_bool(dword == 0);
|
||||
}
|
||||
}
|
||||
Mode::Light
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod detect;
|
||||
pub mod notify;
|
||||
@@ -1,23 +0,0 @@
|
||||
use std::task::Poll;
|
||||
|
||||
use futures::{stream, Stream};
|
||||
|
||||
use crate::{detect, Mode};
|
||||
|
||||
pub async fn subscribe() -> anyhow::Result<impl Stream<Item = Mode> + Send> {
|
||||
let mut last_mode = detect();
|
||||
|
||||
let stream = stream::poll_fn(move |ctx| -> Poll<Option<Mode>> {
|
||||
let current_mode = detect();
|
||||
|
||||
if current_mode != last_mode {
|
||||
last_mode = current_mode;
|
||||
Poll::Ready(Some(current_mode))
|
||||
} else {
|
||||
ctx.waker().wake_by_ref();
|
||||
Poll::Pending
|
||||
}
|
||||
});
|
||||
|
||||
Ok(stream)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod rgb;
|
||||
@@ -1,24 +0,0 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
/// Struct representing an RGB color
|
||||
#[allow(dead_code)] // Suppress warnings for unused fields in this struct only
|
||||
pub(crate) struct Rgb(pub(crate) u32, pub(crate) u32, pub(crate) u32);
|
||||
|
||||
impl FromStr for Rgb {
|
||||
type Err = anyhow::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let rgb = s
|
||||
.split(',')
|
||||
.map(|s| s.parse::<u32>().unwrap_or(255))
|
||||
.try_fold(vec![], |mut acc, x| {
|
||||
if acc.len() < 3 {
|
||||
acc.push(x);
|
||||
Ok(acc)
|
||||
} else {
|
||||
Err(anyhow::anyhow!("RGB format is invalid"))
|
||||
}
|
||||
})?;
|
||||
Ok(Rgb(rgb[0], rgb[1], rgb[2]))
|
||||
}
|
||||
}
|
||||
524
desktop/tauri/src-tauri/Cargo.lock
generated
524
desktop/tauri/src-tauri/Cargo.lock
generated
@@ -156,11 +156,11 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||
|
||||
[[package]]
|
||||
name = "ashpd"
|
||||
version = "0.7.0"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01992ad7774250d5b7fe214e2676cb99bf92564436d8135ab44fe815e71769a9"
|
||||
checksum = "de3d60bee1a1d38c2077030f4788e1b4e31058d2e79a8cfc8f2b440bd44db290"
|
||||
dependencies = [
|
||||
"async-fs 2.1.2",
|
||||
"async-fs",
|
||||
"async-net",
|
||||
"enumflags2",
|
||||
"futures-channel",
|
||||
@@ -169,7 +169,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"url",
|
||||
"zbus 3.15.2",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -187,7 +187,7 @@ dependencies = [
|
||||
"serde_repr",
|
||||
"tokio",
|
||||
"url",
|
||||
"zbus 5.5.0",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -196,16 +196,6 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"
|
||||
|
||||
[[package]]
|
||||
name = "async-broadcast"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b"
|
||||
dependencies = [
|
||||
"event-listener 2.5.3",
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-broadcast"
|
||||
version = "0.7.2"
|
||||
@@ -218,6 +208,17 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-channel"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35"
|
||||
dependencies = [
|
||||
"concurrent-queue",
|
||||
"event-listener 2.5.3",
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-channel"
|
||||
version = "2.3.1"
|
||||
@@ -238,52 +239,35 @@ checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec"
|
||||
dependencies = [
|
||||
"async-task",
|
||||
"concurrent-queue",
|
||||
"fastrand 2.3.0",
|
||||
"futures-lite 2.6.0",
|
||||
"fastrand",
|
||||
"futures-lite",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-fs"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06"
|
||||
dependencies = [
|
||||
"async-lock 2.8.0",
|
||||
"autocfg",
|
||||
"blocking",
|
||||
"futures-lite 1.13.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-fs"
|
||||
version = "2.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a"
|
||||
dependencies = [
|
||||
"async-lock 3.4.0",
|
||||
"async-lock",
|
||||
"blocking",
|
||||
"futures-lite 2.6.0",
|
||||
"futures-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-io"
|
||||
version = "1.13.0"
|
||||
name = "async-global-executor"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af"
|
||||
checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c"
|
||||
dependencies = [
|
||||
"async-lock 2.8.0",
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"concurrent-queue",
|
||||
"futures-lite 1.13.0",
|
||||
"log",
|
||||
"parking",
|
||||
"polling 2.8.0",
|
||||
"rustix 0.37.28",
|
||||
"slab",
|
||||
"socket2 0.4.10",
|
||||
"waker-fn",
|
||||
"async-channel 2.3.1",
|
||||
"async-executor",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"blocking",
|
||||
"futures-lite",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -292,28 +276,19 @@ version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059"
|
||||
dependencies = [
|
||||
"async-lock 3.4.0",
|
||||
"async-lock",
|
||||
"cfg-if",
|
||||
"concurrent-queue",
|
||||
"futures-io",
|
||||
"futures-lite 2.6.0",
|
||||
"futures-lite",
|
||||
"parking",
|
||||
"polling 3.7.4",
|
||||
"polling",
|
||||
"rustix 0.38.44",
|
||||
"slab",
|
||||
"tracing",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-lock"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b"
|
||||
dependencies = [
|
||||
"event-listener 2.5.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-lock"
|
||||
version = "3.4.0"
|
||||
@@ -331,26 +306,9 @@ version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7"
|
||||
dependencies = [
|
||||
"async-io 2.4.0",
|
||||
"async-io",
|
||||
"blocking",
|
||||
"futures-lite 2.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-process"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88"
|
||||
dependencies = [
|
||||
"async-io 1.13.0",
|
||||
"async-lock 2.8.0",
|
||||
"async-signal",
|
||||
"blocking",
|
||||
"cfg-if",
|
||||
"event-listener 3.1.0",
|
||||
"futures-lite 1.13.0",
|
||||
"rustix 0.38.44",
|
||||
"windows-sys 0.48.0",
|
||||
"futures-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -359,15 +317,15 @@ version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-io 2.4.0",
|
||||
"async-lock 3.4.0",
|
||||
"async-channel 2.3.1",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"async-signal",
|
||||
"async-task",
|
||||
"blocking",
|
||||
"cfg-if",
|
||||
"event-listener 5.4.0",
|
||||
"futures-lite 2.6.0",
|
||||
"futures-lite",
|
||||
"rustix 0.38.44",
|
||||
"tracing",
|
||||
]
|
||||
@@ -389,8 +347,8 @@ version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3"
|
||||
dependencies = [
|
||||
"async-io 2.4.0",
|
||||
"async-lock 3.4.0",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"atomic-waker",
|
||||
"cfg-if",
|
||||
"futures-core",
|
||||
@@ -401,6 +359,32 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-std"
|
||||
version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c8e079a4ab67ae52b7403632e4618815d6db36d2a010cfe41b02c1b1578f93b"
|
||||
dependencies = [
|
||||
"async-channel 1.9.0",
|
||||
"async-global-executor",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"crossbeam-utils",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-lite",
|
||||
"gloo-timers",
|
||||
"kv-log-macro",
|
||||
"log",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
"wasm-bindgen-futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-task"
|
||||
version = "4.7.1"
|
||||
@@ -574,10 +558,10 @@ version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-channel 2.3.1",
|
||||
"async-task",
|
||||
"futures-io",
|
||||
"futures-lite 2.6.0",
|
||||
"futures-lite",
|
||||
"piper",
|
||||
]
|
||||
|
||||
@@ -1136,19 +1120,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dark-light"
|
||||
version = "1.1.1"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18e1a09f280e29a8b00bc7e81eca5ac87dca0575639c9422a5fa25a07bb884b8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ashpd 0.7.0",
|
||||
"dconf_rs",
|
||||
"detect-desktop-environment",
|
||||
"futures",
|
||||
"objc",
|
||||
"rust-ini",
|
||||
"ashpd 0.10.3",
|
||||
"async-std",
|
||||
"objc2 0.5.2",
|
||||
"objc2-foundation 0.2.2",
|
||||
"web-sys",
|
||||
"winreg",
|
||||
"xdg",
|
||||
"zbus 3.15.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1241,12 +1222,6 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dconf_rs"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7046468a81e6a002061c01e6a7c83139daf91b11c30e66795b13217c2d885c8b"
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.4.1"
|
||||
@@ -1257,17 +1232,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derivative"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive-new"
|
||||
version = "0.6.0"
|
||||
@@ -1292,12 +1256,6 @@ dependencies = [
|
||||
"syn 2.0.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "detect-desktop-environment"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff7f16599c3ba6b4ab9a3195bcd9413a7ee8d51e7651f3e9efd6a5db5315008d"
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
@@ -1583,17 +1541,6 @@ version = "2.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "3.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2"
|
||||
dependencies = [
|
||||
"concurrent-queue",
|
||||
"parking",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "5.4.0"
|
||||
@@ -1615,15 +1562,6 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
|
||||
dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.3.0"
|
||||
@@ -1654,7 +1592,7 @@ version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
|
||||
dependencies = [
|
||||
"memoffset 0.9.1",
|
||||
"memoffset",
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
@@ -1747,21 +1685,6 @@ dependencies = [
|
||||
"new_debug_unreachable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.31"
|
||||
@@ -1769,7 +1692,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1795,28 +1717,13 @@ version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
|
||||
|
||||
[[package]]
|
||||
name = "futures-lite"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce"
|
||||
dependencies = [
|
||||
"fastrand 1.9.0",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"memchr",
|
||||
"parking",
|
||||
"pin-project-lite",
|
||||
"waker-fn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-lite"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532"
|
||||
dependencies = [
|
||||
"fastrand 2.3.0",
|
||||
"fastrand",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"parking",
|
||||
@@ -1852,7 +1759,6 @@ version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
@@ -2127,6 +2033,18 @@ version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
|
||||
|
||||
[[package]]
|
||||
name = "gloo-timers"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.18.0"
|
||||
@@ -2255,12 +2173,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.4.0"
|
||||
@@ -2403,7 +2315,7 @@ dependencies = [
|
||||
"hyper",
|
||||
"libc",
|
||||
"pin-project-lite",
|
||||
"socket2 0.5.9",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
@@ -2641,17 +2553,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.9",
|
||||
"libc",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.11.0"
|
||||
@@ -2807,6 +2708,15 @@ dependencies = [
|
||||
"selectors",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kv-log-macro"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f"
|
||||
dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
@@ -2863,12 +2773,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.15"
|
||||
@@ -2966,15 +2870,6 @@ version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.9.1"
|
||||
@@ -3091,18 +2986,6 @@ version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.26.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"memoffset 0.7.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.28.0"
|
||||
@@ -3125,7 +3008,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"cfg_aliases 0.2.1",
|
||||
"libc",
|
||||
"memoffset 0.9.1",
|
||||
"memoffset",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3150,12 +3033,12 @@ version = "4.11.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4012c5a725bfa4cfd09c2f3abf29fb0b03a528d02787744e485c8014cdf6f1c0"
|
||||
dependencies = [
|
||||
"futures-lite 2.6.0",
|
||||
"futures-lite",
|
||||
"log",
|
||||
"mac-notification-sys",
|
||||
"serde",
|
||||
"tauri-winrt-notification 0.2.1",
|
||||
"zbus 5.5.0",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3188,7 +3071,7 @@ version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
|
||||
dependencies = [
|
||||
"proc-macro-crate 3.3.0",
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.100",
|
||||
@@ -3876,7 +3759,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066"
|
||||
dependencies = [
|
||||
"atomic-waker",
|
||||
"fastrand 2.3.0",
|
||||
"fastrand",
|
||||
"futures-io",
|
||||
]
|
||||
|
||||
@@ -3912,22 +3795,6 @@ dependencies = [
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"bitflags 1.3.2",
|
||||
"cfg-if",
|
||||
"concurrent-queue",
|
||||
"libc",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "3.7.4"
|
||||
@@ -4539,20 +4406,6 @@ dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.37.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "519165d378b97752ca44bbe15047d5d3409e875f39327546b42ac81d7e18c1b6"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"errno",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
"linux-raw-sys 0.3.8",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.44"
|
||||
@@ -5006,16 +4859,6 @@ version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.9"
|
||||
@@ -5572,7 +5415,7 @@ dependencies = [
|
||||
"thiserror 2.0.12",
|
||||
"tracing",
|
||||
"windows-sys 0.59.0",
|
||||
"zbus 5.5.0",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5733,7 +5576,7 @@ version = "3.19.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf"
|
||||
dependencies = [
|
||||
"fastrand 2.3.0",
|
||||
"fastrand",
|
||||
"getrandom 0.3.2",
|
||||
"once_cell",
|
||||
"rustix 1.0.4",
|
||||
@@ -5896,7 +5739,7 @@ dependencies = [
|
||||
"mio",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2 0.5.9",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"tracing",
|
||||
"windows-sys 0.52.0",
|
||||
@@ -6191,7 +6034,7 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9"
|
||||
dependencies = [
|
||||
"memoffset 0.9.1",
|
||||
"memoffset",
|
||||
"tempfile",
|
||||
"winapi",
|
||||
]
|
||||
@@ -6369,12 +6212,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "waker-fn"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
@@ -7420,12 +7257,6 @@ version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d"
|
||||
|
||||
[[package]]
|
||||
name = "xdg"
|
||||
version = "2.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546"
|
||||
|
||||
[[package]]
|
||||
name = "xdg-home"
|
||||
version = "1.3.0"
|
||||
@@ -7460,59 +7291,18 @@ dependencies = [
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zbus"
|
||||
version = "3.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "675d170b632a6ad49804c8cf2105d7c31eddd3312555cffd4b740e08e97c25e6"
|
||||
dependencies = [
|
||||
"async-broadcast 0.5.1",
|
||||
"async-executor",
|
||||
"async-fs 1.6.0",
|
||||
"async-io 1.13.0",
|
||||
"async-lock 2.8.0",
|
||||
"async-process 1.8.1",
|
||||
"async-recursion",
|
||||
"async-task",
|
||||
"async-trait",
|
||||
"blocking",
|
||||
"byteorder",
|
||||
"derivative",
|
||||
"enumflags2",
|
||||
"event-listener 2.5.3",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"nix 0.26.4",
|
||||
"once_cell",
|
||||
"ordered-stream",
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"sha1",
|
||||
"static_assertions",
|
||||
"tracing",
|
||||
"uds_windows",
|
||||
"winapi",
|
||||
"xdg-home",
|
||||
"zbus_macros 3.15.2",
|
||||
"zbus_names 2.6.1",
|
||||
"zvariant 3.15.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zbus"
|
||||
version = "5.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59c333f648ea1b647bc95dc1d34807c8e25ed7a6feff3394034dc4776054b236"
|
||||
dependencies = [
|
||||
"async-broadcast 0.7.2",
|
||||
"async-broadcast",
|
||||
"async-executor",
|
||||
"async-fs 2.1.2",
|
||||
"async-io 2.4.0",
|
||||
"async-lock 3.4.0",
|
||||
"async-process 2.3.0",
|
||||
"async-fs",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"async-process",
|
||||
"async-recursion",
|
||||
"async-task",
|
||||
"async-trait",
|
||||
@@ -7520,7 +7310,7 @@ dependencies = [
|
||||
"enumflags2",
|
||||
"event-listener 5.4.0",
|
||||
"futures-core",
|
||||
"futures-lite 2.6.0",
|
||||
"futures-lite",
|
||||
"hex",
|
||||
"nix 0.29.0",
|
||||
"ordered-stream",
|
||||
@@ -7533,23 +7323,9 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"winnow 0.7.4",
|
||||
"xdg-home",
|
||||
"zbus_macros 5.5.0",
|
||||
"zbus_names 4.2.0",
|
||||
"zvariant 5.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zbus_macros"
|
||||
version = "3.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7131497b0f887e8061b430c530240063d33bf9455fa34438f388a245da69e0a5"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"syn 1.0.109",
|
||||
"zvariant_utils 1.0.1",
|
||||
"zbus_macros",
|
||||
"zbus_names",
|
||||
"zvariant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7562,20 +7338,9 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.100",
|
||||
"zbus_names 4.2.0",
|
||||
"zvariant 5.4.0",
|
||||
"zvariant_utils 3.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zbus_names"
|
||||
version = "2.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "437d738d3750bed6ca9b8d423ccc7a8eb284f6b1d6d4e225a0e4e6258d864c8d"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"static_assertions",
|
||||
"zvariant 3.15.2",
|
||||
"zbus_names",
|
||||
"zvariant",
|
||||
"zvariant_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7587,7 +7352,7 @@ dependencies = [
|
||||
"serde",
|
||||
"static_assertions",
|
||||
"winnow 0.7.4",
|
||||
"zvariant 5.4.0",
|
||||
"zvariant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7679,21 +7444,6 @@ dependencies = [
|
||||
"syn 2.0.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "3.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eef2be88ba09b358d3b58aca6e41cd853631d44787f319a1383ca83424fb2db"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"enumflags2",
|
||||
"libc",
|
||||
"serde",
|
||||
"static_assertions",
|
||||
"url",
|
||||
"zvariant_derive 3.15.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "5.4.0"
|
||||
@@ -7706,21 +7456,8 @@ dependencies = [
|
||||
"static_assertions",
|
||||
"url",
|
||||
"winnow 0.7.4",
|
||||
"zvariant_derive 5.4.0",
|
||||
"zvariant_utils 3.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant_derive"
|
||||
version = "3.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37c24dc0bed72f5f90d1f8bb5b07228cbf63b3c6e9f82d82559d4bae666e7ed9"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"zvariant_utils 1.0.1",
|
||||
"zvariant_derive",
|
||||
"zvariant_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7733,18 +7470,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.100",
|
||||
"zvariant_utils 3.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant_utils"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"zvariant_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -53,7 +53,7 @@ reqwest = { version = "0.12", features = ["cookies", "json"] }
|
||||
rfd = { version = "*", default-features = false, features = [ "tokio", "gtk3", "common-controls-v6" ] }
|
||||
open = "5.1.3"
|
||||
|
||||
dark-light = { path = "../rust-dark-light" }
|
||||
dark-light = "2.0.0"
|
||||
|
||||
# Linux only
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
|
||||
@@ -43,7 +43,7 @@ enum IconColor {
|
||||
}
|
||||
|
||||
static CURRENT_ICON_COLOR: RwLock<IconColor> = RwLock::new(IconColor::Red);
|
||||
pub static USER_THEME: RwLock<dark_light::Mode> = RwLock::new(dark_light::Mode::Default);
|
||||
pub static USER_THEME: RwLock<dark_light::Mode> = RwLock::new(dark_light::Mode::Unspecified);
|
||||
const OPEN_KEY: &str = "open";
|
||||
const EXIT_UI_KEY: &str = "exit_ui";
|
||||
const SPN_STATUS_KEY: &str = "spn_status";
|
||||
@@ -65,7 +65,7 @@ fn get_theme_mode() -> dark_light::Mode {
|
||||
if let Ok(value) = USER_THEME.read() {
|
||||
return *value.deref();
|
||||
}
|
||||
dark_light::detect()
|
||||
dark_light::detect().unwrap_or(dark_light::Mode::Unspecified)
|
||||
}
|
||||
|
||||
fn get_green_icon() -> &'static [u8] {
|
||||
@@ -247,7 +247,7 @@ pub fn setup_tray_menu(
|
||||
SHUTDOWN_KEY => {
|
||||
app.portmaster().trigger_shutdown();
|
||||
}
|
||||
SYSTEM_THEME_KEY => update_icon_theme(app, dark_light::Mode::Default),
|
||||
SYSTEM_THEME_KEY => update_icon_theme(app, dark_light::Mode::Unspecified),
|
||||
DARK_THEME_KEY => update_icon_theme(app, dark_light::Mode::Dark),
|
||||
LIGHT_THEME_KEY => update_icon_theme(app, dark_light::Mode::Light),
|
||||
other => {
|
||||
@@ -538,7 +538,7 @@ fn load_theme(app: &tauri::AppHandle) {
|
||||
let theme = match config.theme {
|
||||
config::Theme::Light => dark_light::Mode::Light,
|
||||
config::Theme::Dark => dark_light::Mode::Dark,
|
||||
config::Theme::System => dark_light::Mode::Default,
|
||||
config::Theme::System => dark_light::Mode::Unspecified,
|
||||
};
|
||||
|
||||
if let Ok(mut value) = USER_THEME.write() {
|
||||
@@ -555,7 +555,7 @@ fn save_theme(app: &tauri::AppHandle, mode: dark_light::Mode) {
|
||||
let theme = match mode {
|
||||
dark_light::Mode::Dark => config::Theme::Dark,
|
||||
dark_light::Mode::Light => config::Theme::Light,
|
||||
dark_light::Mode::Default => config::Theme::System,
|
||||
dark_light::Mode::Unspecified => config::Theme::System,
|
||||
};
|
||||
config.theme = theme;
|
||||
if let Err(err) = config::save(app, config) {
|
||||
|
||||
@@ -143,11 +143,11 @@ pub fn set_window_icon(window: &WebviewWindow) {
|
||||
let mut mode = if let Ok(value) = traymenu::USER_THEME.read() {
|
||||
*value
|
||||
} else {
|
||||
dark_light::Mode::Default
|
||||
dark_light::Mode::Unspecified
|
||||
};
|
||||
|
||||
if mode == dark_light::Mode::Default {
|
||||
mode = dark_light::detect();
|
||||
if mode == dark_light::Mode::Unspecified {
|
||||
mode = dark_light::detect().unwrap_or(dark_light::Mode::Dark);
|
||||
}
|
||||
|
||||
let _ = match mode {
|
||||
|
||||
Reference in New Issue
Block a user