feedback

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

README

Haptic/visual/audio feedback for GNOME: Go bindings

go-feedback implements Go bindings for feedbackd, the Purism C library. It provides a means to create haptic, visual and audio feedback.

This package requires CGO_ENABLED=1 and libfeedback to be installed (apt install libfeedback-dev on Debian, pacman -S feedbackd on Arch).

Usage

Simple example without any error handling:

feedbacker, _ := feedback.NewFeedbacker("my.app.id")

event, _ := feedbacker.NewEvent("message-new-instant")

event.TriggerFeedback()

time.Sleep(2 * time.Second) // give time to actually notice feedback

An full example of how to use this library can be found in examples/example.go.

Documentation

Overview

Package feedback implements Go bindings for libfeedback. Requires Cgo and feedbackd (libfeedback-dev) to be installed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDebugLogger added in v0.2.0

func SetDebugLogger(logger Logger)

SetDebugLogger sets the Logger that will receive debug logging.

func SetErrorLogger added in v0.2.0

func SetErrorLogger(logger Logger)

SetErrorLogger sets the Logger that will receive error logging.

Types

type Event added in v0.2.0

type Event struct {
	// contains filtered or unexported fields
}

Event can trigger feedback.

func (*Event) TriggerFeedback added in v0.2.0

func (e *Event) TriggerFeedback() (bool, error)

TriggerFeedback triggers the feedback for the event. If the same event is triggered twice, an error is returned. If the program is terminated immediately after calling this function, the result might not be noticeable. That is because feedbackd terminates feedback from clients that disconnect from DBus, to avoid feedback not being stopped.

func (*Event) TriggerFeedbackAsync added in v0.2.0

func (e *Event) TriggerFeedbackAsync() error

TriggerFeedbackAsync triggers feedback for the event asynchronously. See the sync version of this function for more details.

type Feedbacker

type Feedbacker struct{}

Feedbacker is the main struct to interact with.

func NewFeedbacker

func NewFeedbacker(appID string) (*Feedbacker, error)

NewFeedbacker inits the underlying libfeedback.

func (*Feedbacker) NewEvent

func (f *Feedbacker) NewEvent(name string) (*Event, error)

NewEvent creates a new feedback event.

type Logger added in v0.2.0

type Logger func(...interface{})

Logger logs relevant information about the state of the application

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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