beeep

package module
v0.0.0-...-fa30c1b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2021 License: BSD-2-Clause Imports: 9 Imported by: 0

README

beeep

TravisCI Build Status AppVeyor Build Status GoDoc Go Report Card

beeep provides a cross-platform library for sending desktop notifications, alerts and beeps.

Installation

go get -u github.com/Quorin/beeep

Examples

err := beeep.Beep(beeep.DefaultFreq, beeep.DefaultDuration)
if err != nil {
    panic(err)
}
err := beeep.Notify("App name", "Title", "Message body", "assets/information.png")
if err != nil {
    panic(err)
}
err := beeep.Alert("App name", "Title", "Message body", "assets/warning.png")
if err != nil {
    panic(err)
}

macOS

For icons to show up when using Alert() or Notify(), you will need to bundle your application with a app icon.

More

For cross-platform dialogs and input boxes see dlgs.

Documentation

Overview

Package beeep provides a cross-platform library for sending desktop notifications and beeps.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// DefaultFreq - frequency, in Hz, middle A
	DefaultFreq = 440.0
	// DefaultDuration - duration in milliseconds
	DefaultDuration = 200
)
View Source
var (
	// ErrUnsupported is returned when operating system is not supported.
	ErrUnsupported = errors.New("beeep: unsupported operating system: " + runtime.GOOS)
)

Functions

func Alert

func Alert(title, message, appIcon string) error

Alert displays a desktop notification and plays a beep.

Example
Alert("Title", "MessageBody", "assets/warning.png")
Output:

func Beep

func Beep(freq float64, duration int) error

Beep beeps the PC speaker (https://en.wikipedia.org/wiki/PC_speaker).

On Linux it needs permission to access `/dev/tty0` or `/dev/input/by-path/platform-pcspkr-event-spkr` files for writing, and `pcspkr` module must be loaded. User must be in correct groups, usually `input` and/or `tty`.

If it can not open device files, it will fallback to sending Bell character (https://en.wikipedia.org/wiki/Bell_character). For bell character in X11 terminals you can enable bell with `xset b on`. For console check `setterm` and `--blength` or `--bfreq` options.

On macOS this just sends bell character. Enable `Audible bell` in Terminal --> Preferences --> Settings --> Advanced.

On Windows it uses Beep function via syscall.

On Web it plays hard coded beep sound.

Example
Beep(DefaultFreq, DefaultDuration)
Output:

func Notify

func Notify(title, message, appIcon string) error

Notify sends desktop notification.

On Linux it tries to send notification via D-Bus and it will fallback to `notify-send` binary.

Example
Notify("Title", "MessageBody", "assets/information.png")
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL