vendor/github.com/gen2brain/beeep/alert_windows.go

22 lines · 586 bytes

 1//go:build windows && !linux && !freebsd && !netbsd && !openbsd && !darwin && !js
 2// +build windows,!linux,!freebsd,!netbsd,!openbsd,!darwin,!js
 3
 4package beeep
 5
 6import (
 7	toast "github.com/go-toast/toast"
 8)
 9
10// Alert displays a desktop notification and plays a default system sound.
11func Alert(title, message, appIcon string) error {
12	if isWindows10 {
13		note := toastNotification(title, message, pathAbs(appIcon))
14		note.Audio = toast.Default
15		return note.Push()
16	}
17
18	if err := Notify(title, message, appIcon); err != nil {
19		return err
20	}
21	return Beep(DefaultFreq, DefaultDuration)
22}