1use crate::core::theme;
3use crate::futures::futures::channel::oneshot;
4use crate::futures::subscription::{self, Subscription};
5use crate::task::{self, Task};
6
7#[derive(Debug)]
9pub enum Action {
10 GetInformation(oneshot::Sender<Information>),
12
13 GetTheme(oneshot::Sender<theme::Mode>),
15
16 NotifyTheme(theme::Mode),
18}
19
20#[derive(Clone, Debug)]
22pub struct Information {
23 pub system_name: Option<String>,
25 pub system_kernel: Option<String>,
27 pub system_version: Option<String>,
34 pub system_short_version: Option<String>,
36 pub cpu_brand: String,
38 pub cpu_cores: Option<usize>,
40 pub memory_total: u64,
42 pub memory_used: Option<u64>,
44 pub graphics_backend: String,
46 pub graphics_adapter: String,
48}
49
50pub fn information() -> Task<Information> {
52 task::oneshot(|channel| {
53 crate::Action::System(Action::GetInformation(channel))
54 })
55}
56
57pub fn theme() -> Task<theme::Mode> {
59 task::oneshot(|sender| crate::Action::System(Action::GetTheme(sender)))
60}
61
62pub fn theme_changes() -> Subscription<theme::Mode> {
64 #[derive(Hash)]
65 struct ThemeChanges;
66
67 subscription::filter_map(ThemeChanges, |event| {
68 let subscription::Event::SystemThemeChanged(mode) = event else {
69 return None;
70 };
71
72 Some(mode)
73 })
74}