-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathalert_windows.go
More file actions
43 lines (36 loc) · 776 Bytes
/
Copy pathalert_windows.go
File metadata and controls
43 lines (36 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//go:build windows && !linux && !freebsd && !netbsd && !openbsd && !darwin && !js
package beeep
import (
"fmt"
"os"
"time"
)
// Alert displays a desktop notification and plays a default system sound.
func Alert(title, message string, icon any) error {
var img string
switch i := icon.(type) {
case string:
img = i
case []byte:
var err error
img, err = bytesToFilename(i)
if err != nil {
return err
}
defer os.Remove(img)
default:
return fmt.Errorf("unsupported argument: %T", icon)
}
if isWindows10 {
if err := toastNotify(title, message, img, true); err != nil {
return err
}
time.Sleep(time.Millisecond * 100)
} else {
if err := balloonNotify(title, message, img); err != nil {
return err
}
}
messageBeep()
return nil
}