From 89b3f6f2d3f54456500faa044f862b2cef618d60 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Sun, 1 Jun 2025 01:39:48 +0200 Subject: [PATCH] restructure lib this makes imports better, as they can now be written as use worf:: instead worf_lib:: --- IO | 0 examples/worf-hyprswitch/src/main.rs | 4 ++-- examples/worf-warden/src/main.rs | 2 +- worf/Cargo.toml | 4 ++-- worf/src/main.rs | 2 +- worf/src/{lib => }/mod.rs | 7 ++++++- 6 files changed, 12 insertions(+), 7 deletions(-) delete mode 100644 IO rename worf/src/{lib => }/mod.rs (95%) diff --git a/IO b/IO deleted file mode 100644 index e69de29..0000000 diff --git a/examples/worf-hyprswitch/src/main.rs b/examples/worf-hyprswitch/src/main.rs index 876d559..6325723 100644 --- a/examples/worf-hyprswitch/src/main.rs +++ b/examples/worf-hyprswitch/src/main.rs @@ -7,7 +7,7 @@ use hyprland::{ }; use rayon::prelude::*; use sysinfo::{Pid, System}; -use worf_lib::{ +use worf::{ config::{self, Config}, desktop::EntryType, gui::{self, ItemProvider, MenuItem}, @@ -23,7 +23,7 @@ impl WindowProvider { let clients = hyprland::data::Clients::get().map_err(|e| e.to_string())?; let clients: Vec<_> = clients.iter().cloned().collect(); - let desktop_files = Arc::new(worf_lib::desktop::find_desktop_files()); + let desktop_files = Arc::new(worf::desktop::find_desktop_files()); let mut sys = System::new_all(); sys.refresh_all(); diff --git a/examples/worf-warden/src/main.rs b/examples/worf-warden/src/main.rs index 31d79af..8646f7e 100644 --- a/examples/worf-warden/src/main.rs +++ b/examples/worf-warden/src/main.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, env, process::Command, thread::sleep, time::Duration}; -use worf_lib::{ +use worf::{ config::{self, Config, CustomKeyHintLocation}, desktop::{copy_to_clipboard, spawn_fork}, gui::{self, CustomKeyHint, CustomKeys, ItemProvider, Key, KeyBinding, MenuItem, Modifier}, diff --git a/worf/Cargo.toml b/worf/Cargo.toml index 81d1e09..d3a1131 100644 --- a/worf/Cargo.toml +++ b/worf/Cargo.toml @@ -13,8 +13,8 @@ similar_names = "allow" clone_on_ref_ptr = "warn" [lib] -name = "worf_lib" -path = "src/lib/mod.rs" +name = "worf" +path = "src/mod.rs" [[bin]] name = "worf" diff --git a/worf/src/main.rs b/worf/src/main.rs index 548a2b5..d0573b1 100644 --- a/worf/src/main.rs +++ b/worf/src/main.rs @@ -2,7 +2,7 @@ use std::env; use anyhow::anyhow; -use worf_lib::{Error, config, config::Mode, desktop::fork_if_configured, modes}; +use worf::{Error, config, config::Mode, desktop::fork_if_configured, modes}; fn main() -> anyhow::Result<()> { env_logger::Builder::new() diff --git a/worf/src/lib/mod.rs b/worf/src/mod.rs similarity index 95% rename from worf/src/lib/mod.rs rename to worf/src/mod.rs index 365eb4e..34d1812 100644 --- a/worf/src/lib/mod.rs +++ b/worf/src/mod.rs @@ -1,14 +1,19 @@ use std::fmt; /// Configuration and command line parsing +#[path = "lib/config.rs"] pub mod config; /// Desktop action like parsing desktop files and launching programs +#[path = "lib/desktop.rs"] pub mod desktop; +#[path = "lib/gui.rs"] /// All things related to the user interface pub mod gui; /// Out of the box supported modes, like drun, dmenu, etc... +#[path = "lib/modes/mod.rs"] pub mod modes; + /// Defines error the lib can encounter #[derive(Debug, PartialEq)] pub enum Error { @@ -72,4 +77,4 @@ impl fmt::Display for Error { } } } -} +} \ No newline at end of file