plugins

package
v0.0.0-...-8099344 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Overview

Package plugins abuses the go build chain to use code as configuration.

Index

Constants

This section is empty.

Variables

View Source
var Devices = map[Device]map[Page]map[Button]Action{
	{Model: "", Serial: ""}: {
		"default": {
			{Row: 0, Col: 0}: &gopher{},
			{Row: 0, Col: 1}: &date{formats: []string{time.TimeOnly, time.DateOnly, "Monday"}},
			{Row: 0, Col: 2}: &serial{},
			{Row: 0, Col: 4}: &change{toPage: "debug"},
			{Row: 1, Col: 0}: &command{
				cmd: "subl", args: []string{"-n"},
				icon: "/opt/sublime_text/Icon/128x128/sublime-text.png",
			},
			{Row: 1, Col: 1}: &command{
				cmd:  "smerge",
				icon: "/opt/sublime_merge/Icon/128x128/sublime-merge.png",
			},
			{Row: 1, Col: 2}: &command{
				name: "terminal", cmd: "gnome-terminal", args: []string{"--working-directory=~"},
				icon: "/usr/share/icons/gnome/256x256/apps/gnome-terminal.png",
			},
			{Row: 1, Col: 3}: &command{cmd: "bad"},
			{Row: 2, Col: 0}: &brightness{add: +5},
			{Row: 2, Col: 1}: &brightness{add: -5},
			{Row: 1, Col: 4}: &sleep{blankAfter: time.Minute},
		},
		"debug": {
			{Row: 0, Col: 4}: &change{toPage: "default"},
			{Row: 0, Col: 0}: &dump{},
			{Row: 1, Col: 0}: &logging{add: -1},
			{Row: 2, Col: 0}: &logging{add: +1},
			{Row: 1, Col: 4}: &sleep{blankAfter: time.Minute},
			{Row: 2, Col: 4}: &stop{},
		},
	},
}

Devices is the device configuration used by minidex.

Functions

func Swatch

func Swatch(rect image.Rectangle, col color.Color) image.Image

Swatch returns a bounded uniform color image.

Types

type Action

type Action interface {
	Init(context.Context, Plugin) (image.Image, error)
}

Action is a plugin definition.

type Button

type Button struct {
	Row, Col int
}

Button is a plugin table button key.

type Device

type Device struct {
	Model, Serial string
}

Device is a plugin table device key.

type Page

type Page string

Page is a plugin table page key.

type Plugin

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

Plugin holds system state useful for a plugin.

func New

func New(dev *device.Controller, button *device.Button, store *state.DB, log *slog.Logger, level *slog.LevelVar) Plugin

New returns a new initialised plugin.

type Presser

type Presser interface {
	Press(ctx context.Context, page string, r, c int, t time.Time) error
}

type Releaser

type Releaser interface {
	Release(ctx context.Context, page string, r, c int, t time.Time) error
}

Jump to

Keyboard shortcuts

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