Skip to main content

Crate awase

Crate awase 

Source
Expand description

Awase (合わせ) — global hotkey abstraction.

Provides platform-agnostic types and traits for global hotkey registration, mode systems, key chords, conditional bindings, and key remapping. macOS and Linux backends can be added as separate feature-gated modules.

§Quick Start

use awase::{Hotkey, Modifiers, Key, NoopManager, HotkeyManager};
use awase::{Action, Binding, Condition};

// Parse hotkeys in plus-separated or skhd format
let hk = Hotkey::parse("cmd+space").unwrap();
let hk2 = Hotkey::parse("cmd - h").unwrap(); // skhd style

// Create bindings with actions and conditions
let binding = Binding::new(hk, Action::command("launcher_toggle"))
    .with_condition(Condition {
        app_exclude: Some("com.apple.Terminal".to_string()),
        ..Default::default()
    });

// Use the hotkey manager
let mut manager = NoopManager::new();
manager.register(1, hk).unwrap();
manager.unregister(1).unwrap();

Re-exports§

pub use action::Action;
pub use binding::Binding;
pub use chord::ChordState;
pub use chord::KeyChord;
pub use condition::Condition;
pub use condition::MatchContext;
pub use conflict::detect_conflicts;
pub use conflict::ConflictEntry;
pub use conflict::ConflictReport;
pub use mode::BindingMap;
pub use mode::KeyMode;
pub use mode::MatchResult;
pub use remap::KeyRemap;
pub use repeat_gate::KeyRepeatGate;
pub use repeat_gate::DEFAULT_MIN_INTERVAL;

Modules§

action
binding
chord
condition
conflict
macos
macOS-specific hotkey backend.
mode
remap
repeat_gate
KeyRepeatGate<K> — debouncer for OS key-repeat storms.

Macros§

atlas_chord
Sugar over atlas_hotkey that auto-stringifies the field name as the intent label. Consumer code becomes:

Structs§

Hotkey
A hotkey: a combination of modifier keys and a single key.
Modifiers
Modifier key flags. Uses a bitmask internally.
NoopManager
A no-op hotkey manager for testing and platforms without hotkey support.

Enums§

AwaseError
Errors from the hotkey system.
Key
A keyboard key.

Traits§

HotkeyManager
Trait for platform-specific hotkey registration.

Functions§

atlas_hotkey
Resolve an atlas chord into a typed Hotkey, panicking with a labelled message on parse failure. The two-string call form (atlas_hotkey(kb.copy, "copy")) is what hand-written default_bindings() functions reach for; the [atlas_chord!] macro generates that exact call from a single field access.