icon update + color tray when recording

This commit is contained in:
CJ Pais 2025-05-09 11:46:06 -07:00
parent b58b65dabc
commit 5fc55cfcb3
62 changed files with 88 additions and 9 deletions

2
.gitignore vendored
View file

@ -23,4 +23,4 @@ dist-ssr
*.sln
*.sw?
src-tauri/resources
src-tauri/resources/models

1
src-tauri/Cargo.lock generated
View file

@ -4779,6 +4779,7 @@ dependencies = [
"gtk",
"heck 0.5.0",
"http",
"image",
"jni",
"libc",
"log",

View file

@ -21,7 +21,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = ["tray-icon"] }
tauri = { version = "2", features = ["tray-icon", 'image-png'] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src-tauri/icons/64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
src-tauri/icons/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View file

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 469 B

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -7,6 +7,8 @@ use managers::audio::AudioRecordingManager;
use managers::transcription::TranscriptionManager;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use tauri::image::Image;
use tauri::menu::{Menu, MenuItem};
use tauri::tray::TrayIconBuilder;
use tauri::Manager;
use tauri_plugin_autostart::MacosLauncher;
@ -40,15 +42,36 @@ pub fn run() {
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
.manage(AppState::new())
.setup(move |app| {
let _tray = TrayIconBuilder::new().build(app)?;
let settings_i = MenuItem::with_id(app, "settings", "Settings", true, None::<&str>)?;
let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&settings_i, &quit_i])?;
let tray = TrayIconBuilder::new()
.icon(Image::from_path(app.path().resolve(
"resources/tray_64x64.png",
tauri::path::BaseDirectory::Resource,
)?)?)
.menu(&menu)
.show_menu_on_left_click(true)
.on_menu_event(|app, event| match event.id.as_ref() {
"settings" => {
let settings_window = app.get_webview_window("main").unwrap();
settings_window.show().unwrap();
}
"quit" => {
app.exit(0);
}
_ => {}
})
.build(app)?;
app.manage(tray);
let vad_path = app.path().resolve(
"resources/silero_vad_v4.onnx",
"resources/models/silero_vad_v4.onnx",
tauri::path::BaseDirectory::Resource,
)?;
let whisper_path = app.path().resolve(
"resources/ggml-small.bin",
"resources/models/ggml-small.bin",
tauri::path::BaseDirectory::Resource,
)?;
@ -75,6 +98,14 @@ pub fn run() {
})
.on_window_event(|window, event| match event {
tauri::WindowEvent::CloseRequested { api, .. } => {
#[cfg(target_os = "macos")]
let res = window
.app_handle()
.set_activation_policy(tauri::ActivationPolicy::Accessory);
if let Err(e) = res {
println!("Failed to set activation policy: {}", e);
}
api.prevent_close();
// TODO may be different on windows, this works for macos

View file

@ -1,6 +1,8 @@
use std::sync::Arc;
use serde::Serialize;
use tauri::image::Image;
use tauri::tray::TrayIcon;
use tauri::App;
use tauri::AppHandle;
use tauri::Manager;
@ -14,11 +16,37 @@ use crate::settings::ShortcutBinding;
use crate::utils;
fn transcribe_pressed(app: &AppHandle) {
let tray = app.state::<TrayIcon>();
tray.set_icon(Some(
Image::from_path(
app.path()
.resolve(
"resources/tray_recording_64x64.png",
tauri::path::BaseDirectory::Resource,
)
.expect("failed to resolve"),
)
.expect("failed to set icon"),
));
let rm = app.state::<Arc<AudioRecordingManager>>();
rm.try_start_recording("transcribe");
}
fn transcribe_released(app: &AppHandle) {
let tray = app.state::<TrayIcon>();
tray.set_icon(Some(
Image::from_path(
app.path()
.resolve(
"resources/tray_64x64.png",
tauri::path::BaseDirectory::Resource,
)
.expect("failed to resolve"),
)
.expect("failed to set icon"),
));
let ah = app.clone();
let rm = Arc::clone(&app.state::<Arc<AudioRecordingManager>>());
let tm = Arc::clone(&app.state::<Arc<TranscriptionManager>>());

View file

@ -19,15 +19,12 @@
],
"security": {
"csp": null
},
"trayIcon": {
"iconPath": "icons/tray_64x64.png"
}
},
"bundle": {
"active": true,
"targets": "all",
"resources": ["resources/*"],
"resources": ["resources/**/*"],
"icon": [
"icons/32x32.png",
"icons/128x128.png",

View file

@ -8,6 +8,24 @@ import {
import { register } from "@tauri-apps/plugin-global-shortcut";
import HandyTextLogo from "./components/icons/HandyTextLogo";
import { invoke } from "@tauri-apps/api/core";
// import { TrayIcon } from "@tauri-apps/api/tray";
// import { Menu } from "@tauri-apps/api/menu";
// import { defaultWindowIcon } from "@tauri-apps/api/app";
// const menu = await Menu.new({
// items: [
// {
// id: "quit",
// text: "Quit",
// },
// ],
// });
// const options = {
// icon: await defaultWindowIcon(),
// menu,
// menuOnLeftClick: true,
// };
function App() {
const [hasAccessibility, setHasAccessibility] = useState(false);
@ -23,6 +41,10 @@ function App() {
setHasAccessibility(hasPermissions);
});
// TrayIcon.new(options).then((t) => {
// console.log("tray init", t);
// });
// invoke("set_binding", {
// id: "test",
// binding: "alt+d",