summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2022-06-29 18:12:32 +0300
committerdelthas <delthas@dille.cc>2022-08-01 02:54:30 +0200
commite8ed8e7e13134ee7fc8ac116d58efc55813632a1 (patch)
tree672ff545386a4b9cd2c0bc0516d7362e6242f62d
parentAdd support for hex colors (diff)
Add a config option to beep on highlight
This will allow to bring user attention when you are getting highlighted.
-rw-r--r--app.go4
-rw-r--r--config.go11
-rw-r--r--doc/senpai.5.scd6
-rw-r--r--ui/ui.go4
4 files changed, 24 insertions, 1 deletions
diff --git a/app.go b/app.go
index 2aaa486..a87df2d 100644
--- a/app.go
+++ b/app.go
@@ -978,6 +978,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.OnHighlightBeep {
+ app.win.Beep()
+ }
+
path := app.cfg.OnHighlightPath
if path == "" {
defaultHighlightPath, err := DefaultHighlightPath()
diff --git a/config.go b/config.go
index 7823ae7..2450e75 100644
--- a/config.go
+++ b/config.go
@@ -63,6 +63,7 @@ type Config struct {
Highlights []string
OnHighlightPath string
+ OnHighlightBeep bool
NickColWidth int
ChanColWidth int
ChanColEnabled bool
@@ -96,6 +97,7 @@ func Defaults() (cfg Config, err error) {
Mouse: true,
Highlights: nil,
OnHighlightPath: "",
+ OnHighlightBeep: false,
NickColWidth: 14,
ChanColWidth: 16,
ChanColEnabled: true,
@@ -197,6 +199,15 @@ func unmarshal(filename string, cfg *Config) (err error) {
if err := d.ParseParams(&cfg.OnHighlightPath); err != nil {
return err
}
+ case "on-highlight-beep":
+ var onHighlightBeep string
+ if err := d.ParseParams(&onHighlightBeep); err != nil {
+ return err
+ }
+
+ if cfg.OnHighlightBeep, err = strconv.ParseBool(onHighlightBeep); 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 a8bd9c3..d8f04f6 100644
--- a/doc/senpai.5.scd
+++ b/doc/senpai.5.scd
@@ -44,7 +44,7 @@ Some settings are required, the others are optional.
used for login.
*channel*
- A spaced separated list of channel names that senpai will automatically join
+ A space separated list of channel names that senpai will automatically join
at startup and server reconnect. This directive can be specified multiple
times.
@@ -55,6 +55,10 @@ Some settings are required, the others are optional.
By default, senpai will use your current nickname.
+*on-highlight-beep*
+ Enable sending the bell character (BEL) when you are highlighted.
+ Defaults to disabled.
+
*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 7ae13e2..4866969 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -421,6 +421,10 @@ func (ui *UI) Size() (int, int) {
return ui.screen.Size()
}
+func (ui *UI) Beep() {
+ ui.screen.Beep()
+}
+
func (ui *UI) Draw(members []irc.Member) {
w, h := ui.screen.Size()