feat: voidpin now copies to linux as well
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "voidpin"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
version.workspace = true
|
||||
|
||||
|
@@ -15,9 +15,26 @@ impl LocalCopier {
|
||||
|
||||
pub async fn copy(&self, input: &[u8]) -> anyhow::Result<()> {
|
||||
// FIXME: hardcode for macos
|
||||
let mut copy_process = tokio::process::Command::new("pbcopy")
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()?;
|
||||
#[cfg(target_os = "macos")]
|
||||
let mut copy_process = {
|
||||
tokio::process::Command::new("pbcopy")
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()?
|
||||
};
|
||||
#[cfg(target_os = "linux")]
|
||||
let mut copy_process = {
|
||||
tokio::process::Command::new("wl-copy")
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()?
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
let mut copy_process = {
|
||||
todo!("windows not supported yet");
|
||||
|
||||
tokio::process::Command::new("wl-copy")
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()?
|
||||
};
|
||||
|
||||
if let Some(mut stdin_handle) = copy_process.stdin.take() {
|
||||
stdin_handle
|
||||
|
@@ -70,6 +70,26 @@ async fn main() -> anyhow::Result<()> {
|
||||
.await?;
|
||||
}
|
||||
Commands::Copy {} => {
|
||||
if let Ok(remote_host) = std::env::var("VOIDPIN_REMOTE") {
|
||||
let mut input = String::new();
|
||||
std::io::stdin()
|
||||
.read_to_string(&mut input)
|
||||
.context("failed to read from stdin")?;
|
||||
|
||||
if input.is_empty() {
|
||||
tracing::info!("no content to put in clipboard");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
tracing::debug!(content = &input, "found content");
|
||||
state
|
||||
.remote_copier(&remote_host)
|
||||
.copy(input.as_bytes())
|
||||
.await?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut input = String::new();
|
||||
std::io::stdin()
|
||||
.read_to_string(&mut input)
|
||||
@@ -102,7 +122,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
.await?;
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user