simpletimed

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: MIT Imports: 13 Imported by: 1

README

The Simple Timed Wallpaper Format

Specification

Version 1.0.0

Go module

GoDoc

The simpletimed Go module can be used for parsing the file format and for running an event loop for setting the wallpaper, given a function with this signature:

func(string) error

Where the given string is the image filename to be set.

  • simpletimed module version: 1.0.8

General info

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultLoopTime = 5 * time.Second

Functions

This section is empty.

Types

type Static

type Static struct {
	At       time.Time
	Filename string
}

func (*Static) String

func (s *Static) String(format string) string

type Transition

type Transition struct {
	From         time.Time
	UpTo         time.Time
	FromFilename string
	ToFilename   string
	Type         string
}

func (*Transition) Duration

func (t *Transition) Duration() time.Duration

func (*Transition) String

func (t *Transition) String(format string) string

type Wallpaper

type Wallpaper struct {
	STWVersion  string
	Name        string
	Format      string
	Path        string // not part of the file data, but handy when parsing
	Statics     []*Static
	Transitions []*Transition
	LoopWait    time.Duration // how long the main event loop should sleep
}

func DataToSimple

func DataToSimple(path string, data []byte) (*Wallpaper, error)

DataToSimple converts from the contents of a Simple Timed Wallpaper file to a Wallpaper structs. The given path is used in the error messages and for setting stw.Path.

func NewWallpaper

func NewWallpaper(version, name, format string) *Wallpaper

func ParseSTW

func ParseSTW(filename string) (*Wallpaper, error)
Example
stw, err := ParseSTW("testdata/adwaita-timed2.stw")
if err != nil {
	panic(err)
}
fmt.Println(stw.Name)
Output:
adwaita-timed

func (*Wallpaper) AddStatic

func (stw *Wallpaper) AddStatic(at time.Time, filename string)

func (*Wallpaper) AddTransition

func (stw *Wallpaper) AddTransition(from, upto time.Time, fromFilename, toFilename, transitionType string)

func (*Wallpaper) EventLoop

func (stw *Wallpaper) EventLoop(verbose bool, setWallpaperFunc func(string) error) error

EventLoop will start the event loop for this Simple Timed Wallpaper

func (*Wallpaper) NextEvent

func (stw *Wallpaper) NextEvent(now time.Time) (interface{}, error)

NextEvent finds the next event, given a timestamp. Returns an interface{} that is either a static or transition event.

func (*Wallpaper) PrevEvent

func (stw *Wallpaper) PrevEvent(now time.Time) (interface{}, error)

PrevEvent finds the previous event, given a timestamp. Returns an interface{} that is either a static or transition event.

func (*Wallpaper) SetInitialWallpaper

func (stw *Wallpaper) SetInitialWallpaper(verbose bool, setWallpaperFunc func(string) error) error

SetInitialWallpaper will set the first wallpaper, before starting the event loop

func (*Wallpaper) String

func (stw *Wallpaper) String() string

String outputs a valid STW file, where the timestamps are in a sorted order

func (*Wallpaper) UntilNext

func (stw *Wallpaper) UntilNext(et time.Time) time.Duration

UntilNext finds the duration until the next event starts

Jump to

Keyboard shortcuts

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