Add mute change notification, remove nwg trash, package updates

This commit is contained in:
Your Name
2025-02-16 11:19:29 -05:00
parent 5f69fc664a
commit 989c5c05a5
7 changed files with 182 additions and 318 deletions

View File

@@ -3,7 +3,7 @@ use std::{
env,
error::Error,
fs::{self, File},
io::{BufRead, BufReader},
io::{BufRead, BufReader}
};
use auto_mute_lib::muter::MuterThread;
@@ -14,18 +14,10 @@ use windows::{
FindCloseChangeNotification, FindFirstChangeNotificationW, FindNextChangeNotification,
FILE_NOTIFY_CHANGE_LAST_WRITE,
},
System::{
Com::{CoInitializeEx, COINIT_MULTITHREADED},
Threading::{WaitForSingleObject, INFINITE}
},
System::Threading::{WaitForSingleObject, INFINITE},
}, core::w,
};
pub fn load_mute_txt(file_name: &str) -> HashSet<String> {
let file = File::open(file_name).unwrap();
HashSet::from_iter(BufReader::new(file).lines().map(|line| line.unwrap()))
}
pub fn await_file_change(file_name: &str) -> Result<(), Box<dyn Error>> {
unsafe {
let md = fs::metadata(file_name)?.modified()?;
@@ -40,13 +32,17 @@ pub fn await_file_change(file_name: &str) -> Result<(), Box<dyn Error>> {
}
}
pub fn load_mute_txt(file_name: &str) -> HashSet<String> {
let file = File::open(file_name).unwrap();
HashSet::from_iter(BufReader::new(file).lines().map(|line| line.unwrap()))
}
fn main() {
unsafe {
CoInitializeEx(None, COINIT_MULTITHREADED).unwrap();
}
MuterThread::com_init();
let mute_file: String = env::args().nth(1).unwrap_or("mute.txt".to_string());
loop {
let mut _mt = MuterThread::new(load_mute_txt(&mute_file));
let mut _mt = MuterThread::new(load_mute_txt(&mute_file), None);
await_file_change(&mute_file).unwrap();
}
}