feat: implement OS bridge and enhance app launcher functionality
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use k_launcher_kernel::{Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
use k_launcher_kernel::{LaunchAction, Plugin, PluginName, ResultId, ResultTitle, Score, SearchResult};
|
||||
|
||||
pub struct CalcPlugin;
|
||||
|
||||
@@ -46,27 +44,14 @@ impl Plugin for CalcPlugin {
|
||||
};
|
||||
let display = format!("= {value_str}");
|
||||
let expr_owned = expr.to_string();
|
||||
let clipboard_val = value_str;
|
||||
vec![SearchResult {
|
||||
id: ResultId::new("calc-result"),
|
||||
title: ResultTitle::new(display),
|
||||
description: Some(format!("{expr_owned} · Enter to copy")),
|
||||
icon: None,
|
||||
score: Score::new(90),
|
||||
on_execute: Arc::new(move || {
|
||||
if std::process::Command::new("wl-copy").arg(&clipboard_val).spawn().is_err() {
|
||||
use std::io::Write;
|
||||
if let Ok(mut child) = std::process::Command::new("xclip")
|
||||
.args(["-selection", "clipboard"])
|
||||
.stdin(std::process::Stdio::piped())
|
||||
.spawn()
|
||||
{
|
||||
if let Some(stdin) = child.stdin.as_mut() {
|
||||
let _ = stdin.write_all(clipboard_val.as_bytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
action: LaunchAction::CopyToClipboard(value_str),
|
||||
on_select: None,
|
||||
}]
|
||||
}
|
||||
_ => vec![],
|
||||
|
||||
Reference in New Issue
Block a user