Skip to content

Commit

Permalink
v2.0.0 (#53)
Browse files Browse the repository at this point in the history
* Prepared for v2.0.0
* Remove unused variants from Error struct
* Update justfile to remove subscription examples
  • Loading branch information
Eduardo Flores authored and edfloreshz committed Jan 9, 2025
1 parent b10982b commit 2569541
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ On Linux the XDG Desktop Portal D-Bus API is checked for the `color-scheme` pref

## Usage

Add this to your `Cargo.toml`:

```toml
[dependencies]
dark-light = "2.0.0"
```


### Detect current theme mode
You can detect the current mode by using the `detect` function. This function returns a `Mode` value.
```rust
Expand Down
4 changes: 0 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ doc-wasm:
example-linux:
echo "Building examples for Linux..."
cargo build --example detect --target x86_64-unknown-linux-gnu
cargo build --example subscribe --target x86_64-unknown-linux-gnu
example-macos:
echo "Building examples for macOS..."
cargo build --example detect --target aarch64-apple-darwin
cargo build --example subscribe --target aarch64-apple-darwin
example-windows:
echo "Building examples for Windows..."
cargo build --example detect --target x86_64-pc-windows-gnu
cargo build --example subscribe --target x86_64-pc-windows-gnu
example-wasm:
echo "Building examples for wasm..."
cargo build --example detect --target wasm32-unknown-unknown
cargo build --example subscribe --target wasm32-unknown-unknown
8 changes: 1 addition & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ use std::fmt::Display;
pub enum Error {
/// If an I/O error occurs.
Io(std::io::Error),
/// If the system theme mode could not be detected.
DetectionFailed,
/// If the XDG Desktop Portal could not be communicated with.
XdgDesktopPortal(String),
/// If the timeout is reached.
Timeout,
/// Failed to get persistent domain for Apple Global Domain
/// Failed to get persistent domain for Apple Global Domain.
PersistentDomainFailed,
/// Failed to get AppleInterfaceStyle
AppleInterfaceStyleFailed,
/// If the window could not be found.
WindowNotFound,
/// If the media query could not be executed.
Expand All @@ -27,13 +23,11 @@ impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::Io(error) => write!(f, "I/O error: {}", error),
Error::DetectionFailed => write!(f, "Failed to detect system theme mode"),
Error::XdgDesktopPortal(err) => write!(f, "XDG Desktop Portal error: {}", err),
Error::Timeout => write!(f, "Timeout reached"),
Error::PersistentDomainFailed => {
write!(f, "Failed to get persistent domain for Apple Global Domain")
}
Error::AppleInterfaceStyleFailed => write!(f, "Failed to get AppleInterfaceStyle"),
Error::WindowNotFound => write!(f, "Window not found"),
Error::MediaQueryFailed => write!(f, "Media query failed"),
Error::MediaQueryNotSupported => write!(f, "Media query not supported"),
Expand Down

0 comments on commit 2569541

Please sign in to comment.