1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
use alloc::string::String;
use core::fmt::{self, Display, Formatter};
/// The desktop environment of a system
#[derive(Debug, PartialEq, Eq, Clone)]
#[non_exhaustive]
pub enum DesktopEnvironment {
/// Unknown desktop environment
Unknown(String),
/// Running as Web Assembly on a web page
WebBrowser(String),
/// Popular GTK-based desktop environment on Linux
Gnome,
/// One of the desktop environments for a specific version of Windows
Windows,
/// Linux desktop environment optimized for low resource requirements
Lxde,
/// Stacking window manager for X Windows on Linux
Openbox,
/// Desktop environment for Linux, BSD and illumos
Mate,
/// Lightweight desktop enivornment for unix-like operating systems
Xfce,
/// KDE Plasma desktop enviroment
Plasma,
/// Default desktop environment on Linux Mint
Cinnamon,
/// Tiling window manager for Linux
I3,
/// Desktop environment for MacOS
Aqua,
/// Desktop environment for iOS
Ios,
/// Desktop environment for Android
Android,
/// A desktop environment for a video game console
Console,
/// Ubuntu-branded GNOME
Ubuntu,
/// Default shell for Fuchsia
Ermine,
/// Default desktop environment for Redox
Orbital,
/// Wayland scrolling window manager for Linux
Niri,
/// Wayland tiling window manager for Linux
Hyprland,
/// Rust based desktop environment on Linux
Cosmic,
}
impl Display for DesktopEnvironment {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
if let Self::Unknown(_) = self {
f.write_str("Unknown: ")?;
}
f.write_str(match self {
Self::Unknown(de) => de,
Self::WebBrowser(de) => return write!(f, "WebBrowser ({de})"),
Self::Gnome => "Gnome",
Self::Windows => "Windows",
Self::Lxde => "LXDE",
Self::Openbox => "Openbox",
Self::Mate => "Mate",
Self::Xfce => "XFCE",
Self::Plasma => "KDE Plasma",
Self::Cinnamon => "Cinnamon",
Self::I3 => "I3",
Self::Aqua => "Aqua",
Self::Ios => "IOS",
Self::Android => "Android",
Self::Console => "Console",
Self::Ubuntu => "Ubuntu",
Self::Ermine => "Ermine",
Self::Orbital => "Orbital",
Self::Niri => "Niri",
Self::Hyprland => "Hyprland",
Self::Cosmic => "Cosmic",
})
}
}
impl DesktopEnvironment {
/// Returns true if the desktop environment is based on GTK.
#[must_use]
pub const fn is_gtk(&self) -> bool {
matches!(
self,
Self::Gnome
| Self::Ubuntu
| Self::Cinnamon
| Self::Lxde
| Self::Mate
| Self::Xfce
| Self::Niri
)
}
/// Returns true if the desktop environment is based on KDE.
#[must_use]
pub const fn is_kde(&self) -> bool {
matches!(self, Self::Plasma)
}
}