[PR #150] Detect light/dark OS theme #443

Open
opened 2026-02-28 14:33:01 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jpochyla/psst/pull/150
Author: @KeKsBoTer
Created: 8/26/2021
Status: 🔄 Open

Base: mainHead: master


📝 Commits (2)

  • b4df3ad read system theme as default theme value on macos
  • 295370f remove unused import

📊 Changes

3 files changed (+38 additions, -1 deletions)

View changed files

📝 Cargo.lock (+2 -0)
📝 psst-gui/Cargo.toml (+5 -0)
📝 psst-gui/src/data/config.rs (+31 -1)

📄 Description

Hey,

I implemented basic light/dark theme detection for macOS.
I am new to the project and would appreciate your input.

Location in Code

At this point in time I am just reading the OS theme as the default value for the Theme Enum.
This seems a bit sketchy to me but I am not sure where else to put it.

Reactive Implementation

My approach only reads the OS theme once (at the application start) and does not react to theme changes during runtime.
This project could serve as a basic implementation for a reactive implementation.
Since a reactive implementation is much more complicated I would strive for a basic approach at this point in time.

Error Handling

I was unable to find a suitable error handling approach for my implementation.
Neither panic::catch_unwind nor reading the OS value in a separate thread prevents the program from crashing when reading the OS theme fails ("rust cannot catch foreign exceptions").
This is not optimal since an theme reading error should not result in the program crashing.
Do you have any idea how to fix this problem?


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jpochyla/psst/pull/150 **Author:** [@KeKsBoTer](https://github.com/KeKsBoTer) **Created:** 8/26/2021 **Status:** 🔄 Open **Base:** `main` ← **Head:** `master` --- ### 📝 Commits (2) - [`b4df3ad`](https://github.com/jpochyla/psst/commit/b4df3ada8cf65845cd09738650f9968af2b52fe8) read system theme as default theme value on macos - [`295370f`](https://github.com/jpochyla/psst/commit/295370fc451b3a8cf453a6b5e37f920bfc58d873) remove unused import ### 📊 Changes **3 files changed** (+38 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+2 -0) 📝 `psst-gui/Cargo.toml` (+5 -0) 📝 `psst-gui/src/data/config.rs` (+31 -1) </details> ### 📄 Description Hey, I implemented basic light/dark theme detection for macOS. I am new to the project and would appreciate your input. ## Location in Code At this point in time I am just reading the OS theme as the default value for the Theme Enum. This seems a bit sketchy to me but I am not sure where else to put it. ## Reactive Implementation My approach only reads the OS theme once (at the application start) and does not react to theme changes during runtime. This [project](https://github.com/cormacrelf/dark-notify) could serve as a basic implementation for a reactive implementation. Since a reactive implementation is much more complicated I would strive for a basic approach at this point in time. ## Error Handling I was unable to find a suitable error handling approach for my implementation. Neither `panic::catch_unwind` nor reading the OS value in a separate thread prevents the program from crashing when reading the OS theme fails ("rust cannot catch foreign exceptions"). This is not optimal since an theme reading error should not result in the program crashing. Do you have any idea how to fix this problem? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/psst#443
No description provided.