Some terminals (foot, kitty, urxvt, gnome-terminal) support OSC777 sequences.
This allows emitting notifications from a terminal, e.g.: via:
echo -e "\033]777;notify;senpai;You've been mentioned on IRC\a"
(Hint: if you're trying this for a first time, keep in mind that foot won't emit the notification if the emitting window is focused; just use sleep 2 && ... and focus something else).
The terminal emulator itself can then relay the notification to a local notification-daemon or anything else (foot makes this configurable). An interesting detail of this escape sequence is that it works over SSH. If I ssh onto a remote machine and run the above command on it, I'll see a notification on my local desktop.
I tried adding this to ~/.config/senpai/highlight and making it executable:
#!/bin/sh
# TODO: use $SENDER (but need to escape it properly)
echo -e "\033]777;notify;senpai;You've been mentioned on IRC\a"
However it doesn't work. If my understanding is correct, it doesn't work because the output of this echo command never reaches the terminal; senpai runs this script piping its output to /dev/null (I have confirmed that the script itself gets executed).
So I don't think this kind of integration is possible via the highlight script, leading me to the conclusion that this would need to be implemented in senpai itself. The following quick-and-dirty patch works:
diff --git a/app.go b/app.go
index 4e66fe5..aa4e573 100644
--- a/app.go
+++ b/app.go
@@ -1102,6 +1102,7 @@ func (app *App) notifyHighlight(buffer, nick, content string) {
app.win.Beep()
}
+ fmt.Print("\033]777;notify;senpai;You've been mentioned on IRC\a")
path := app.cfg.OnHighlightPath
if path == "" {
defaultHighlightPath, err := DefaultHighlightPath()
With it, if I'm mentioned on IRC, I'll get a notification, even via SSH. The downside is that this is a horrible patch, and this should ideally be configurable.
I'm happy to work further on this, but I'm opening this ticket at this stage to have some discussion on how to make this configurable (and I guess confirm that this is a desirable feature).
Relates to: https://github.com/gdamore/tcell/issues/499
On 1 July 2023 00:06:39 CEST, ~whynothugo outgoing@sr.ht wrote:
Some terminals (foot, kitty, urxvt, gnome-terminal) support OSC777 sequences.
This allows emitting notifications from a terminal, e.g.: via:
echo -e "\033]777;notify;senpai;You've been mentioned on IRC\a"(Hint: if you're trying this for a first time, keep in mind that
footwon't emit the notification if the emitting window is focused; just usesleep 2 && ...and focus something else).The terminal emulator itself can then relay the notification to a local notification-daemon or anything else (foot makes this configurable). An interesting detail of this escape sequence is that it works over SSH. If I ssh onto a remote machine and run the above command on it, I'll see a notification on my local desktop.
I tried adding this to
~/.config/senpai/highlightand making it executable:#!/bin/sh # TODO: use $SENDER (but need to escape it properly) echo -e "\033]777;notify;senpai;You've been mentioned on IRC\a"However it doesn't work. If my understanding is correct, it doesn't work because the output of this
echocommand never reaches the terminal;senpairuns this script piping its output to/dev/null(I have confirmed that the script itself gets executed).So I don't think this kind of integration is possible via the
highlightscript, leading me to the conclusion that this would need to be implemented insenpaiitself. The following quick-and-dirty patch works:diff --git a/app.go b/app.go index 4e66fe5..aa4e573 100644 --- a/app.go +++ b/app.go @@ -1102,6 +1102,7 @@ func (app *App) notifyHighlight(buffer, nick, content string) { app.win.Beep() } + fmt.Print("\033]777;notify;senpai;You've been mentioned on IRC\a") path := app.cfg.OnHighlightPath if path == "" { defaultHighlightPath, err := DefaultHighlightPath()With it, if I'm mentioned on IRC, I'll get a notification, even via SSH. The downside is that this is a horrible patch, and this should ideally be configurable.
I'm happy to work further on this, but I'm opening this ticket at this stage to have some discussion on how to make this configurable (and I guess confirm that this is a desirable feature).
Added (experimental) in https://git.sr.ht/~taiite/senpai/commit/0b5ceec2a1de0d3a5403cb8c232d29eddd9c3406