swaybarprotocol

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

README

swaybar-protocol

This library is a golang implementation of the swaybar-protocol as outlined in man 7 swaybar-protocol.

Documentation

Index

Constants

View Source
const (
	AlignLeft   = "left"
	AlignRight  = "right"
	AlignCenter = "center"

	MarkupPango = "pango"
	MarkupNone  = "none"
)

Variables

This section is empty.

Functions

func Init

func Init(w io.Writer, h *Header) error

func Output

func Output(w io.Writer, arr []*Body) error

Types

type Body

type Body struct {
	Instance            string `json:"instance,omitempty"`
	Border              string `json:"border,omitempty"`
	Markup              string `json:"markup,omitempty"`
	Background          string `json:"background,omitempty"`
	FullText            string `json:"full_text"`
	ShortText           string `json:"short_text,omitempty"`
	Name                string `json:"name"`
	Align               string `json:"align,omitempty"`
	Color               string `json:"color,omitempty"`
	BorderTop           int    `json:"border_top,omitempty"`
	BorderLeft          int    `json:"border_left,omitempty"`
	BorderBottom        int    `json:"border_bottom,omitempty"`
	MinWidth            int    `json:"min_width,omitempty"`
	SeparatorBlockWidth int    `json:"separator_block_width,omitempty"`
	BorderRight         int    `json:"border_right,omitempty"`
	Urgent              bool   `json:"urgent,omitempty"`
	Separator           bool   `json:"separator,omitempty"`
}

Body represents a single element of the infinite swaybar array, where each element represents a block to be rendered by swaybar. (see: man 7 swaybar-protocol)

type ClickEvent

type ClickEvent struct {
	Name      string `json:"name"`
	Instance  string `json:"instance"`
	X         int    `json:"x"`
	Y         int    `json:"y"`
	Button    int    `json:"button"`
	Event     int    `json:"event"`
	RelativeX int    `json:"relative_x"`
	RelativeY int    `json:"relative_y"`
	Width     int    `json:"width"`
	Height    int    `json:"height"`
}

ClickEvent represents an event that swaybar writes to the standard input when the user clicks on a block.

func Read

func Read(r io.Reader) (*ClickEvent, error)
type Header struct {
	Version     int  `json:"version"`
	ClickEvents bool `json:"click_events,omitempty"`
	ContSignal  int  `json:"cont_signal,omitempty"`
	StopSignal  int  `json:"stop_signal,omitempty"`
}

Header represents the swaybar header as defined in the swaybar json protocol. (see: man 7 swaybar-protocol)

Jump to

Keyboard shortcuts

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