core: add 'command finished' notifications

Fixes #8991

Uses OSC 133 esc sequences to keep track of how long commands take to
execute. If the user chooses, commands that take longer than a user
specified limit will trigger a notification. The user can choose between
a bell notification or a desktop notification.
This commit is contained in:
Jeffrey C. Ollie
2025-10-01 23:48:08 -05:00
parent 9c8d2e577e
commit 07124dba64
12 changed files with 366 additions and 25 deletions

View File

@@ -295,6 +295,9 @@ pub const Action = union(Key) {
/// Show the on-screen keyboard.
show_on_screen_keyboard,
/// A command has finished,
command_finished: CommandFinished,
/// Sync with: ghostty_action_tag_e
pub const Key = enum(c_int) {
quit,
@@ -350,6 +353,7 @@ pub const Action = union(Key) {
show_child_exited,
progress_report,
show_on_screen_keyboard,
command_finished,
};
/// Sync with: ghostty_action_u
@@ -741,3 +745,21 @@ pub const CloseTabMode = enum(c_int) {
/// Close all other tabs.
other,
};
pub const CommandFinished = struct {
exit_code: ?u8,
duration: configpkg.Config.Duration,
/// sync with ghostty_action_command_finished_s in ghostty.h
pub const C = extern struct {
exit_code: i16,
duration: u64,
};
pub fn cval(self: CommandFinished) C {
return .{
.exit_code = self.exit_code orelse -1,
.duration = self.duration.duration,
};
}
};