volume

package
v0.0.0-...-069b4f3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

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

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

Functions

This section is empty.

Types

type Controller

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

Controller for a volume module implementation.

type Module

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

Module represents a bar.Module that displays volume information.

func New

func New(provider Provider) *Module

New creates a new module with the given backing implementation.

func (*Module) Output

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

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

Stream starts the module.

type Provider

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

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

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

MakeVolume creates a Volume instance with the given data.

func (Volume) Frac

func (v Volume) Frac() float64

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

func (Volume) Pct

func (v Volume) Pct() int

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

func (Volume) SetMuted

func (v Volume) SetMuted(muted bool)

SetMuted controls whether the system volume is muted.

func (Volume) SetVolume

func (v Volume) SetVolume(volume int64)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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