Files
spaceshell/app/src-tauri/src/lib.rs
T

56 lines
1.9 KiB
Rust

mod bridge;
use tauri::Manager;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_notification::init())
.setup(|app| {
let handle = app.handle().clone();
// Connect the bridge on a tokio runtime, then manage it.
tauri::async_runtime::block_on(async move {
match bridge::Bridge::connect(handle.clone()).await {
Ok(bridge) => {
handle.manage(bridge);
}
// Don't crash the app — open the window and log. Commands will
// error until a daemon is reachable; start it manually
// (./target/debug/spaceshd) or set SPACESHD_BIN / SPACESH_SOCK.
Err(e) => {
eprintln!(
"spacesh: could not connect to spaceshd: {e}\
start it manually or set SPACESHD_BIN/SPACESH_SOCK"
);
}
}
});
Ok(())
})
.invoke_handler(tauri::generate_handler![
bridge::open,
bridge::new_surface,
bridge::input,
bridge::resize,
bridge::attach,
bridge::detach,
bridge::status,
bridge::close_surface,
bridge::split_surface,
bridge::set_ratios,
bridge::move_surface,
bridge::apply_preset,
bridge::restart_surface,
bridge::close_workspace,
bridge::set_workspace_meta,
bridge::create_group,
bridge::set_group,
bridge::delete_group,
bridge::focus,
bridge::event_log,
bridge::mark_read,
])
.run(tauri::generate_context!())
.expect("error while running spacesh");
}