Bel LaPointe 2024-10-31 14:26:43 -06:00
parent 4e85f48d9e
commit ca20b2a052
1 changed files with 4 additions and 7 deletions

11
main.go
View File

@ -14,7 +14,6 @@ import (
"time"
"github.com/gen2brain/beeep"
"github.com/schollz/progressbar/v3"
)
func main() {
@ -74,24 +73,22 @@ func alertAfter(ctx context.Context, ntfy string, duration string) error {
}
func alertAt(ctx context.Context, ntfy string, deadline time.Time, title, msg string) error {
n := int64(time.Until(deadline) / time.Second)
bar := progressbar.Default(n)
// n := int64(time.Until(deadline) / time.Second)
c := time.NewTicker(time.Second)
defer c.Stop()
func() {
ctx, can := context.WithDeadline(ctx, deadline)
defer can()
for {
for ctx.Err() == nil {
select {
case <-c.C:
case <-ctx.Done():
return
}
bar.Add(1)
fmt.Printf("\r%s ", deadline.Sub(time.Now()))
}
}()
bar.Finish()
bar.Exit()
fmt.Println()
if err := ctx.Err(); err == nil {
beeep.Alert(title, msg, "/dev/null")