Files
VoelinClient/crates/tsc-platform/src/lib.rs
T
Claude edb9c0a958 tsc-platform: global push-to-talk hotkeys, notifications, app directories
- hotkey: HotkeyManager picks a backend and register() returns a stream of
  Pressed/Released events:
  - xdg-desktop-portal GlobalShortcuts through ashpd (Wayland; Activated /
    Deactivated; the portal owns the binding, ours is the preferred trigger)
  - X11 XInput2 raw key/button events on the root window (no grab, the key
    still reaches the focused app); tested under Xvfb with XTEST input
  - Windows low-level keyboard and mouse hooks on a dedicated thread (the
    crate's only unsafe code, in one module)
  Hotkey/Key/Modifiers parse and serialize as "Ctrl+Shift+T", "F13",
  "RightCtrl", "MouseBack", with X11 keysym, Windows VK and xdg names.
- notify: desktop notifications through notify-rust (D-Bus / toasts)
- paths: data/config/cache/state dirs under "tsc" (as the desktop app
  already uses), TSC_*_DIR overrides, Flatpak and display server detection

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-26 04:56:23 +00:00

35 lines
1.0 KiB
Rust

//! Desktop integration.
//!
//! - [`hotkey`]: global push-to-talk hotkeys with press and release events
//! (xdg-desktop-portal on Wayland, XInput2 on X11, a keyboard hook on
//! Windows)
//! - [`notify`]: desktop notifications
//! - [`paths`]: data, config, cache and state directories
pub mod hotkey;
pub mod notify;
pub mod paths;
pub use hotkey::{BackendKind, Hotkey, HotkeyEvent, HotkeyEvents, HotkeyManager, Key, Modifiers};
pub use notify::{Notification, notify};
/// Application id: desktop file, icon, portal registrations. A placeholder
/// until the product has a name.
pub const APP_ID: &str = "io.github.faumaray.TsClient";
/// Name shown in notifications. A placeholder until the product has a name.
pub const APP_NAME: &str = "TS Client";
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid hotkey: {0}")]
InvalidHotkey(String),
#[error("not supported: {0}")]
Unsupported(String),
#[error("{0}")]
Backend(String),
#[error("notification: {0}")]
Notification(String),
}
pub type Result<T> = std::result::Result<T, Error>;