This will allow to bring user attention when you are getting
highlighted.
---
This should bring parity with other applications that request user
attention, since BEL is what is usually used for and reliable.
Using OnHighlightPath isn't really a convinient way to do so, since
it'll require arbitrary writing to PTY which could break rendering given
that BEL is also an escape sequence terminator.
app.go | 4 ++++config.go | 11 +++++++++++doc/senpai.5.scd | 5 +++++ui/ui.go | 4 ++++
4 files changed, 24 insertions(+)
diff --git a/app.go b/app.go
index 9f86b99..8995011 100644
--- a/app.go+++ b/app.go
@@ -975,6 +975,10 @@ func (app *App) isHighlight(s *irc.Session, content string) bool {
// notifyHighlight executes the script at "on-highlight-path" according to the given
// message context.
func (app *App) notifyHighlight(buffer, nick, content string) {
+ if app.cfg.Beep {+ app.win.Beep();+ }+ path := app.cfg.OnHighlightPath
if path == "" {
defaultHighlightPath, err := DefaultHighlightPath()
diff --git a/config.go b/config.go
index 5ac2a8a..af3fd40 100644
--- a/config.go+++ b/config.go
@@ -63,6 +63,7 @@ type Config struct {
Highlights []string
OnHighlightPath string
+ Beep bool NickColWidth int
ChanColWidth int
ChanColEnabled bool
@@ -95,6 +96,7 @@ func Defaults() (cfg Config, err error) {
Mouse: true,
Highlights: nil,
OnHighlightPath: "",
+ Beep: true, NickColWidth: 14,
ChanColWidth: 16,
ChanColEnabled: true,
@@ -195,6 +197,15 @@ func unmarshal(filename string, cfg *Config) (err error) {
if err := d.ParseParams(&cfg.OnHighlightPath); err != nil {
return err
}
+ case "beep":+ var beep string+ if err := d.ParseParams(&beep); err != nil {+ return err+ }++ if cfg.Beep, err = strconv.ParseBool(beep); err != nil {+ return err+ } case "pane-widths":
for _, child := range d.Children {
switch child.Name {
diff --git a/doc/senpai.5.scd b/doc/senpai.5.scd
index ec6bea5..917dfbf 100644
--- a/doc/senpai.5.scd+++ b/doc/senpai.5.scd
@@ -55,6 +55,11 @@ Some settings are required, the others are optional.
By default, senpai will use your current nickname.
+*beep*+ Send BEL when you are highlighted.++ By default, senpai will send BEL on highlight.+*on-highlight-path*
Alternative path to a shell script to be executed when you are highlighted.
By default, senpai looks for a highlight shell script at
diff --git a/ui/ui.go b/ui/ui.go
index 77757cb..0fa8663 100644
--- a/ui/ui.go+++ b/ui/ui.go
@@ -413,6 +413,10 @@ func (ui *UI) Size() (int, int) {
return ui.screen.Size()
}
+func (ui *UI) Beep() error {+ return ui.screen.Beep()+}+func (ui *UI) Draw(members []irc.Member) {
w, h := ui.screen.Size()
--
2.35.1
Thanks!
Pushed with minor edits:
- use on-highlight-beep rather than beep
- disable this feature by default
To git.sr.ht:~taiite/senpai
f13aa04..e8ed8e7 master -> master