Files
cinny-desktop/src-tauri/src/native/mod.rs
T
jared 22f8e1566c
Build Lotus Chat Desktop / prepare (push) Successful in 3s
Build Lotus Chat Desktop / build-windows (push) Successful in 23m43s
Build Lotus Chat Desktop / build-linux (push) Successful in 23m57s
Build Lotus Chat Desktop / update-manifest (push) Successful in 4s
feat(native): Linux parity + autostart + tray DND (P6-1; no macOS)
Rounds out the native app on Linux (Windows features kept; macOS stays no-op):
- power.rs: no-sleep during calls on Linux via a zbus org.freedesktop.ScreenSaver
  Inhibit/UnInhibit (cookie held in ScreenSaverInhibit managed state).
- set_badge_count: Linux launcher badge via the Unity
  com.canonical.Unity.LauncherEntry.Update D-Bus signal (best-effort; app_uri
  = cinny.desktop per Tauri's mainBinaryName naming).
- tauri-plugin-autostart registered (+ autostart:allow-enable/disable/is-enabled
  capabilities); web toggles it from Settings.
- Tray "Do Not Disturb" CheckMenuItem → emits lotus-dnd-changed to the web,
  which ORs it into the notification quiet-gate.

zbus 5 (Linux target dep; blocking-api default). CI-compile-verified
(windows+linux); reviewer confirmed no build-breakers. Runtime to check on
Linux: DND toggle polarity, badge .desktop id.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 15:18:28 -04:00

44 lines
1.6 KiB
Rust

//! Native desktop feature modules (Lotus Chat).
//!
//! Each feature lives in its own submodule exposing `#[tauri::command]`(s) and,
//! when it needs to register listeners/state, a `setup(&AppHandle)`. lib.rs adds
//! the commands to `generate_handler!` and calls `native::setup()` once during
//! app setup. Windows-only pieces are guarded with `#[cfg(target_os = "windows")]`
//! and compile-verified in CI (Gitea `windows` runner / GitHub `windows-latest`).
use tauri::{AppHandle, Manager};
pub mod chrome;
pub mod focus_assist;
pub mod jumplist;
pub mod network;
pub mod power;
pub mod smtc;
pub mod thumbbar;
pub mod toast;
/// Dispatch a DOM `CustomEvent` to the web client (mirrors `forward_deeplink` in
/// lib.rs) so native modules can push data to the frontend without pulling in
/// `@tauri-apps/api` on the web side. `detail_json` MUST be valid JSON (use
/// `serde_json::to_string`). `event` is a static, trusted name.
#[allow(dead_code)]
pub fn emit_to_web(app: &AppHandle, event: &str, detail_json: &str) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.eval(&format!(
"window.dispatchEvent(new CustomEvent('{event}',{{detail:{detail_json}}}))"
));
}
}
/// Called once from lib.rs `.setup()`. Feature modules that need to register OS
/// listeners or managed state get initialized here. (jumplist/chrome are
/// command-only and need no setup.)
pub fn setup(app: &AppHandle) -> tauri::Result<()> {
power::setup(app)?;
thumbbar::setup(app)?;
smtc::setup(app)?;
network::setup(app)?;
focus_assist::setup(app)?;
Ok(())
}