Toggle the Comet when pressing F12

This commit is contained in:
Héctor Ramón Jiménez 2024-05-11 12:25:44 +02:00
parent fc53a97831
commit b7c65c877d
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
9 changed files with 125 additions and 35 deletions

View file

@ -9,7 +9,9 @@ pub fn init(name: &str) {
internal::init(name);
}
pub fn open_comet() {}
pub fn toggle_comet() {
internal::toggle_comet();
}
pub fn log_message(_message: &impl std::fmt::Debug) {}
@ -65,6 +67,7 @@ mod internal {
use beacon::span;
use once_cell::sync::Lazy;
use std::process;
use std::sync::atomic::{self, AtomicBool};
use std::sync::RwLock;
@ -72,6 +75,18 @@ mod internal {
name.clone_into(&mut NAME.write().expect("Write application name"));
}
pub fn toggle_comet() {
if BEACON.is_connected() {
BEACON.quit();
} else {
let _ = process::Command::new("iced_comet")
.stdin(process::Stdio::null())
.stdout(process::Stdio::null())
.stderr(process::Stdio::null())
.spawn();
}
}
pub fn theme_changed(f: impl FnOnce() -> Option<theme::Palette>) {
let Some(palette) = f() else {
return;
@ -166,6 +181,8 @@ mod internal {
pub fn init(_name: &str) {}
pub fn toggle_comet() {}
pub fn theme_changed(_f: impl FnOnce() -> Option<theme::Palette>) {}
pub fn boot() -> Span {