aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/quarrel/native
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2023-04-12 00:21:03 +0200
committerdelta <darkussdelta@gmail.com>2023-04-12 00:21:03 +0200
commit98676ca1d7ab9a9abb4c01d0cdf67b83f7cdce49 (patch)
tree2c8499e59cd346c8f59688d8c5dda231c178941a /.config/awesome/quarrel/native
parentf7116d268aff3fae88d8de408e8c807295618a5c (diff)
idk what i'm doing
Diffstat (limited to '.config/awesome/quarrel/native')
-rw-r--r--.config/awesome/quarrel/native/Cargo.toml3
-rw-r--r--.config/awesome/quarrel/native/rustfmt.toml1
-rw-r--r--.config/awesome/quarrel/native/src/lenses/application.rs34
-rw-r--r--.config/awesome/quarrel/native/src/lib.rs1
-rw-r--r--.config/awesome/quarrel/native/src/sound.rs17
5 files changed, 35 insertions, 21 deletions
diff --git a/.config/awesome/quarrel/native/Cargo.toml b/.config/awesome/quarrel/native/Cargo.toml
index 3806f3c..fdabea0 100644
--- a/.config/awesome/quarrel/native/Cargo.toml
+++ b/.config/awesome/quarrel/native/Cargo.toml
@@ -7,14 +7,13 @@ edition = "2021"
[dependencies]
freedesktop_entry_parser = "1.3.0"
-# meval = "0.2.0"
cpc = "1.9.1"
mlua = { version = "0.8.7", features = [ "module", "lua54", "serialize" ] }
palette = { version = "0.6.1", default-features = false, features = [ "std" ] }
-parking_lot = "0.12.1"
rayon = "1.6.1"
serde = { version = "1.0.152", features = [ "derive" ] }
url = "2.3.1"
+rodio = "0.17.1"
[lib]
crate-type = ["cdylib"]
diff --git a/.config/awesome/quarrel/native/rustfmt.toml b/.config/awesome/quarrel/native/rustfmt.toml
index 36afbbd..3c7f9b0 100644
--- a/.config/awesome/quarrel/native/rustfmt.toml
+++ b/.config/awesome/quarrel/native/rustfmt.toml
@@ -1,3 +1,4 @@
imports_layout = "Vertical"
unstable_features = true
group_imports = "StdExternalCrate"
+imports_granularity = "Crate"
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<()> {
+
+}