barista-contrib

Community modules and extensions for barista.

View barista-contrib on GitHub View barista on GitHub View official barista docs

Keyboard

godoc
import "github.com/martinohmann/barista-contrib/modules/keyboard"

Show the currently active keyboard layout: keyboard.New(someProvider, layouts...).

Keyboard supports displaying the keyboard layout using pluggable providers, with the ability to add custom providers fairly easily. Provider is just

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
}

The following keyboard providers are available in barista-contrib:

Configuration

Examples

us

Show the current keyboard layout and add custom click handlers:

xkbmap.New("us", "de").Output(func(layout keyboard.Layout) bar.Output {
    return outputs.Textf("%s", strings.ToUpper(layout.Name)).OnClick(func(e bar.Event) {
		switch e.Button {
		case bar.ButtonLeft:
			l.Next()
		case bar.ButtonRight:
			l.Previous()
		}
	})
})

Using .OnClick(nil) prevents the default click handler of the keyboard module from being added to part of the output.

Data: type Layout struct

Fields

Methods

Controller Methods

In addition to the data methods listed above, keyboard’s Layout type also provides controller methods to control the active keyboard layout: