improv: Separate components & merge plugins binary with launcher service

This commit is contained in:
Michael Aaron Murphy 2021-08-14 14:19:42 +02:00
parent 43a4229ba7
commit 88acf0a74e
41 changed files with 219 additions and 152 deletions

View file

@ -1,7 +1,7 @@
use freedesktop_desktop_entry::{default_paths, DesktopEntry, Iter as DesktopIter, PathSource};
use futures_lite::{AsyncWrite, StreamExt};
use pop_launcher::*;
use pop_launcher_plugins::*;
use crate::*;
use std::borrow::Cow;
use std::hash::{Hash, Hasher};
use std::path::PathBuf;
@ -172,7 +172,7 @@ impl<W: AsyncWrite + Unpin> DesktopEntryPlugin<W> {
|| strsim::damerau_levenshtein(&*query, &*search_interest) < 3;
if append {
let response = PluginResponse::Append(SearchMeta {
let response = PluginResponse::Append(PluginSearchResult {
id: id as u32,
name: entry.name.clone(),
description: format!("{} - {}", path_string(&entry.src), entry.description),

View file

@ -1,6 +1,6 @@
use futures_lite::*;
use pop_launcher::*;
use pop_launcher_plugins::send;
use crate::send;
use smol::process::{ChildStdout, Command, Stdio};
use std::borrow::Cow;
use std::cell::Cell;
@ -121,7 +121,7 @@ impl SearchContext {
let path = PathBuf::from(line);
let response = PluginResponse::Append(SearchMeta {
let response = PluginResponse::Append(PluginSearchResult {
id,
description,
name,

View file

@ -1,3 +1,8 @@
pub mod desktop_entries;
pub mod find;
pub mod pop_shell;
pub mod scripts;
use futures_lite::{AsyncWrite, AsyncWriteExt};
use pop_launcher::PluginResponse;

View file

@ -1,26 +0,0 @@
mod plugins;
use smol::block_on;
use std::io;
fn main() {
tracing_subscriber::fmt()
.with_writer(io::stderr)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
std::env::args();
if let Some(plugin) = std::env::args().next() {
let start = plugin.rfind('/').map(|v| v + 1).unwrap_or(0);
match &plugin.as_str()[start..] {
"desktop-entries" => block_on(plugins::desktop_entries::main()),
"pop-shell" => block_on(plugins::pop_shell::main()),
"find" => block_on(plugins::find::main()),
"scripts" => block_on(plugins::scripts::main()),
unknown => {
eprintln!("unknown cmd: {}", unknown);
}
}
}
}

View file

@ -1,4 +0,0 @@
pub mod desktop_entries;
pub mod find;
pub mod pop_shell;
pub mod scripts;

View file

@ -1,6 +1,6 @@
use futures_lite::{AsyncWrite, AsyncWriteExt, StreamExt};
use pop_launcher::*;
use pop_launcher_plugins::*;
use crate::*;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use zbus::Connection;
@ -106,7 +106,7 @@ impl<W: AsyncWrite + Unpin> App<W> {
send(
&mut self.tx,
PluginResponse::Append(SearchMeta {
PluginResponse::Append(PluginSearchResult {
id: id as u32,
name: item.name.clone(),
description: item.description.clone(),

View file

@ -1,5 +1,5 @@
use pop_launcher::*;
use pop_launcher_plugins::*;
use crate::*;
use flume::Sender;
use futures_lite::{AsyncBufReadExt, StreamExt};
@ -114,7 +114,7 @@ impl App {
if should_include {
send(
out,
PluginResponse::Append(SearchMeta {
PluginResponse::Append(PluginSearchResult {
id: id as u32,
name: script.name.clone(),
description: script.description.clone(),