keyboard

package
v0.0.0-...-e5c115e Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

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

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

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// Next switches to the next layout in the layout list. This will wrap
	// around if the last layout is reached.
	Next()

	// Next switches to the previous layout in the layout list. This will wrap
	// around if the first layout is reached.
	Previous()

	// SetLayout sets a new layout. Layout strings that were not configured on
	// the module are ignored.
	SetLayout(layout string)

	// GetLayouts returns all layouts that are configured on the keyboard module
	// instance that the controller belongs to.
	GetLayouts() []string
}

Controller can switch between keyboard layouts.

type Layout

type Layout struct {
	Controller

	// Name is the name of the keyboard layout, e.g "us".
	Name string
}

Layout contains the name of the currently set keyboard layout. It also exposes a Controller to switch between available layouts.

func (Layout) String

func (l Layout) String() string

String implements fmt.Stringer.

type Module

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

Module is a module for displaying and interacting with the keyboard layout that is configured by the user.

func New

func New(provider Provider, layouts ...string) *Module

New creates a new *Module with given keyboard provider. By default, the lists of layouts is cycled through whenever the keyboard layout display in the bar is clicked or scrolled. By default, the module will refresh every 10 seconds. The refresh interval can be configured using `Every`.

func (*Module) Every

func (m *Module) Every(interval time.Duration) *Module

Every configures the refresh interval for the module. Passing a zero interval will disable refreshing.

func (*Module) Output

func (m *Module) Output(format func(Layout) bar.Output) *Module

Output updates the output format func.

func (*Module) Refresh

func (m *Module) Refresh()

Refresh forces a refresh of the module output.

func (*Module) Stream

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

Stream implements bar.Module.

type Provider

type Provider interface {
	// GetLayout retrieves the name of the currently active keyboard layout.
	GetLayout() (string, error)

	// SetLayout sets a new keyboard layout.
	SetLayout(layout string) error
}

Provider provides the current keyboard layout and is also able to change it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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