Skip to content

Commit

Permalink
Fix chromium freeze by switching from fork to bin clipboard provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasol committed Oct 6, 2023
1 parent 32fae91 commit 9b8ca81
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use base64::{engine::general_purpose, Engine as _};
use copypasta_ext::prelude::*;
use copypasta_ext::x11_fork::ClipboardContext;
use copypasta_ext::x11_bin::ClipboardContext as BinClipboardContext;
use copypasta_ext::x11_fork::ClipboardContext as ForkClipboardContext;
use crossterm::style::Print;
use dirs::home_dir;
use std::path::PathBuf;
Expand Down Expand Up @@ -110,12 +111,17 @@ pub fn copy_string_to_clipboard(content: String) -> Result<CopyType, ()> {
Ok(_) => Ok(CopyType::OSC52),
Err(_) => Err(()),
};
} else if let Ok(mut ctx) = ClipboardContext::new() {
return if ctx.set_contents(content).is_ok() {
Ok(CopyType::Native)
} else {
Err(())
};
} else if BinClipboardContext::new()
.and_then(|mut ctx| ctx.set_contents(content.clone()))
.is_ok()
{
Ok(CopyType::Native)
} else if ForkClipboardContext::new()
.and_then(|mut ctx| ctx.set_contents(content))
.is_ok()
{
Ok(CopyType::Native)
} else {
Err(())
}
Err(())
}

0 comments on commit 9b8ca81

Please sign in to comment.