azalea/lib.rs
1//! # azalea
2//!
3//! This crate works as the main application and as a library that re-exports the inner crates
4//!
5//! Using this as a library:
6//!```bash
7//!cargo add --git https://github.com/enzohideo/azalea-desktop-shell.git azalea
8//!```
9//!
10//!You need to crate two wrappers: `ConfigWrapper` and `WindowWrapper`.
11//!
12//!The `ConfigWrapper` wraps each window's configuration
13//!```rust
14//!#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
15//!pub enum ConfigWrapper {
16//! Default,
17//! Taskbar(taskbar::Config),
18//!}
19//!```
20//!
21//!The `WindowWrapper` wraps data structures that contains a gtk::Window
22//!```rust
23//!pub enum WindowWrapper {
24//! Default(gtk::Window),
25//! Taskbar(relm4::component::Controller<taskbar::Model>),
26//!}
27//!```
28//!
29//!Now, you just need to implement [core::app::AzaleaAppExt]
30//!```
31//!pub struct AzaleaAppExt {}
32//!
33//!impl app::AzaleaAppExt for AzaleaAppExt {
34//!
35//! type ConfigWrapper = ConfigWrapper;
36//! type WindowWrapper = WindowWrapper;
37//!
38//! fn create_window(init: &ConfigWrapper) -> WindowWrapper {
39//! match &init {
40//! ConfigWrapper::Default => {
41//! let btn = gtk::Button::with_label("Hey");
42//! let window = gtk::Window::builder().child(&btn).build();
43//! WindowWrapper::Default(window)
44//! }
45//! ConfigWrapper::Taskbar(config) => {
46//! let builder = taskbar::Model::builder();
47//! let controller = builder
48//! .launch(shell::window::Init::<taskbar::Model> {
49//! config: config.clone(),
50//! })
51//! .detach();
52//! WindowWrapper::Taskbar(controller)
53//! }
54//! }
55//! }
56//!
57//! fn unwrap_window(window: &WindowWrapper) -> >k::Window {
58//! match window {
59//! WindowWrapper::Default(window) => window,
60//! WindowWrapper::Taskbar(controller) => controller.widget(),
61//! }
62//! }
63//!}
64//!```
65//!
66//!Now, the main application
67//!```rust
68//!fn main() {
69//! // Initialize the icons
70//! icon::init();
71//!
72//! // Default windows' configurations
73//! let windows = HashMap::from([
74//! (
75//! format!("hey"),
76//! config::window::Config {
77//! config: ConfigWrapper::Default,
78//!
79//! layer_shell: Some({
80//! use config::layer_shell::{Anchor, Config, ExclusiveZone, Layer};
81//!
82//! Config {
83//! namespace: format!("something"),
84//! layer: Layer::Background,
85//! anchors: vec![Anchor::Left, Anchor::Right, Anchor::Bottom, Anchor::Top],
86//! exclusive_zone: ExclusiveZone::Ignore,
87//! }
88//! }),
89//!
90//! lazy: false,
91//!
92//! monitor: Monitor::All,
93//! },
94//! ),
95//! (
96//! format!("bottom-taskbar"),
97//! config::window::Config {
98//! config: ConfigWrapper::Taskbar({
99//! use taskbar::{
100//! Config,
101//! widget::{ConfigWrapper::*, *},
102//! };
103//!
104//! Config {
105//! spacing: 8,
106//!
107//! start: vec![
108//! StartMenu(startmenu::Config {}),
109//! Separator(separator::Config { separator: None }),
110//! Audio(audio::Config {}),
111//! Separator(separator::Config { separator: None }),
112//! Brightness(brightness::Config {}),
113//! Separator(separator::Config { separator: None }),
114//! ],
115//!
116//! center: vec![Media(media::Config {})],
117//!
118//! end: vec![
119//! Separator(separator::Config { separator: None }),
120//! Bluetooth(bluetooth::Config {}),
121//! Separator(separator::Config { separator: None }),
122//! Network(network::Config {}),
123//! Separator(separator::Config { separator: None }),
124//! Time(time::Config {
125//! format: format!("%d/%m/%y"),
126//! }),
127//! Separator(separator::Config { separator: None }),
128//! Time(time::Config {
129//! format: format!("%H:%M"),
130//! }),
131//! Separator(separator::Config { separator: None }),
132//! ],
133//! }
134//! }),
135//!
136//! layer_shell: Some({
137//! use config::layer_shell::{Anchor, Config, ExclusiveZone, Layer};
138//!
139//! Config {
140//! namespace: format!("taskbar"),
141//! layer: Layer::Top,
142//! anchors: vec![Anchor::Left, Anchor::Right, Anchor::Bottom],
143//! exclusive_zone: ExclusiveZone::Auto,
144//! }
145//! }),
146//!
147//! lazy: false,
148//!
149//! monitor: Monitor::All,
150//! },
151//! ),
152//! ]);
153//!
154//! app::AzaleaApp::<AzaleaAppExt>::new(Config { windows }).run();
155//!}
156//!```
157//!
158//!If you want to use a configuration file, use `azalea config view` to see the default
159//!configuration in RON format, then copy it to `~/.config/azalea/config.ron`
160//!
161//!You can also change where it looks for config files by overriding it in [core::app::AzaleaAppExt]
162//!```rust
163//!impl app::AzaleaAppExt for AzaleaAppExt {
164//! const CONFIG_PATH: &str = "azalea/config.ron";
165//!
166//! // You can also use JSON, instead of RON
167//! // const CONFIG_PATH: &str = "azalea/config.json";
168//!
169//! // Other things you can also override:
170//! const STYLE_PATH: &str = "azalea/style.scss";
171//! const SOCKET_NAME: &str = "azalea.sock";
172//! const APP_ID: &str = "br.usp.ime.Azalea";
173//!}
174//!```
175
176#[doc(inline)]
177pub use azalea_core as core;
178
179#[doc(inline)]
180pub use azalea_log as log;
181
182#[doc(inline)]
183pub use azalea_derive as derive;
184
185#[doc(inline)]
186pub use azalea_shell as shell;
187
188#[doc(inline)]
189pub use azalea_service as service;