Skip to content

Commit

Permalink
easy
Browse files Browse the repository at this point in the history
  • Loading branch information
0-don committed Oct 3, 2023
1 parent 03864db commit 0c496be
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 18 deletions.
38 changes: 30 additions & 8 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ path = "src/lib.rs"

[dependencies]
entity = { path = "../entity" }
async-std = { version = "1.12", features = ["attributes", "tokio1"] }
async-std = { version = "1", features = ["attributes", "tokio1"] }

[dependencies.sea-orm-migration]
version = "^0"
Expand Down
5 changes: 4 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use commands::{clipboard, hotkey, settings, window};
use tauri_plugin_autostart::MacosLauncher;
use utils::{setup, tray};

fn main() {
#[tokio::main]
async fn main() {
tauri::async_runtime::set(tokio::runtime::Handle::current());

tauri::Builder::default()
.plugin(tauri_plugin_positioner::init())
.plugin(tauri_plugin_autostart::init(
Expand Down
15 changes: 13 additions & 2 deletions src-tauri/src/utils/hotkey/hotkey_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ pub fn init_hotkey_listener() -> () {
let _ = hotkey_manager.register(hotkey).unwrap();

let receiver = GlobalHotKeyEvent::receiver();
std::thread::spawn(|| {
let hotkeys = HOTKEYS.get().unwrap().lock().unwrap();
// Runtime;
tokio::spawn(async {
loop {
if let Ok(event) = receiver.try_recv() {
let hotkeys = HOTKEYS.get().unwrap().lock().unwrap();
if let Some(hotkey) = hotkeys.get(&event.id) {
println!("Hotkey Pressed: {:?}", hotkey);
toggle_main_window();
Expand All @@ -41,6 +42,16 @@ pub fn init_hotkey_listener() -> () {
std::thread::sleep(Duration::from_millis(100));
}
});
// std::thread::spawn(|| loop {
// if let Ok(event) = receiver.try_recv() {
// let hotkeys = HOTKEYS.get().unwrap().lock().unwrap();
// if let Some(hotkey) = hotkeys.get(&event.id) {
// println!("Hotkey Pressed: {:?}", hotkey);
// toggle_main_window();
// }
// }
// std::thread::sleep(Duration::from_millis(100));
// });
}

pub fn parse_shortcut(ctrl: bool, alt: bool, shift: bool, key: &str) -> String {
Expand Down
8 changes: 2 additions & 6 deletions src-tauri/src/utils/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ pub fn system_tray_event(app: &tauri::AppHandle, event: SystemTrayEvent) {
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
"open" => toggle_main_window(),
"quit" => app.exit(1),
_ => {
println!("Unhandled tray event");
}
_ => println!("Unhandled tray event"),
},
_ => {
println!("Unhandled tray event");
}
_ => println!("Unhandled tray event"),
}
}

0 comments on commit 0c496be

Please sign in to comment.