Documentation ¶
Index ¶
- func CommonPrefix(sl []string) string
- func CommonSuffix(sl []string) string
- func GnomeFileToSimpleString(filename string) (string, error)
- func GnomeToSimpleString(gtw *FatWallpaper) (string, error)
- func Meat(s, prefix, suffix string) string
- type FatWallpaper
- func DataToSimple(path string, data []byte) (*FatWallpaper, error)
- func GnomeToSimple(gtw *FatWallpaper) (*FatWallpaper, error)
- func NewGnome(name, path string, config *GBackground) *FatWallpaper
- func NewSimple(version, name, format string) *FatWallpaper
- func ParseSTW(filename string) (*FatWallpaper, error)
- func ParseXML(filename string) (*FatWallpaper, error)
- func (fw *FatWallpaper) AddStatic(at time.Time, filename string)
- func (fw *FatWallpaper) AddTransition(from, upto time.Time, fromFilename, toFilename, transitionType string)
- func (fw *FatWallpaper) EventLoop(verbose bool, setWallpaperFunc func(string) error, tempImageFilename string) error
- func (fw *FatWallpaper) Images() []string
- func (fw *FatWallpaper) NextEvent(now time.Time) (interface{}, error)
- func (fw *FatWallpaper) PrevEvent(now time.Time) (interface{}, error)
- func (fw *FatWallpaper) SetInitialWallpaper(verbose bool, setWallpaperFunc func(string) error, tempImageFilename string) error
- func (fw *FatWallpaper) StartTime() time.Time
- func (fw *FatWallpaper) String() string
- func (fw *FatWallpaper) UntilNext(et time.Time) time.Duration
- type GBackground
- type GStartTime
- type GStatic
- type GTransition
- type Static
- type StaticMap
- type Transition
- type TransitionMap
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommonPrefix ¶
CommonPrefix will find the longest common prefix in a slice of strings
func CommonSuffix ¶
CommonPrefix will find the longest common suffix in a slice of strings
func GnomeFileToSimpleString ¶
GnomeFileToSimpleString reads and parses an XML file, then returns a string representing the contents of a Simple Timed Wallpaper file.
func GnomeToSimpleString ¶
func GnomeToSimpleString(gtw *FatWallpaper) (string, error)
GnomeToSimpleString converts a Gnome Timed Wallpaper to a string representing a Simple Timed Wallpaper. The Path field in the given struct is not included in the output string.
Types ¶
type FatWallpaper ¶
type FatWallpaper struct { GNOME bool Version 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 Config *GBackground // set to nil when not a GNOME timed wallpaper }
FatWallpaper contains all data for either a Simple Timed Wallpaper or a GNOME Timed Wallpaper
func DataToSimple ¶
func DataToSimple(path string, data []byte) (*FatWallpaper, 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 GnomeToSimple ¶
func GnomeToSimple(gtw *FatWallpaper) (*FatWallpaper, error)
GnomeToSimple converts a Gnome Timed Wallpaper to a Simple Timed Wallpaper
func NewGnome ¶
func NewGnome(name, path string, config *GBackground) *FatWallpaper
NewGnome creates a new Gnome Timed Wallpaper struct
func NewSimple ¶
func NewSimple(version, name, format string) *FatWallpaper
NewSimple creates a new Simple Timed Wallpaper struct
func ParseSTW ¶
func ParseSTW(filename string) (*FatWallpaper, error)
Example ¶
stw, err := ParseSTW("testdata/adwaita-timed2.stw") if err != nil { panic(err) } fmt.Println(stw.Name) stw, err = ParseSTW("testdata/comments.stw") if err != nil { panic(err) } fmt.Println(stw.Name)
Output: adwaita-timed comments
func ParseXML ¶
func ParseXML(filename string) (*FatWallpaper, error)
Parse a Gnome XML file to a Wallpaper struct
Example ¶
gtw, err := ParseXML("testdata/example1.xml") if err != nil { panic(err) } fmt.Println(gtw.Config.StartTime.Year) fmt.Println(gtw.Config.Transitions[0].ToFilename) gtw, err = ParseXML("testdata/example2.xml") if err != nil { panic(err) } fmt.Println(gtw.Config.StartTime.Year) gtw, err = ParseXML("testdata/adwaita-timed.xml") if err != nil { panic(err) } fmt.Println(gtw.Config.StartTime.Year) gtw, err = ParseXML("testdata/generated.xml") if err != nil { panic(err) } fmt.Println(gtw.Config.StartTime.Year)
Output: 2009 /usr/share/backgrounds/cosmos/comet.jpg 0 2011 2018
func (*FatWallpaper) AddTransition ¶
func (fw *FatWallpaper) AddTransition(from, upto time.Time, fromFilename, toFilename, transitionType string)
func (*FatWallpaper) EventLoop ¶
func (fw *FatWallpaper) EventLoop(verbose bool, setWallpaperFunc func(string) error, tempImageFilename string) error
EventLoop will start the event loop for this Simple Timed Wallpaper
func (*FatWallpaper) Images ¶
func (fw *FatWallpaper) Images() []string
func (*FatWallpaper) NextEvent ¶
func (fw *FatWallpaper) 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 (*FatWallpaper) PrevEvent ¶
func (fw *FatWallpaper) 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 (*FatWallpaper) SetInitialWallpaper ¶
func (fw *FatWallpaper) SetInitialWallpaper(verbose bool, setWallpaperFunc func(string) error, tempImageFilename string) error
SetInitialWallpaper will set the first wallpaper, before starting the event loop
func (*FatWallpaper) StartTime ¶
func (fw *FatWallpaper) StartTime() time.Time
StartTime returns the timed wallpaper start time, as a time.Time
func (*FatWallpaper) String ¶
func (fw *FatWallpaper) String() string
String builds a string with various information about this GNOME timed wallpaper
type GBackground ¶
type GBackground struct { XMLName xml.Name `xml:"background"` StartTime GStartTime `xml:"starttime"` Statics []GStatic `xml:"static"` Transitions []GTransition `xml:"transition"` // contains filtered or unexported fields }
func (*GBackground) Get ¶
func (gb *GBackground) Get(i int) (interface{}, error)
Get either a GStatic or a GTransition, given a total position. Will return nil and an error if nothing is found.
func (*GBackground) StaticOrder ¶
func (gb *GBackground) StaticOrder(i int) (int, error)
StaticOrder finds the total position of a given GStatic position
func (*GBackground) String ¶
func (gb *GBackground) String() string
func (*GBackground) TransitionOrder ¶
func (gb *GBackground) TransitionOrder(i int) (int, error)
TransitionOrder finds the total position of a given GTransition position
type GStartTime ¶
type GStatic ¶
type GTransition ¶
type GTransition struct { XMLName xml.Name `xml:"transition"` Type string `xml:"type,attr,omitempty"` Seconds float64 `xml:"duration"` FromFilename string `xml:"from"` ToFilename string `xml:"to"` }
func (*GTransition) Duration ¶
func (t *GTransition) Duration() time.Duration
Duration returns how long a transition should last
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