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| crate::Action::System(Action::GetInformation(channel)))
53}
54
55pub fn theme() -> Task<theme::Mode> {
57 task::oneshot(|sender| crate::Action::System(Action::GetTheme(sender)))
58}
59
60pub fn theme_changes() -> Subscription<theme::Mode> {
62 #[derive(Hash)]
63 struct ThemeChanges;
64
65 subscription::filter_map(ThemeChanges, |event| {
66 let subscription::Event::SystemThemeChanged(mode) = event else {
67 return None;
68 };
69
70 Some(mode)
71 })
72}