barista.run: barista.run/modules/volume Index | Files | Directories

package volume

import "barista.run/modules/volume"

Package volume provides an i3bar module that interfaces with alsa or pulse to display and control the system volume.

Index

Package Files

volume.go

Variables

var RateLimiter = rate.NewLimiter(rate.Every(20*time.Millisecond), 1)

RateLimiter throttles volume updates to once every ~20ms to avoid unexpected behaviour.

type Controller Uses

type Controller interface {
    SetVolume(int64) error
    SetMuted(bool) error
}

Controller for a volume module implementation.

type Module Uses

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

Module represents a bar.Module that displays volume information.

func New Uses

func New(provider Provider) *Module

New creates a new module with the given backing implementation.

func (*Module) Output Uses

func (m *Module) Output(outputFunc func(Volume) bar.Output) *Module

Output configures a module to display the output of a user-defined function.

func (*Module) Stream Uses

func (m *Module) Stream(s bar.Sink)

Stream starts the module.

type Provider Uses

type Provider interface {
    // Worker pushes updates and errors to the provided ErrorValue.
    Worker(s *value.ErrorValue)
}

Provider is the interface that must be implemented by individual volume implementations.

type Volume Uses

type Volume struct {
    Min, Max, Vol int64
    Mute          bool
    // contains filtered or unexported fields
}

Volume represents the current audio volume and mute state.

func MakeVolume Uses

func MakeVolume(min, max, volume int64, mute bool, controller Controller) Volume

MakeVolume creates a Volume instance with the given data.

func (Volume) Frac Uses

func (v Volume) Frac() float64

Frac returns the current volume as a fraction of the total range.

func (Volume) Pct Uses

func (v Volume) Pct() int

Pct returns the current volume in the range 0-100.

func (Volume) SetMuted Uses

func (v Volume) SetMuted(muted bool)

SetMuted controls whether the system volume is muted.

func (Volume) SetVolume Uses

func (v Volume) SetVolume(volume int64)

SetVolume sets the system volume. It does not change the mute status.

Directories

PathSynopsis
alsa
pulseaudio

Package volume imports 6 packages (graph) and is imported by 5 packages. Updated 2019-12-11. Refresh now. Tools for package owners.