Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
745 changes: 7 additions & 738 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ hypr-audio = { path = "../../../crates/audio", package = "audio" }
hypr-cloud = { path = "../../../crates/cloud", package = "cloud" }
hypr-calendar = { path = "../../../crates/calendar", package = "calendar" }

tauri = { workspace = true, features = ["tray-icon", "devtools"] }
tauri = { workspace = true, features = ["tray-icon", "image-png", "devtools"] }
tauri-plugin-updater = "2"
tauri-plugin-fs = "2"
tauri-plugin-positioner = "2"
Expand All @@ -36,6 +36,7 @@ tauri-plugin-global-shortcut = "2"
tauri-plugin-store = "2"
tauri-plugin-notification = "2"
tauri-plugin-autostart = "2"
tauri-plugin-shell = "2"

specta = { workspace = true }
specta-typescript = { workspace = true }
Expand All @@ -56,5 +57,3 @@ futures = "0.3.31"
flume = "0.11.1"
objc = "0.2.7"
cap-media = { workspace = true }
tauri-plugin-stronghold = "2.2.0"
tauri-plugin-shell = "2.2.0"
1 change: 0 additions & 1 deletion apps/desktop/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"sql:default",
"sql:allow-execute",
"store:default",
"stronghold:default",
"shell:allow-open"
]
}
Binary file added apps/desktop/src-tauri/icons/tray_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/desktop/src-tauri/icons/tray_recording.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions apps/desktop/src-tauri/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use serde::{Deserialize, Serialize};
use specta::Type;
use std::path::PathBuf;
use tauri_specta::Event;

#[derive(Debug, Clone, Serialize, Deserialize, Type, Event)]
Expand All @@ -10,3 +11,11 @@ pub struct NotAuthenticated;

#[derive(Debug, Clone, Serialize, Deserialize, Type, Event)]
pub struct JustAuthenticated;

#[derive(Debug, Clone, Serialize, Deserialize, Type, Event)]
pub struct RecordingStarted;

#[derive(Debug, Clone, Serialize, Deserialize, Type, Event)]
pub struct RecordingStopped {
path: PathBuf,
}
35 changes: 19 additions & 16 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod db;
mod events;
mod permissions;
mod session;
mod tray;

pub struct App {
handle: AppHandle,
Expand Down Expand Up @@ -134,6 +135,10 @@ pub fn run() {
let handler = specta_builder.invoke_handler();
move |invoke| handler(invoke)
})
.setup(move |app| {
specta_builder.mount_events(app);
Ok(())
})
.setup(move |app| {
let app = app.handle().clone();

Expand All @@ -150,25 +155,18 @@ pub fn run() {
cloud_config.auth_token = Some(auth.token);
}

app.manage(RwLock::new(App {
handle: app.clone(),
audio_input_tx,
audio_input_feed: None,
cloud_config,
}));
// These MUST be called before anything else!
{
app.manage(RwLock::new(App {
handle: app.clone(),
audio_input_tx,
audio_input_feed: None,
cloud_config,
}));
}

Ok(())
})
.setup(|app| {
let salt_path = app.path().app_local_data_dir()?.join("salt.txt");
app.handle()
.plugin(tauri_plugin_stronghold::Builder::with_argon2(&salt_path).build())?;
Ok(())
})
.setup(move |app| {
specta_builder.mount_events(app);
Ok(())
})
.setup(|app| {
#[cfg(desktop)]
let _ = app
Expand All @@ -192,6 +190,11 @@ pub fn run() {
}
Ok(())
})
.setup(|app| {
let app = app.handle().clone();
tray::create_tray(&app).unwrap();
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
87 changes: 87 additions & 0 deletions apps/desktop/src-tauri/src/tray.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// https://github.com/CapSoftware/Cap/blob/8671050aaff780f658507579e7d1d75e7ee25d59/apps/desktop/src-tauri/src/tray.rs

// use crate::events::{RecordingStarted, RecordingStopped};
use tauri::{
image::Image,
menu::{Menu, MenuId, MenuItem, PredefinedMenuItem},
tray::TrayIconBuilder,
AppHandle, Manager, Result,
};
// use tauri_specta::Event;

pub enum TrayItem {
Open,
Quit,
}

impl From<TrayItem> for MenuId {
fn from(value: TrayItem) -> Self {
match value {
TrayItem::Open => "open_hypr",
TrayItem::Quit => "quit_hypr",
}
.into()
}
}

impl From<MenuId> for TrayItem {
fn from(value: MenuId) -> Self {
match value.0.as_str() {
"open_hypr" => TrayItem::Open,
"quit_hypr" => TrayItem::Quit,
_ => unreachable!(),
}
}
}

pub fn create_tray(app: &AppHandle) -> Result<()> {
let menu = Menu::with_items(
app,
&[
&MenuItem::with_id(app, TrayItem::Open, "Open", true, None::<&str>)?,
&PredefinedMenuItem::separator(app)?,
&MenuItem::with_id(app, TrayItem::Quit, "Quit", true, None::<&str>)?,
],
)?;

let app = app.clone();

TrayIconBuilder::with_id("hypr-tray")
.icon(Image::from_bytes(include_bytes!(
"../icons/tray_default.png"
))?)
.icon_as_template(true)
.menu(&menu)
.menu_on_left_click(true)
.on_menu_event({
move |app: &AppHandle, event| match TrayItem::from(event.id) {
TrayItem::Open => {
if let Some(window) = app.get_webview_window("main") {
window.show().unwrap();
window.set_focus().unwrap();
}
}
TrayItem::Quit => {
app.exit(0);
}
}
})
.on_tray_icon_event({
let app_handle = app.clone();
move |tray, event| {}
})
.build(&app)
.unwrap();

// RecordingStarted::listen_any(&app, {
// let app = app.clone();
// move |_| {}
// });

// RecordingStopped::listen_any(&app, {
// let app = app.clone();
// move |_| {}
// });

Ok(())
}