glass

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 15 Imported by: 0

README

Logo

Go Report Card Build Status Coverage Status GitHub release GitHub license

Smart mirror platform written in Go leveraging WASM.

Table of Contents

Requirements

Chrome

Chrome or Chromium must be installed. The version must be greater or equal to 70. If looking glass cannot find Chrome, use the LORCACHROME environment variable to force the location of your installation.

Install

On a fresh install of Raspberry Pi OS Lite, run the following command:

bash -c "$(curl -fsSL https://git.io/looking_glass)"

Usage

Run

Runs looking glass using the specified configuration and modules path.

glass run -c /path/to/config.yaml -m /path/to/modules
Run Options

--secrets FILE, -s FILE, $SECRETS (Optional)

The path to the YAML secrets file to hold sensitive configuration values. Secrets can be accessed in the configuration using Go template syntax using the ".Secrets" prefix.

--config FILE, -c FILE, $CONFIG (Required)

The path to the YAML configuration file for looking-glass which includes module configuration. This file will be parsed using Go template syntax.

--assets PATH, -a PATH, $ASSETS (Required)

The path to the assets.

--modules PATH, -m PATH, $MODULES (Required)

The path to the module cache.

--log.format FORMAT, $LOG_FORMAT (Default: "logfmt")

Specify the format of logs. Supported formats: 'logfmt', 'json', 'console'.

--log.level LEVEL, $LOG_LEVEL (Default: "info")

Specify the log level. Supported levels: 'debug', 'info', 'warn', 'error', 'crit'.

Configuration

ui:
  width:  640
  height: 480
  fullscreen: true
  customCss:
    - path/to/custom.css
modules:
  - name: simple-clock
    url: https://github.com/glasslabs/clock/releases/download/v1.0.0/clock.wasm
    position: top:right
  - name: simple-weather
    uri: https://github.com/glasslabs/weather/releases/download/v1.0.0/weather.wasm
    position: top:left
    config:
      locationId: 996506
      appId: {{ .Secrets.weather.appId }}
      units: metric

The module configuration can contain secrets from the secrets YAML prefixed with .Secrets as shown in the example above.

Configuration Options

ui.width

The width of the chrome window.

ui.height

The height of the chrome window.

ui.fullscreen

If the chrome window should start fullscreen.

ui.customCSS

A list of custom css files to load. These can be used to customise the layout of looking glass.

modules.[].name

The name of the module. This name must be unique. This is used as the ID of the module HTML wrapper.

modules.[].url

The module URL or path of the module under the modules path.

modules.[].position

The position of the module.

modules.[].config

The configuration that will be passed to the module.

Configuration Variables

The configuration file will be parsed using Go template syntax. The available variables are:

Secrets

The secrets in the case they appear in the secrets file.

Env

The environment variables available when running looking-glass.

Modules

You can discover modules on GitHub using GitHub Search.

Development

To make your module discoverable on GitHub, add the topics looking-glass and module.

TODO

This is very much a work in progress and under active development. The immediate list of things to do is below:

  • Localisation
  • Testing Framework for Modules

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSecrets

func ParseSecrets(in []byte) (map[string]any, error)

ParseSecrets parses secrets from in.

Types

type Config

type Config struct {
	UI      UIConfig            `yaml:"ui"`
	Modules []module.Descriptor `yaml:"modules"`
}

Config contains the main configuration.

func ParseConfig

func ParseConfig(in []byte, cfgPath string, secrets map[string]any) (Config, error)

ParseConfig parses configuration from in.

func (Config) Validate

func (c Config) Validate() error

Validate validates the configuration.

type UI

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

UI implements a ui manager.

func NewUI

func NewUI(cfg UIConfig, log *logger.Logger) (*UI, error)

NewUI returns a new UI.

func (*UI) Close

func (ui *UI) Close() error

Close closes the ui.

func (*UI) Done

func (ui *UI) Done() <-chan struct{}

Done returns a channel signalling the UI being closed.

func (*UI) Eval

func (ui *UI) Eval(js string) (any, error)

Eval evaluates a javascript expression.

type UIConfig

type UIConfig struct {
	Width      int      `yaml:"width"`
	Height     int      `yaml:"height"`
	Fullscreen bool     `yaml:"fullscreen"`
	CustomCSS  []string `yaml:"customCss"`
}

UIConfig contains configuration for the UI.

func (UIConfig) Validate

func (c UIConfig) Validate() error

Validate validates the ui configuration.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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