diff options
author | delta <darkussdelta@gmail.com> | 2023-04-12 00:21:03 +0200 |
---|---|---|
committer | delta <darkussdelta@gmail.com> | 2023-04-12 00:21:03 +0200 |
commit | 98676ca1d7ab9a9abb4c01d0cdf67b83f7cdce49 (patch) | |
tree | 2c8499e59cd346c8f59688d8c5dda231c178941a /.config/awesome/quarrel/native/src | |
parent | f7116d268aff3fae88d8de408e8c807295618a5c (diff) |
idk what i'm doing
Diffstat (limited to '.config/awesome/quarrel/native/src')
-rw-r--r-- | .config/awesome/quarrel/native/src/lenses/application.rs | 34 | ||||
-rw-r--r-- | .config/awesome/quarrel/native/src/lib.rs | 1 | ||||
-rw-r--r-- | .config/awesome/quarrel/native/src/sound.rs | 17 |
3 files changed, 33 insertions, 19 deletions
diff --git a/.config/awesome/quarrel/native/src/lenses/application.rs b/.config/awesome/quarrel/native/src/lenses/application.rs index 4317c75..b0135d4 100644 --- a/.config/awesome/quarrel/native/src/lenses/application.rs +++ b/.config/awesome/quarrel/native/src/lenses/application.rs @@ -5,7 +5,6 @@ use std::{ use freedesktop_entry_parser as fd; use mlua::prelude::*; -use parking_lot::Mutex; use rayon::prelude::*; use url::Url; @@ -14,6 +13,10 @@ use crate::lenses::entry::{ Entry, }; +fn contains_ignore_ascii_case(a: &str, b: &str) -> bool { + return false; +} + fn parse_entry(entry: &fd::Entry, path: &PathBuf) -> Result<Entry, ()> { let section = entry.section("Desktop Entry"); let name = section.attr("Name").ok_or(())?.to_string(); @@ -66,29 +69,22 @@ pub fn query(lua: &Lua, input: String) -> LuaResult<LuaTable> { .map(|result| result.map(|e| e.path())) .collect::<Result<Vec<_>, std::io::Error>>()?; - let entries = entries - .into_iter() - .filter(|e| matches!(e.extension(), Some(ext) if ext == "desktop")) - .collect::<Vec<_>>(); - - let mut parsed_entries: Mutex<Vec<Entry>> = Mutex::new(Vec::new()); + let parsed_entries: Vec<Entry> = entries + .into_par_iter() + .filter(|path| matches!(path.extension(), Some(ext) if ext == "desktop")) + .filter_map(|path| { + let Ok(entry) = fd::parse_entry(&path) else { + return None + }; - entries.into_par_iter().for_each(|path| { - let Ok(entry) = fd::parse_entry(&path) else { - return - }; - - if let Ok(parsed_entry) = parse_entry(&entry, &path) { - parsed_entries.lock().push(parsed_entry); - } - }); + return parse_entry(&entry, &path).ok(); + }) + .collect(); Ok(entries_to_lua_table( parsed_entries - .get_mut() - .iter() + .into_iter() .filter(|entry| entry.message.to_lowercase().contains(&input)) - .map(|entry| (*entry).clone()) .collect(), lua, )) diff --git a/.config/awesome/quarrel/native/src/lib.rs b/.config/awesome/quarrel/native/src/lib.rs index 3a016c4..d265d2d 100644 --- a/.config/awesome/quarrel/native/src/lib.rs +++ b/.config/awesome/quarrel/native/src/lib.rs @@ -1,4 +1,5 @@ mod lenses; +// mod sound; use mlua::prelude::*; diff --git a/.config/awesome/quarrel/native/src/sound.rs b/.config/awesome/quarrel/native/src/sound.rs new file mode 100644 index 0000000..c398d70 --- /dev/null +++ b/.config/awesome/quarrel/native/src/sound.rs @@ -0,0 +1,17 @@ +use std::{ + fs::File, + io::BufReader, + path::Path, + time::Duration, +}; + +use mlua::prelude::*; +use rodio::{ + Decoder, + OutputStream, + Sink, +}; + +pub fn play_sound(_: &Lua, file: String) -> LuaResult<()> { + +} |