modules

package
v0.0.0-...-4fdbfbd Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2017 License: BSD-2-Clause Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig(cfg *Config) error

GetConfig loads the Goblocks configuration object.

Types

type Battery

type Battery struct {
	BlockConfigBase `yaml:",inline"`
	BatteryNumber   int     `yaml:"battery_number"`
	CritBattery     float64 `yaml:"crit_battery"`
}

Battery represents the configuration for the battery block.

func (Battery) UpdateBlock

func (c Battery) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the battery status block.

type Block

type Block struct {
	I3barBlock i3barjson.Block
	Config     BlockConfig
}

Block contains all functions and objects necessary to configure and update a single status block.

func GetBlocks

func GetBlocks(blockConfigSlice []BlockConfig) ([]*Block, error)

GetBlocks initializes and returns a Block slice based on the given configuration.

type BlockConfig

type BlockConfig interface {
	GetUpdateInterval() float64
	GetUpdateSignal() int
	GetBlockType() string
	UpdateBlock(b *i3barjson.Block)
}

BlockConfig is an interface for Block configuration structs.

type BlockConfigBase

type BlockConfigBase struct {
	Type           string  `yaml:"type"`
	UpdateInterval float64 `yaml:"update_interval"`
	Label          string  `yaml:"label"`
	Color          string  `yaml:"color"`
	UpdateSignal   int     `yaml:"update_signal"`
}

BlockConfigBase is a base struct for Block configuration structs. It implements all of the methods of the BlockConfig interface except the UpdateBlock method. That method should be implemented by each Block configuration struct, which should also embed the BlockConfigBase struct as an anonymous field. That way, each Block configuration struct will implement the full BlockConfig interface.

func (BlockConfigBase) GetBlockType

func (c BlockConfigBase) GetBlockType() string

GetBlockType returns the block's type as a string.

func (BlockConfigBase) GetUpdateInterval

func (c BlockConfigBase) GetUpdateInterval() float64

GetUpdateInterval returns the block's update interval in seconds.

func (BlockConfigBase) GetUpdateSignal

func (c BlockConfigBase) GetUpdateSignal() int

GetUpdateSignal returns the block's update signal that forces an update and refresh.

type Command

type Command struct {
	BlockConfigBase `yaml:",inline"`
	Cmd             string `yaml:"command"`
}

func (Command) UpdateBlock

func (c Command) UpdateBlock(b *i3barjson.Block)

type Config

type Config struct {
	Global GlobalConfig
	Blocks []BlockConfig
}

Config is the root configuration struct.

type Disk

type Disk struct {
	BlockConfigBase `yaml:",inline"`
	Filesystems     map[string]float64 `yaml:"filesystems"`
}

Disk represents the configuration for the disk block.

func (Disk) UpdateBlock

func (c Disk) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the status of the disk block. The block displays "ok" unless one of the given filesystems are over 95%.

type GlobalConfig

type GlobalConfig struct {
	Debug           bool    `yaml:"debug"`
	RefreshInterval float64 `yaml:"refresh_interval"`
}

GlobalConfig represents global config options.

type Goblocks

type Goblocks struct {
	Cfg         Config
	SelectCases SelectCases
	Tickers     []*time.Ticker
	StatusLine  i3barjson.StatusLine
}

Goblocks contains all configuration and runtime data needed for the application.

func NewGoblocks

func NewGoblocks() (*Goblocks, error)

NewGoblocks returns a Goblocks instance with all configuration and runtime data loaded in.

func (*Goblocks) AddBlockSelectCases

func (gb *Goblocks) AddBlockSelectCases(b []*Block)

AddBlockSelectCases is a helper function to add all configured Block objects to Goblocks' SelectCases.

func (*Goblocks) AddUpdateTickerSelectCase

func (gb *Goblocks) AddUpdateTickerSelectCase()

AddUpdateTickerSelectCase adds the Goblocks update ticker that controls refreshing the Goblocks output.

func (*Goblocks) Reset

func (gb *Goblocks) Reset()

Reset stops all tickers and resets all signal handlers.

type Interface

type Interface struct {
	BlockConfigBase `yaml:",inline"`
	IfaceName       string `yaml:"interface_name"`
	IfaceFormat     string `yaml:"interface_format"`
}

Interface represents the configuration for the network interface block.

func (Interface) UpdateBlock

func (c Interface) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the network interface block.

type KeyIndicator

type KeyIndicator struct {
	BlockConfigBase `yaml:",inline"`
	Key             string `yaml:"key"`
	KeyText         string `yaml:"key-text"`
	OnColor         string `yaml:"on-color"`
	OffColor        string `yaml:"off-color"`
}

KeyIndicator represents the configuration for the key indicator block.

func (KeyIndicator) UpdateBlock

func (c KeyIndicator) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the key indicator block's status.

type Load

type Load struct {
	BlockConfigBase `yaml:",inline"`
	CritLoad        float64 `yaml:"crit_load"`
}

Load represents the configuration for the system load.

func (Load) UpdateBlock

func (c Load) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the load block status.

type Memory

