From 12b7610559eced3d631d2e2f16744ca723f89bd9 Mon Sep 17 00:00:00 2001 From: Daniel Berg Date: Sun, 15 Dec 2024 18:28:44 +0100 Subject: [PATCH] fix: configure as binary package Let lib be named something different, mainly for documentation purposes --- Cargo.toml | 8 ++++++++ src/main.rs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d1ce68c..e0791a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,14 @@ categories = ["gui", "window-manager"] license = "MIT" exclude = ["/script", "/assets/*", "Vagrantfile"] +[lib] +name = "i3wsr_core" +path = "src/lib.rs" + +[[bin]] +name = "i3wsr" +path = "src/main.rs" + [badges] travis-ci = { repository = "roosta/i3wsr" } diff --git a/src/main.rs b/src/main.rs index 0b83a4d..24bc14e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,11 +93,11 @@ use clap::{Parser, ValueEnum}; use dirs::config_dir; use swayipc::{Connection, Event, EventType, Fallible}; -use i3wsr::config::{Config, ConfigError}; +use i3wsr_core::config::{Config, ConfigError}; use std::io; use std::path::Path; -use i3wsr::AppError; +use i3wsr_core::AppError; /// Window property types that can be used for workspace naming. /// @@ -298,7 +298,7 @@ fn setup() -> Result { let args = Args::parse(); // Set verbose mode if requested - i3wsr::VERBOSE.store(args.verbose, std::sync::atomic::Ordering::Relaxed); + i3wsr_core::VERBOSE.store(args.verbose, std::sync::atomic::Ordering::Relaxed); let mut config = load_config(args.config.as_deref())?; apply_args_to_config(&mut config, &args); @@ -318,15 +318,15 @@ fn handle_event( event: Fallible, conn: &mut Connection, config: &Config, - res: &i3wsr::regex::Compiled, + res: &i3wsr_core::regex::Compiled, ) -> Result<(), AppError> { match event { Ok(Event::Window(e)) => { - i3wsr::handle_window_event(&e, conn, config, res) + i3wsr_core::handle_window_event(&e, conn, config, res) .map_err(|e| AppError::Event(format!("Window event error: {}", e)))?; } Ok(Event::Workspace(e)) => { - i3wsr::handle_ws_event(&e, conn, config, res) + i3wsr_core::handle_ws_event(&e, conn, config, res) .map_err(|e| AppError::Event(format!("Workspace event error: {}", e)))?; } Ok(_) => {} @@ -347,12 +347,12 @@ fn handle_event( /// interrupted or an unrecoverable error occurs. fn run() -> Result<(), AppError> { let config = setup()?; - let res = i3wsr::regex::parse_config(&config)?; + let res = i3wsr_core::regex::parse_config(&config)?; let mut conn = Connection::new()?; let subscriptions = [EventType::Window, EventType::Workspace]; - i3wsr::update_tree(&mut conn, &config, &res) + i3wsr_core::update_tree(&mut conn, &config, &res) .map_err(|e| AppError::Event(format!("Initial tree update failed: {}", e)))?; let event_connection = Connection::new()?;