Skip to content

Commit

Permalink
Merge pull request #126 from braden-w:fix/windows-and-linux-github-ac…
Browse files Browse the repository at this point in the history
…tions

fix: conditionally include accessibility-sys and core-foundation-sys only if target os is macos
  • Loading branch information
braden-w committed Jun 29, 2024
1 parent 1c3f89a commit 70dc7ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
6 changes: 4 additions & 2 deletions apps/app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.6.1", features = [ "os-all", "updater", "notification-all", "window-set-size", "fs-write-file", "dialog-save", "system-tray", "global-shortcut-all", "clipboard-write-text", "shell-open", "icon-png"] }
enigo = "0.2.1"
accessibility-sys = "0.1.3"
core-foundation-sys = "0.8.6"

[target.'cfg(target_os = "macos")'.dependencies]
accessibility-sys = "0.1.3"
core-foundation-sys = "0.8.6"

[features]
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
Expand Down
25 changes: 18 additions & 7 deletions apps/app/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

#[cfg(target_os = "macos")]
mod accessibility;

#[cfg(target_os = "macos")]
use accessibility::is_macos_accessibility_enabled;

use tauri::{CustomMenuItem, Manager};
use tauri::{SystemTray, SystemTrayEvent, SystemTrayMenu};

Expand All @@ -11,7 +15,7 @@ fn main() {

let tray_menu = SystemTrayMenu::new().add_item(quit);

tauri::Builder::default()
let builder = tauri::Builder::default()
.system_tray(SystemTray::new().with_menu(tray_menu))
.on_system_tray_event(|app, event| match event {
SystemTrayEvent::LeftClick {
Expand All @@ -28,12 +32,19 @@ fn main() {
_ => {}
},
_ => {}
})
.invoke_handler(tauri::generate_handler![
write_text,
set_tray_icon,
is_macos_accessibility_enabled
])
});

#[cfg(target_os = "macos")]
let builder = builder.invoke_handler(tauri::generate_handler![
write_text,
set_tray_icon,
is_macos_accessibility_enabled,
]);

#[cfg(not(target_os = "macos"))]
let builder = builder.invoke_handler(tauri::generate_handler![write_text, set_tray_icon,]);

builder
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Expand Down

0 comments on commit 70dc7ee

Please sign in to comment.