diff --git a/Cargo.lock b/Cargo.lock index 9e0c55c..9695db0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -597,26 +597,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "swayipc" -version = "3.0.0-alpha.3" -source = "git+https://github.com/k0kubun/swayipc-rs#580b5b6e02b911547c4741bfe240ea8d81d1147c" -dependencies = [ - "serde", - "serde_json", - "swayipc-types", -] - -[[package]] -name = "swayipc-types" -version = "1.0.0-alpha.3" -source = "git+https://github.com/k0kubun/swayipc-rs#580b5b6e02b911547c4741bfe240ea8d81d1147c" -dependencies = [ - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "syn" version = "1.0.82" @@ -762,7 +742,6 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "swayipc", "x11", "zbus", ] diff --git a/Cargo.toml b/Cargo.toml index 03b640d..03ce876 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,8 @@ name = "xremap" version = "0.1.0" edition = "2021" +description = "Dynamic key remapp for X and Wayland" +license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -21,5 +23,4 @@ zbus = "1.9.2" [features] gnome = [] -sway = [] x11 = [] diff --git a/src/client/mod.rs b/src/client/mod.rs index 053c41b..5a28467 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -48,13 +48,6 @@ pub fn build_client() -> WMClient { WMClient::new("GNOME", Box::new(gnome_client::GnomeClient::new())) } -#[cfg(feature = "sway")] -mod sway_client; -#[cfg(feature = "sway")] -pub fn build_client() -> WMClient { - WMClient::new("Sway", Box::new(sway_client::SwayClient::new())) -} - #[cfg(feature = "x11")] mod x11_client; #[cfg(feature = "x11")] @@ -62,9 +55,9 @@ pub fn build_client() -> WMClient { WMClient::new("X11", Box::new(x11_client::X11Client::new())) } -#[cfg(not(any(feature = "gnome", feature = "sway", feature = "x11")))] +#[cfg(not(any(feature = "gnome", feature = "x11")))] mod null_client; -#[cfg(not(any(feature = "gnome", feature = "sway", feature = "x11")))] +#[cfg(not(any(feature = "gnome", feature = "x11")))] pub fn build_client() -> WMClient { WMClient::new("none", Box::new(null_client::NullClient)) } diff --git a/src/client/sway_client.rs b/src/client/sway_client.rs deleted file mode 100644 index 72a250c..0000000 --- a/src/client/sway_client.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate::client::Client; -use std::fs::read_dir; -use std::os::unix::ffi::OsStrExt; -use std::os::unix::net::UnixStream; -use swayipc::Connection; - -pub struct SwayClient { - connection: Option, -} - -impl SwayClient { - pub fn new() -> SwayClient { - SwayClient { connection: None } - } - - fn connect(&mut self) { - if let None = self.connection { - if let Some(socket) = find_socket() { - if let Ok(unix_stream) = UnixStream::connect(socket) { - self.connection = Some(Connection(unix_stream)); - } - } - } - } -} - -impl Client for SwayClient { - fn supported(&mut self) -> bool { - self.connect(); - self.connection.is_some() - } - - fn current_application(&mut self) -> Option { - self.connect(); - let connection = match &mut self.connection { - Some(connection) => connection, - None => return None, - }; - - if let Ok(node) = connection.get_tree() { - if let Some(node) = node.find_focused(|n| n.focused) { - return node.app_id; - } - } - None - } -} - -// e.g. "/run/user/1000/sway-ipc.1000.2575.sock" -fn find_socket() -> Option { - let uid = 1000; // Assume a first nornal Linux user. TODO: Make it configurable - if let Some(run_user) = read_dir(format!("/run/user/{}", uid)).as_mut().ok() { - while let Some(entry) = run_user.next() { - let path = entry.ok()?.path(); - if let Some(fname) = path.file_name() { - if fname.as_bytes().starts_with(b"sway-ipc.") { - if let Ok(path) = path.into_os_string().into_string() { - return Some(path); - } - } - } - } - } - None -}