mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-15 18:16:59 +05:30
chore: revert to default formatting style
This commit is contained in:
parent
142676ac1d
commit
6048f7a537
6 changed files with 169 additions and 185 deletions
|
@ -5,24 +5,23 @@ use std::time::Duration;
|
|||
use tracing::{debug, error};
|
||||
|
||||
pub fn monitor(config: &Replacements) -> Result<()> {
|
||||
loop {
|
||||
let mut clipboard =
|
||||
ClipboardContext::new().expect("Failed to get clipboard");
|
||||
if let Ok(contents) = clipboard.get_contents() {
|
||||
if let Some(subst) = config
|
||||
.substitutors
|
||||
.iter()
|
||||
.find(|subst| subst.matcher.check_match(&contents))
|
||||
{
|
||||
if !subst.name.is_empty() {
|
||||
debug!(?subst.name, ?contents);
|
||||
loop {
|
||||
let mut clipboard = ClipboardContext::new().expect("Failed to get clipboard");
|
||||
if let Ok(contents) = clipboard.get_contents() {
|
||||
if let Some(subst) = config
|
||||
.substitutors
|
||||
.iter()
|
||||
.find(|subst| subst.matcher.check_match(&contents))
|
||||
{
|
||||
if !subst.name.is_empty() {
|
||||
debug!(?subst.name, ?contents);
|
||||
}
|
||||
let result = subst.action.apply_action(&contents);
|
||||
if let Err(e) = clipboard.set_contents(result) {
|
||||
error!("{}", e);
|
||||
}
|
||||
};
|
||||
}
|
||||
let result = subst.action.apply_action(&contents);
|
||||
if let Err(e) = clipboard.set_contents(result) {
|
||||
error!("{}", e);
|
||||
}
|
||||
};
|
||||
std::thread::sleep(Duration::from_millis(1_000));
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(1_000));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue