aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/aerc.go
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-07-29 10:50:02 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-29 15:01:49 -0400
commit152f8c9519ac1b7b35c3789b03f3d1cc3b1e8881 (patch)
tree0c8693aa2651955d0e12f090f5469c7183e190d3 /widgets/aerc.go
parent2804f000017c0ef6bcaf8d571627fa08784f48ac (diff)
downloadaerc-152f8c9519ac1b7b35c3789b03f3d1cc3b1e8881.tar.gz
Ring bell when new messages arrive0.2.0
Add a "new-message-bell" option to the UI section of aerc.conf. A new hook into the message store allows the msglist widget to detect new messages being added to the displayed list. When new messages are delivered, and the new-message-bell option is enabled (as it is by default), the terminal will beep.
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r--widgets/aerc.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 90b56c82..23dac3e2 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -30,6 +30,7 @@ type Aerc struct {
statusline *StatusLine
pendingKeys []config.KeyStroke
tabs *libui.Tabs
+ beep func() error
}
func NewAerc(conf *config.AercConfig, logger *log.Logger,
@@ -84,6 +85,20 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger,
return aerc
}
+func (aerc *Aerc) OnBeep(f func() error) {
+ aerc.beep = f
+}
+
+func (aerc *Aerc) Beep() {
+ if aerc.beep == nil {
+ aerc.logger.Printf("should beep, but no beeper")
+ return
+ }
+ if err := aerc.beep(); err != nil {
+ aerc.logger.Printf("tried to beep, but could not: %v", err)
+ }
+}
+
func (aerc *Aerc) Tick() bool {
more := false
for _, acct := range aerc.accounts {