type Memory struct {
	BlockConfigBase `yaml:",inline"`
	CritMem         float64 `yaml:"crit_mem"`
}

Memory represents the configuration for the memory block.

func (Memory) UpdateBlock

func (c Memory) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the system memory block status. The value dispayed is the amount of available memory.

type PreConfig

type PreConfig struct {
	Global GlobalConfig             `yaml:"global"`
	Blocks []map[string]interface{} `yaml:"blocks"`
}

PreConfig is the struct used to initially unmarshal the configuration. Once the configuration has been fully processed, it is stored in the Config struct.

type Raid

type Raid struct {
	BlockConfigBase `yaml:",inline"`
}

Raid represents the configuration for the RAID block.

func (Raid) UpdateBlock

func (c Raid) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the RAID block's status. This block only supports linux mdraid, and alerts if any RAID volume on the system is degraded.

type SelectAction

type SelectAction func(*Block) SelectReturn

SelectAction is a function type that performs an action when a channel is selected on in the main program loop. The return value indicates some action for the caller to take.

type SelectCases

type SelectCases struct {
	Cases   []reflect.SelectCase
	Actions []SelectAction
	Blocks  []*Block
}

SelectCases represents the set of channels that Goblocks selects on in the main program loop, as well as the functions and data to run and operate on, respectively.

func (*SelectCases) AddSignalSelectCases

func (s *SelectCases) AddSignalSelectCases(blocks []*Block)

AddSignalSelectCases loads the select cases related to OS signals.

type SelectReturn

type SelectReturn struct {
	Exit          bool
	ForceRefresh  bool
	Refresh       bool
	Reload        bool
	SignalRefresh bool
}

SelectReturn is returned by a SelectAction type function and tells the caller a certain action to take.

func SelectActionExit

func SelectActionExit(b *Block) SelectReturn

SelectActionExit is a helper function of type SelectAction that tells Goblocks to exit.

func SelectActionForceRefresh

func SelectActionForceRefresh(b *Block) SelectReturn

SelectActionForceRefresh is a helper function of type SelectAction that tells Goblocks to immediately refresh the output. This differs from SelectActionRefresh in that a refresh is performed regardless of whether SelectActionSignalRefresh has been called.

func SelectActionRefresh

func SelectActionRefresh(b *Block) SelectReturn

SelectActionRefresh is a helper function of type SelectAction that tells Goblocks to refresh the output. Note that the output is only refreshed if SelectActionSignalRefresh was returned at least once since the last refresh interval tick. This prevents needlessly refreshing the output when nothing changed.

func SelectActionReload

func SelectActionReload(b *Block) SelectReturn

SelectActionReload is a helper function of type SelectAction that tells Goblocks to reload the configuration.

func SelectActionSignalRefresh

func SelectActionSignalRefresh(b *Block) SelectReturn

SelectActionSignalRefresh is a helper function of type SelectAction that tells Goblocks to signal the refresher that a refresh should be performed. The actual refresh won't be performed until the refresh interval timer fires again.

type Temperature

type Temperature struct {
	BlockConfigBase `yaml:",inline"`
	CpuTempPath     string  `yaml:"cpu_temp_path"`
	CritTemp        float64 `yaml:"crit_temp"`
}

Temperature represents the configuration for the CPU temperature block. CpuTempPath is the path to the "hwmon" directory of the CPU temperature info. e.g. /sys/devices/platform/coretemp.0/hwmon

func (Temperature) UpdateBlock

func (c Temperature) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the CPU temperature info. The value output by the block is the average temperature of all cores.

type Time

type Time struct {
	BlockConfigBase `yaml:",inline"`
	TimeFormat      string `yaml:"time_format"`
}

Time represents the configuration for the time display block.

func (Time) UpdateBlock

func (c Time) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the time display block.

type Uptime

type Uptime struct {
	BlockConfigBase `yaml:",inline"`
	DurationFormat  string `yaml:"duration_format"`
}

Uptime represents the configuration for the time display block.

func (Uptime) UpdateBlock

func (c Uptime) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the time display block.

type Volume

type Volume struct {
	BlockConfigBase `yaml:",inline"`
	MixerDevice     string `yaml:"mixer_device"`
	Channel         string `yaml:"channel"`
}

Volume represents the configuration for the volume display block.

func (Volume) UpdateBlock

func (c Volume) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the volume display block. Currently, only the ALSA master channel volume is supported.

type Wifi

type Wifi struct {
	BlockConfigBase `yaml:",inline"`
	IfaceName       string  `yaml:"interface_name"`
	CritQuality     float64 `yaml:"crit_quality"`
}

Wifi represents the configuration for the wifi percent block.

func (Wifi) UpdateBlock

func (c Wifi) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the wifi block's status.

type Zfs

type Zfs struct {
	BlockConfigBase `yaml:",inline"`
	PoolName        string `yaml:"zpool_name"`
}

Zfs represents the configuration data for the ZFS block

func (Zfs) UpdateBlock

func (c Zfs) UpdateBlock(b *i3barjson.Block)

UpdateBlock updates the ZFS block

Jump to

Keyboard shortcuts

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