Documentation ¶
Index ¶
- Constants
- func Run(cfg *Config, ctx context.Context) error
- func RunClock(lw *display.LineWriter, width int, ctx context.Context)
- func RunSysinfo(lw *display.LineWriter, width int, ctx context.Context)
- func RunWeather(lw *display.LineWriter, width int, ctx context.Context)
- type Action
- type ClickEntry
- type Config
- type Entry
- type Menu
- type MenuManager
- func (mgr *MenuManager) ActiveWindow() string
- func (mgr *MenuManager) AddMenu(name string, entries []Entry) error
- func (mgr *MenuManager) AddTimedAction(after time.Duration, action Action)
- func (mgr *MenuManager) Close() error
- func (mgr *MenuManager) Direction() int
- func (mgr *MenuManager) Display()
- func (mgr *MenuManager) ReleaseAction(a Action)
- func (mgr *MenuManager) RotateAction(a Action)
- func (mgr *MenuManager) SwitchTo(name string) error
- func (mgr *MenuManager) Value() int
- type Separator
- type ToggleEntry
Constants ¶
const ( // DirectionNone means no movement (initial state) DirectionNone = iota // DirectionRight means a clockwise rotation. DirectionRight // DirectionLeft means a counter-clockwise rotation. DirectionLeft )
Variables ¶
This section is empty.
Functions ¶
func RunClock ¶
func RunClock(lw *display.LineWriter, width int, ctx context.Context)
RunClock displays the current time in the "clock" window.
func RunSysinfo ¶
func RunSysinfo(lw *display.LineWriter, width int, ctx context.Context)
RunSysinfo displays system information in the "sysinfo" window. The data is obtained from the "radio-sysinfo.sh" script.
func RunWeather ¶
func RunWeather(lw *display.LineWriter, width int, ctx context.Context)
RunWeather displays a weather forecast in the "weather" window.
Types ¶
type ClickEntry ¶
type ClickEntry struct { // Text is the static text displayed in the menu line. Text string // ActionFunc is called when the entry is clicked. ActionFunc Action }
ClickEntry is a menu entry that can be clicked with the rotary switch.
type Config ¶
type Config struct { Width int Height int DisplayHost string DisplayPort int MPDHost string MPDPort int AmbilightHost string AmbilightPort int LightdHost string LightdPort int }
Config allows the user to configure to which services the ui connects.
type Entry ¶
type Entry interface { // Selectable returns true when the user can select the entry Selectable() bool // Render draws the line as string (with len of w), possibly with an // "active" marker as indicated by `active`. Render(w int, active bool) string // Action gets called when the user clicks the button. // Errors are logged but not handled otherwise. Action() error }
Entry is the common interface of each menu line
type Menu ¶
type Menu struct { // Name is the name of the menu window. // Should start with menu-[...] Name string // Entries is a list of Entry interfaces Entries []Entry // Cursor is the current offset in the entries Cursor int // contains filtered or unexported fields }
Menu is a collection of Entry interfaces grouped in a window. It supports the usual menu semantics, i.e. moving down and clicking an entry.
func NewMenu ¶
func NewMenu(name string, lw *display.LineWriter) (*Menu, error)
NewMenu returns a new menu that will use `lw` to display itself on the window `name`.
type MenuManager ¶
MenuManager handles the switching and drawing of several Menus and possibly "normal" windows.
func NewMenuManager ¶
func NewMenuManager(cfg *Config, lw *display.LineWriter, initialWin string) (*MenuManager, error)
NewMenuManager returns a new MenuManager that sends it's data to `lw` and switches to `initialWin`.
func (*MenuManager) ActiveWindow ¶
func (mgr *MenuManager) ActiveWindow() string
ActiveWindow returns the currently active window shown by the display server.
func (*MenuManager) AddMenu ¶
func (mgr *MenuManager) AddMenu(name string, entries []Entry) error
AddMenu adds a (potentially new) menu to the manager with `name` and `entries`. If the menu already exists it will be subsituted with the new one.
func (*MenuManager) AddTimedAction ¶
func (mgr *MenuManager) AddTimedAction(after time.Duration, action Action)
AddTimedAction register an action to be called after pressing the rotary button with a duration of `after`.
func (*MenuManager) Direction ¶
func (mgr *MenuManager) Direction() int
Direction returns the direction in which the rotary button was rotated last. If it was not rotated yet, the duration is DirectionNone.
func (*MenuManager) Display ¶
func (mgr *MenuManager) Display()
Display sends the current active menu to the display server. (but it does not switch to it!)
func (*MenuManager) ReleaseAction ¶
func (mgr *MenuManager) ReleaseAction(a Action)
ReleaseAction registers an action to be called when the rotary button is released.
func (*MenuManager) RotateAction ¶
func (mgr *MenuManager) RotateAction(a Action)
RotateAction registers an action to be called when the user rotates the knob.
func (*MenuManager) SwitchTo ¶
func (mgr *MenuManager) SwitchTo(name string) error
SwitchTo switches to the menu named `menu`. NOTE: use this instead of directly talking to the display server since it also switches the input focus.
func (*MenuManager) Value ¶
func (mgr *MenuManager) Value() int
Value returns the current value of the rotary button.
type Separator ¶
type Separator struct { // Title of the separator (drawn centered) Title string }
Separator is a visual separator between several other menu entries. Other than that it has no function.
type ToggleEntry ¶
type ToggleEntry struct { // Text is the text displayed along the state Text string // Order in which the states are toggled through Order []string // Actions is a map of state to Actions. // When changing to a state the respective // Action is called. Actions map[string]Action // contains filtered or unexported fields }
ToggleEntry skips through an ordered list of states.
func (*ToggleEntry) Action ¶
func (te *ToggleEntry) Action() error
Action goes to the next state and executes it's associated action
func (*ToggleEntry) Render ¶
func (te *ToggleEntry) Render(w int, active bool) string
Render draws an activity marker, the text and the current state.
func (*ToggleEntry) Selectable ¶
func (te *ToggleEntry) Selectable() bool
Selectable is true when there is a non-zero amount of actions
func (*ToggleEntry) SetState ¶
func (te *ToggleEntry) SetState(state string)
SetState sets the current state but does not call the associated action It's useful to set the state if it was changed by extern resources (i.e. a different mpd client)