beeep Go Library

repository·master·Indexed 23 days ago

https://github.com/gen2brain/beeep

A 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.

Tokens
493
Snippets
4
Records
7
Agent score
33%

What's inside beeep

  1. Send a desktop alert with beeep.Alert

    master

    Use 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)
    }
  2. Send a desktop notification with beeep.Notify

    master

    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)
    }
  3. Set the application name with AppName

    master
    The 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".
  4. Handle unsupported operating systems with ErrUnsupported

    master
    If the current operating system is not supported by the beeep library, the package returns ErrUnsupported. You can check for this error to provide fallback behavior or graceful degradation.