Documentation
¶
Index ¶
- Variables
- func CommonPrefix(sl []string) string
- func CommonSuffix(sl []string) string
- func GnomeFileToSimpleString(filename string) (string, error)
- func GnomeToSimple(gtw *Wallpaper) (*simpletimed.Wallpaper, error)
- func GnomeToSimpleString(gtw *Wallpaper) (string, error)
- func Meat(s, prefix, suffix string) string
- type GBackground
- type GStartTime
- type GStatic
- type GTransition
- type StaticMap
- type TransitionMap
- type Wallpaper
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultEventLoopDelay = 5 * time.Second
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 GnomeToSimple ¶
func GnomeToSimple(gtw *Wallpaper) (*simpletimed.Wallpaper, error)
GnomeToSimple converts a Gnome Timed Wallpaper to a Simple Timed Wallpaper
func GnomeToSimpleString ¶
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 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 TransitionMap ¶
type Wallpaper ¶
type Wallpaper struct {
// The name of this timed wallpaper
Name string
// Path is the full path to the XML file
Path string
// Config contains the parsed XML. See: gnomexml.go
Config *GBackground
// LoopWait is for how long the event loop should sleep at every iteration
LoopWait time.Duration
}
func NewWallpaper ¶
func NewWallpaper(name string, path string, config *GBackground) *Wallpaper
func ParseXML ¶
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)
Output: 2009 /usr/share/backgrounds/cosmos/comet.jpg 0 2011