Skip to content

Commit

Permalink
feat: Add bell_command option
Browse files Browse the repository at this point in the history
  • Loading branch information
4513ECHO committed Apr 8, 2024
1 parent 270e741 commit 8998412
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/window/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct WindowSettings {
pub input_ime: bool,
pub unlink_border_highlights: bool,
pub show_border: bool,
pub bell_command: String,

#[option = "mousemoveevent"]
pub mouse_move_event: bool,
Expand Down Expand Up @@ -65,6 +66,7 @@ impl Default for WindowSettings {
observed_columns: None,
unlink_border_highlights: true,
show_border: false,
bell_command: "".to_string(),
}
}
}
25 changes: 18 additions & 7 deletions src/window/window_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,24 @@ impl WinitWindowWrapper {
self.mouse_manager.enabled = mouse_enabled
}
WindowCommand::ListAvailableFonts => self.send_font_names(),
WindowCommand::Bell => unsafe {
// TODO: How to bell on X11/Wayland?
#[cfg(target_os = "macos")]
NSBeep();
#[cfg(target_os = "windows")]
MessageBeep(MB_OK);
},
WindowCommand::Bell => {
let bell_command = SETTINGS.get::<WindowSettings>().bell_command;
let bell_command = bell_command.split(" ").collect::<Vec<_>>();
if bell_command.is_empty() {
unsafe {
// TODO: How to bell on X11/Wayland?
#[cfg(target_os = "macos")]
NSBeep();
#[cfg(target_os = "windows")]
MessageBeep(MB_OK);
}
} else {
let _ = std::process::Command::new(&bell_command[0])
.args(&bell_command[1..])
.spawn()
.unwrap();
}
}
WindowCommand::FocusWindow => {
self.skia_renderer.window().focus_window();
}
Expand Down

0 comments on commit 8998412

Please sign in to comment.