From 20760c898df794e2c21c673963bdad8fddb91b92 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Wed, 6 Apr 2022 21:56:33 +0200 Subject: [PATCH] Refactor: workspace with separate swayr & swayrbar crates --- Cargo.lock | 19 ++++++++-- Cargo.toml | 33 +++--------------- swayr/Cargo.toml | 24 +++++++++++++ {etc => swayr/etc}/swayrd.service | 0 {misc => swayr/misc}/switch-window.png | Bin .../misc}/switch-workspace-or-window.png | Bin {src => swayr/src}/bin/swayr.rs | 0 {src => swayr/src}/bin/swayrd.rs | 0 {src => swayr/src}/client.rs | 0 {src => swayr/src}/cmds.rs | 0 {src => swayr/src}/config.rs | 0 {src => swayr/src}/demon.rs | 0 {src => swayr/src}/fmt_replace.rs | 2 +- {src => swayr/src}/ipc.rs | 0 {src => swayr/src}/layout.rs | 0 {src => swayr/src}/lib.rs | 6 ---- {src => swayr/src}/rtfmt.rs | 0 {src => swayr/src}/tree.rs | 0 {src => swayr/src}/util.rs | 0 swayrbar/Cargo.toml | 25 +++++++++++++ {src => swayrbar/src}/bar.rs | 0 {src => swayrbar/src}/bar/config.rs | 0 {src => swayrbar/src}/bar/module.rs | 0 {src => swayrbar/src}/bar/module/battery.rs | 0 {src => swayrbar/src}/bar/module/date.rs | 0 {src => swayrbar/src}/bar/module/sysinfo.rs | 0 {src => swayrbar/src}/bar/module/window.rs | 0 {src => swayrbar/src}/bin/swayrbar.rs | 2 +- swayrbar/src/fmt_replace.rs | 1 + swayrbar/src/ipc.rs | 1 + swayrbar/src/lib.rs | 19 ++++++++++ swayrbar/src/rtfmt.rs | 1 + 32 files changed, 95 insertions(+), 38 deletions(-) create mode 100644 swayr/Cargo.toml rename {etc => swayr/etc}/swayrd.service (100%) rename {misc => swayr/misc}/switch-window.png (100%) rename {misc => swayr/misc}/switch-workspace-or-window.png (100%) rename {src => swayr/src}/bin/swayr.rs (100%) rename {src => swayr/src}/bin/swayrd.rs (100%) rename {src => swayr/src}/client.rs (100%) rename {src => swayr/src}/cmds.rs (100%) rename {src => swayr/src}/config.rs (100%) rename {src => swayr/src}/demon.rs (100%) rename {src => swayr/src}/fmt_replace.rs (97%) rename {src => swayr/src}/ipc.rs (100%) rename {src => swayr/src}/layout.rs (100%) rename {src => swayr/src}/lib.rs (89%) rename {src => swayr/src}/rtfmt.rs (100%) rename {src => swayr/src}/tree.rs (100%) rename {src => swayr/src}/util.rs (100%) create mode 100644 swayrbar/Cargo.toml rename {src => swayrbar/src}/bar.rs (100%) rename {src => swayrbar/src}/bar/config.rs (100%) rename {src => swayrbar/src}/bar/module.rs (100%) rename {src => swayrbar/src}/bar/module/battery.rs (100%) rename {src => swayrbar/src}/bar/module/date.rs (100%) rename {src => swayrbar/src}/bar/module/sysinfo.rs (100%) rename {src => swayrbar/src}/bar/module/window.rs (100%) rename {src => swayrbar/src}/bin/swayrbar.rs (96%) create mode 120000 swayrbar/src/fmt_replace.rs create mode 120000 swayrbar/src/ipc.rs create mode 100644 swayrbar/src/lib.rs create mode 120000 swayrbar/src/rtfmt.rs diff --git a/Cargo.lock b/Cargo.lock index 4698589..9405ab7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -616,8 +616,6 @@ dependencies = [ name = "swayr" version = "0.17.0-alpha.0" dependencies = [ - "battery", - "chrono", "clap", "directories", "env_logger", @@ -628,6 +626,23 @@ dependencies = [ "rt-format", "serde", "serde_json", + "swayipc", + "toml", +] + +[[package]] +name = "swayrbar" +version = "0.0.1" +dependencies = [ + "battery", + "chrono", + "env_logger", + "log", + "once_cell", + "regex", + "rt-format", + "serde", + "serde_json", "swaybar-types", "swayipc", "sysinfo", diff --git a/Cargo.toml b/Cargo.toml index 8503016..f26e879 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,31 +1,8 @@ -[package] -name = "swayr" -version = "0.17.0-alpha.0" -description = "A LRU window-switcher (and more) for the sway window manager" -homepage = "https://sr.ht/~tsdh/swayr/" -repository = "https://git.sr.ht/~tsdh/swayr" -authors = ["Tassilo Horn "] -license = "GPL-3.0+" -edition = "2018" -exclude = ["misc/"] - -[dependencies] -battery = "0.7.8" -chrono = "0.4" -clap = {version = "3.0.0", features = ["derive"] } -directories = "4.0" -env_logger = { version = "0.9.0", default-features = false, features = ["termcolor", "atty", "humantime"] } # without regex -log = "0.4" -once_cell = "1.10.0" -rand = "0.8.4" -regex = "1.5.5" -rt-format = "0.3.0" -serde = { version = "1.0.126", features = ["derive"] } -serde_json = "1.0.64" -swaybar-types = "3.0.0" -swayipc = "3.0.0" -sysinfo = "0.23" -toml = "0.5.8" +[workspace] +members = [ + "swayr", + "swayrbar", +] [profile.release] lto = "thin" diff --git a/swayr/Cargo.toml b/swayr/Cargo.toml new file mode 100644 index 0000000..1e145e8 --- /dev/null +++ b/swayr/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "swayr" +version = "0.17.0-alpha.0" +description = "A LRU window-switcher (and more) for the sway window manager" +homepage = "https://sr.ht/~tsdh/swayr/" +repository = "https://git.sr.ht/~tsdh/swayr" +authors = ["Tassilo Horn "] +license = "GPL-3.0+" +edition = "2021" +exclude = ["misc/"] + +[dependencies] +clap = {version = "3.0.0", features = ["derive"] } +directories = "4.0" +env_logger = { version = "0.9.0", default-features = false, features = ["termcolor", "atty", "humantime"] } # without regex +log = "0.4" +once_cell = "1.10.0" +rand = "0.8.4" +regex = "1.5.5" +rt-format = "0.3.0" +serde = { version = "1.0.126", features = ["derive"] } +serde_json = "1.0.64" +swayipc = "3.0.0" +toml = "0.5.8" diff --git a/etc/swayrd.service b/swayr/etc/swayrd.service similarity index 100% rename from etc/swayrd.service rename to swayr/etc/swayrd.service diff --git a/misc/switch-window.png b/swayr/misc/switch-window.png similarity index 100% rename from misc/switch-window.png rename to swayr/misc/switch-window.png diff --git a/misc/switch-workspace-or-window.png b/swayr/misc/switch-workspace-or-window.png similarity index 100% rename from misc/switch-workspace-or-window.png rename to swayr/misc/switch-workspace-or-window.png diff --git a/src/bin/swayr.rs b/swayr/src/bin/swayr.rs similarity index 100% rename from src/bin/swayr.rs rename to swayr/src/bin/swayr.rs diff --git a/src/bin/swayrd.rs b/swayr/src/bin/swayrd.rs similarity index 100% rename from src/bin/swayrd.rs rename to swayr/src/bin/swayrd.rs diff --git a/src/client.rs b/swayr/src/client.rs similarity index 100% rename from src/client.rs rename to swayr/src/client.rs diff --git a/src/cmds.rs b/swayr/src/cmds.rs similarity index 100% rename from src/cmds.rs rename to swayr/src/cmds.rs diff --git a/src/config.rs b/swayr/src/config.rs similarity index 100% rename from src/config.rs rename to swayr/src/config.rs diff --git a/src/demon.rs b/swayr/src/demon.rs similarity index 100% rename from src/demon.rs rename to swayr/src/demon.rs diff --git a/src/fmt_replace.rs b/swayr/src/fmt_replace.rs similarity index 97% rename from src/fmt_replace.rs rename to swayr/src/fmt_replace.rs index 7a71d1a..dd612fb 100644 --- a/src/fmt_replace.rs +++ b/swayr/src/fmt_replace.rs @@ -35,7 +35,7 @@ pub fn maybe_html_escape(do_it: bool, text: String) -> String { macro_rules! fmt_replace { ( $fmt_str:expr, $html_escape:expr, - { $( $($pat:pat)|+ => $exp:expr, )+ } + { $( $($pat:pat_param)|+ => $exp:expr, )+ } ) => { $crate::fmt_replace::PLACEHOLDER_RX .replace_all($fmt_str, |caps: ®ex::Captures| { diff --git a/src/ipc.rs b/swayr/src/ipc.rs similarity index 100% rename from src/ipc.rs rename to swayr/src/ipc.rs diff --git a/src/layout.rs b/swayr/src/layout.rs similarity index 100% rename from src/layout.rs rename to swayr/src/layout.rs diff --git a/src/lib.rs b/swayr/src/lib.rs similarity index 89% rename from src/lib.rs rename to swayr/src/lib.rs index 3e0004b..2cd4e15 100644 --- a/src/lib.rs +++ b/swayr/src/lib.rs @@ -13,17 +13,11 @@ // You should have received a copy of the GNU General Public License along with // this program. If not, see . -// TODO: Possibly just include README.md when this feature is in the release -// channel. -// -// #![doc(include = "../README.md")] - //! **Swayr** is a LRU window-switcher and more for the sway window manager. //! It consists of a demon, and a client. The demon `swayrd` records //! window/workspace creations, deletions, and focus changes using sway's JSON //! IPC interface. The client `swayr` offers subcommands, see `swayr --help`. -pub mod bar; pub mod client; pub mod cmds; pub mod config; diff --git a/src/rtfmt.rs b/swayr/src/rtfmt.rs similarity index 100% rename from src/rtfmt.rs rename to swayr/src/rtfmt.rs diff --git a/src/tree.rs b/swayr/src/tree.rs similarity index 100% rename from src/tree.rs rename to swayr/src/tree.rs diff --git a/src/util.rs b/swayr/src/util.rs similarity index 100% rename from src/util.rs rename to swayr/src/util.rs diff --git a/swayrbar/Cargo.toml b/swayrbar/Cargo.toml new file mode 100644 index 0000000..dfd31bd --- /dev/null +++ b/swayrbar/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "swayrbar" +version = "0.0.1" +edition = "2021" +homepage = "https://sr.ht/~tsdh/swayr/" +repository = "https://git.sr.ht/~tsdh/swayr" +authors = ["Tassilo Horn "] +license = "GPL-3.0+" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +battery = "0.7.8" +chrono = "0.4" +env_logger = { version = "0.9.0", default-features = false, features = ["termcolor", "atty", "humantime"] } # without regex +log = "0.4" +once_cell = "1.10.0" +regex = "1.5.5" +rt-format = "0.3.0" +serde = { version = "1.0.126", features = ["derive"] } +serde_json = "1.0.64" +swaybar-types = "3.0.0" +swayipc = "3.0.0" +sysinfo = "0.23" +toml = "0.5.8" diff --git a/src/bar.rs b/swayrbar/src/bar.rs similarity index 100% rename from src/bar.rs rename to swayrbar/src/bar.rs diff --git a/src/bar/config.rs b/swayrbar/src/bar/config.rs similarity index 100% rename from src/bar/config.rs rename to swayrbar/src/bar/config.rs diff --git a/src/bar/module.rs b/swayrbar/src/bar/module.rs similarity index 100% rename from src/bar/module.rs rename to swayrbar/src/bar/module.rs diff --git a/src/bar/module/battery.rs b/swayrbar/src/bar/module/battery.rs similarity index 100% rename from src/bar/module/battery.rs rename to swayrbar/src/bar/module/battery.rs diff --git a/src/bar/module/date.rs b/swayrbar/src/bar/module/date.rs similarity index 100% rename from src/bar/module/date.rs rename to swayrbar/src/bar/module/date.rs diff --git a/src/bar/module/sysinfo.rs b/swayrbar/src/bar/module/sysinfo.rs similarity index 100% rename from src/bar/module/sysinfo.rs rename to swayrbar/src/bar/module/sysinfo.rs diff --git a/src/bar/module/window.rs b/swayrbar/src/bar/module/window.rs similarity index 100% rename from src/bar/module/window.rs rename to swayrbar/src/bar/module/window.rs diff --git a/src/bin/swayrbar.rs b/swayrbar/src/bin/swayrbar.rs similarity index 96% rename from src/bin/swayrbar.rs rename to swayrbar/src/bin/swayrbar.rs index c4cd038..507a61e 100644 --- a/src/bin/swayrbar.rs +++ b/swayrbar/src/bin/swayrbar.rs @@ -18,5 +18,5 @@ fn main() { // TODO: We need a config file cmd line option so that each bar can have // its own config. - swayr::bar::start(); + swayrbar::bar::start(); } diff --git a/swayrbar/src/fmt_replace.rs b/swayrbar/src/fmt_replace.rs new file mode 120000 index 0000000..1b48b5f --- /dev/null +++ b/swayrbar/src/fmt_replace.rs @@ -0,0 +1 @@ +../../swayr/src/fmt_replace.rs \ No newline at end of file diff --git a/swayrbar/src/ipc.rs b/swayrbar/src/ipc.rs new file mode 120000 index 0000000..088362c --- /dev/null +++ b/swayrbar/src/ipc.rs @@ -0,0 +1 @@ +../../swayr/src/ipc.rs \ No newline at end of file diff --git a/swayrbar/src/lib.rs b/swayrbar/src/lib.rs new file mode 100644 index 0000000..45716e3 --- /dev/null +++ b/swayrbar/src/lib.rs @@ -0,0 +1,19 @@ +// Copyright (C) 2021-2022 Tassilo Horn +// +// This program is free software: you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation, either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . + +pub mod bar; +pub mod fmt_replace; +pub mod ipc; +pub mod rtfmt; diff --git a/swayrbar/src/rtfmt.rs b/swayrbar/src/rtfmt.rs new file mode 120000 index 0000000..0d9eac8 --- /dev/null +++ b/swayrbar/src/rtfmt.rs @@ -0,0 +1 @@ +../../swayr/src/rtfmt.rs \ No newline at end of file