Skip to content

Commit

Permalink
refactor: restructurize the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
JarKz authored Jul 24, 2024
1 parent 598353e commit e4b7a89
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 15 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
clap = "4.5.7"
clap = { version = "4.5.7", features = ["derive"] }
derive_builder = "0.20.0"
derive_more = "0.99.18"
fontdue = "0.9.2"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cargo install --git https://github.com/noti-rs/noti/
After installation, you can start Noti with:

```bash
noti
noti run
```

To enable Noti to start automatically with your Wayland session, add it to your session startup script.
Expand Down
5 changes: 4 additions & 1 deletion src/core.rs → src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ use std::thread;

use tokio::sync::mpsc::unbounded_channel;

mod render;

use crate::{
data::{aliases::Result, dbus::Action},
dbus::server::Server,
render::Renderer,
};

use render::Renderer;

pub async fn run() -> Result<()> {
let (sender, mut receiver) = unbounded_channel();
let server = Server::init(sender).await?;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions src/render/layer.rs → src/backend/render/layer.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::{fs::File, io::Write, os::fd::AsFd, sync::Arc, time};

use crate::{
config::{self, sorting::Sorting, CONFIG},
config::{self, CONFIG},
data::{
aliases::Result,
internal_messages::RendererMessage,
notification::{self, Notification},
},
render::border::BorderBuilder,
};
use wayland_client::{
delegate_noop,
Expand All @@ -23,7 +22,9 @@ use wayland_protocols_wlr::layer_shell::v1::client::{
zwlr_layer_surface_v1::{self, Anchor},
};

use super::{color::Bgra, font::FontCollection, image::Image, text::TextRect};
use super::{
border::BorderBuilder, color::Bgra, font::FontCollection, image::Image, text::TextRect,
};

pub(crate) struct NotificationStack {
connection: Connection,
Expand Down
3 changes: 1 addition & 2 deletions src/render/text.rs → src/backend/render/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use fontdue::Metrics;
use crate::{
config::{spacing::Spacing, TextAlignment},
data::text::Text,
render::font::FontStyle,
};

use super::{color::Bgra, font::FontCollection, image::Image};
use super::{color::Bgra, font::FontCollection, font::FontStyle, image::Image};

#[derive(Default)]
pub(crate) struct TextRect {
Expand Down
26 changes: 26 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use clap::Parser;

use crate::{backend, config::CONFIG, data::aliases::Result};

/// The notification system which derives a notification to user
/// using wayland client.
#[derive(Parser)]
#[command(version, about, name = env!("CARGO_PKG_NAME"))]
pub enum Args {
/// Starts the backend. Use it in systemd, openrc or any other services.
Run,
}

impl Args {
pub async fn process(&self) -> Result<()> {
match self {
Args::Run => {
let _ = &*CONFIG; // Initializes the configuration.

backend::run().await?;
}
}

Ok(())
}
}
File renamed without changes.
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
mod backend;
mod cli;
mod config;
mod core;
mod data;
mod dbus;
mod render;

use config::CONFIG;
use clap::Parser;

use cli::Args;
use data::aliases::Result;

#[tokio::main]
async fn main() -> Result<()> {
dbg!(&*CONFIG); // &* used for initializing

core::run().await?;
Ok(())
let args = Args::parse();
args.process().await
}

0 comments on commit e4b7a89

Please sign in to comment.