Install beeep via Go
masterTo use the beeep library in your Go project, install it using the following command:
go get -u github.com/gen2brain/beeeprepository·master·Indexed 23 days ago
https://github.com/gen2brain/beeepA cross-platform Go library for sending desktop notifications, alerts, and playing audible beeps. Features include beeep.Notify for basic notifications, beeep.Alert for notifications with file-path icons, and beeep.Beep for audible alerts.
To use the beeep library in your Go project, install it using the following command:
go get -u github.com/gen2brain/beeepUse beeep.Alert to send a notification that typically includes an icon from a file path. You can also set a global beeep.AppName to identify your application in the notification.
beeep.AppName = "My App Name"
err := beeep.Alert("Title", "Message body", "testdata/warning.png")
if err != nil {
panic(err)
}Use beeep.Beep to play an audible alert. It requires a frequency and a duration.
err := beeep.Beep(beeep.DefaultFreq, beeep.DefaultDuration)
if err != nil {
panic(err)
}Use beeep.Notify to send a desktop notification. It accepts a title, a message body, and an optional icon as a byte slice ([]byte).
//go:embed testdata/info.png
var icon []byte
err := beeep.Notify("Title", "Message body", icon)
if err != nil {
panic(err)
}You can use build tags to modify how beeep interacts with the system:
nodbus: Disables godbus/dbus and forces the library to use only notify-send for notifications.AppName variable defines the formal name of your application that appears in desktop notifications. It is recommended to use the application's formal name rather than a technical ID. By default, it is set to "DefaultAppName".beeep library, the package returns ErrUnsupported. You can check for this error to provide fallback behavior or graceful degradation.