From 38887dd4f848523756983ba39a50c7045842341a Mon Sep 17 00:00:00 2001 From: Thomas Queste Date: Thu, 2 Feb 2023 08:51:14 +0100 Subject: [PATCH] fix: remove sound notification (random crash with Alsa on Linux) --- go.mod | 3 --- go.sum | 5 ----- ui/notify.go | 5 ----- ui/playback.go | 41 ----------------------------------------- 4 files changed, 54 deletions(-) delete mode 100644 ui/playback.go diff --git a/go.mod b/go.mod index d083c0d..b0bcdf2 100644 --- a/go.mod +++ b/go.mod @@ -7,15 +7,12 @@ require ( github.com/benbjohnson/clock v1.3.0 github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/hajimehoshi/go-mp3 v0.3.4 github.com/stretchr/testify v1.8.1 golang.org/x/sys v0.4.0 // indirect golang.org/x/text v0.6.0 // indirect; indirect-- gopkg.in/yaml.v3 v3.0.1 // indirect ) -require github.com/hajimehoshi/oto/v2 v2.3.1 - require ( fyne.io/systray v1.10.1-0.20221115204952-d16a6177e6f1 // indirect github.com/benoitkugler/textlayout v0.3.0 // indirect diff --git a/go.sum b/go.sum index f9a82b9..0dd4073 100644 --- a/go.sum +++ b/go.sum @@ -190,10 +190,6 @@ github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfre github.com/goxjs/gl v0.0.0-20210104184919-e3fafc6f8f2a/go.mod h1:dy/f2gjY09hwVfIyATps4G2ai7/hLwLkc5TrPqONuXY= github.com/goxjs/glfw v0.0.0-20191126052801-d2efb5f20838/go.mod h1:oS8P8gVOT4ywTcjV6wZlOU4GuVFQ8F5328KY3MJ79CY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hajimehoshi/go-mp3 v0.3.4 h1:NUP7pBYH8OguP4diaTZ9wJbUbk3tC0KlfzsEpWmYj68= -github.com/hajimehoshi/go-mp3 v0.3.4/go.mod h1:fRtZraRFcWb0pu7ok0LqyFhCUrPeMsGRSVop0eemFmo= -github.com/hajimehoshi/oto/v2 v2.3.1 h1:qrLKpNus2UfD674oxckKjNJmesp9hMh7u7QCrStB3Rc= -github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -504,7 +500,6 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/ui/notify.go b/ui/notify.go index 799bbbe..a0661cf 100644 --- a/ui/notify.go +++ b/ui/notify.go @@ -14,9 +14,4 @@ func notifyPomodoroDone(kind pomodoro.Kind) { if err != nil { log.Printf("unable to notify: %v\n", err) } - - err = playNotificationSound() - if err != nil { - log.Printf("unable to play notification sound: %v\n", err) - } } diff --git a/ui/playback.go b/ui/playback.go deleted file mode 100644 index 6abfd59..0000000 --- a/ui/playback.go +++ /dev/null @@ -1,41 +0,0 @@ -package ui - -import ( - "fmt" - "github.com/hajimehoshi/go-mp3" - "github.com/hajimehoshi/oto/v2" - "os" -) - -func playNotificationSound() error { - fileName := "/usr/share/fynodoro/notification.mp3" - f, err := os.Open(fileName) - if err != nil { - return fmt.Errorf("unable to read %s: %w", fileName, err) - } - - decoder, err := mp3.NewDecoder(f) - if err != nil { - return fmt.Errorf("unable to decode %s: %w", fileName, err) - } - - context, ready, err := oto.NewContext(decoder.SampleRate(), 2, 2) - if err != nil { - return fmt.Errorf("unable to create oto context: %w", err) - } - <-ready - - go func() { - player := context.NewPlayer(decoder) - defer func() { - err = player.Close() - }() - - player.Play() - }() - if err != nil { - return fmt.Errorf("unable to play: %w", err) - } - - return nil -}