beeep

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: BSD-2-Clause Imports: 9 Imported by: 0

README

beeep

Build Status Go Reference Go Report Card

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

Installation

go get -u github.com/godoes/beeep

Build tags

  • nodbus - disable godbus/dbus and use only notify-send

Examples

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

Documentation

Overview

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

Index

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.

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.

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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