diff --git a/README.md b/README.md index bf4bd24..75898c2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Monitor [![Build Status](https://travis-ci.org/xyproto/monitor.svg?branch=master)](https://travis-ci.org/xyproto/monitor) [![GoDoc](https://godoc.org/github.com/xyproto/monitor?status.svg)](http://godoc.org/github.com/xyproto/monitor) [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/xyproto/monitor/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/xyproto/monitor)](https://goreportcard.com/report/github.com/xyproto/monitor) +# Wallutils [![Build Status](https://travis-ci.org/xyproto/wallutils.svg?branch=master)](https://travis-ci.org/xyproto/wallutils) [![GoDoc](https://godoc.org/github.com/xyproto/wallutils?status.svg)](http://godoc.org/github.com/xyproto/wallutils) [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/xyproto/wallutils/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/xyproto/wallutils)](https://goreportcard.com/report/github.com/xyproto/wallutils) * Detect monitor resolutions and set the desktop wallpaper, for any window manager (please file an issue if your window manager is not supported yet). * Supports GNOME timed wallpapers, and includes a utility that can run an event loop for changing them (also supports cross fading). @@ -21,9 +21,9 @@ The [Mojave timed wallpaper](https://github.com/japamax/gnome-mojave-timed-wallp * `setcollection`, for setting a suitable (in terms of resolution) wallpaper from a wallpaper collection. * `setrandom`, for setting a random wallpaper. * `settimed`, for setting GNOME timed wallpapers (will continue to run, to handle time events). - * `setwallpaper` can be used for setting a wallpaper (works both for X11 and Wayland). + * `setwallpaper` can be used for setting a wallpaper (works both over X and the Wayland protocol). * `wayinfo` shows detailed information about the connected monitors, via Wayland. - * `xinfo` shows detailed information about the connected monitors, via X11. + * `xinfo` shows detailed information about the connected monitors, via X. * `xml2stw` for converting GNOME timed wallpapers to the Simple Timed Wallpaper format. ## Example use of the `lsmon` utility @@ -44,15 +44,15 @@ Using make, for building and installing all included utilities: Using Go 1.11 or later, for a single utility: - go get -u github.com/xyproto/monitor/cmd/setwallpaper + go get -u github.com/xyproto/wallutils/cmd/settimed On Arch Linux: -Install `monitor` from AUR, or: +Install `wallutils` from AUR, or: sudo pacman -Syu git go libxcursor libxmu wayland xbitmaps xorgproto - go get -u github.com/xyproto/monitor/cmd/setwallpaper - cd ~/go/src/github.com/xyproto/monitor + git clone https://github.com/xyproto/wallutils + cd wallutils make sudo make install @@ -60,25 +60,23 @@ On Ubuntu: sudo apt get update sudo apt get install libxcursor-dev libxmu-dev libx11-dev git golang-go - go get -u github.com/xyproto/monitor/cmd/setwallpaper - cd ~/go/src/github.com/xyproto/monitor + git clone https://github.com/xyproto/wallutils + cd wallutils make sudo make install -Manually: +## Example use of `settimed` - # clone the repository - git clone https://github.com/xyproto/monitor - - # build and install the setwallpaper command - cd monitor/cmd/setwallpaper - go build - install -Dm755 setwallpaper /usr/bin/setwallpaper + settimed mojave-timed ## Example use of `setwallpaper` setwallpaper /path/to/background/image.png +## Example use of `setrandom` + + setrandom /usr/share/pixmaps + ## Example use of the Go package ### Retrieve monitor resolution(s) @@ -90,12 +88,12 @@ import ( "fmt" "os" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" ) func main() { // Retrieve a slice of Monitor structs, or exit with an error - monitors, err := monitor.Detect() + monitors, err := wallutils.Monitors() if err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) @@ -111,7 +109,7 @@ func main() { ```go fmt.Println("Setting background image to: " + imageFilename) -if err := monitor.SetWallpaper(imageFilename); err != nil { +if err := wallutils.SetWallpaper(imageFilename); err != nil { return err } ``` diff --git a/cinnamon.go b/cinnamon.go index 78278a6..8c46f12 100644 --- a/cinnamon.go +++ b/cinnamon.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // Cinnamon windowmanager detector type Cinnamon struct { diff --git a/closest.go b/closest.go index 9feaec9..7010973 100644 --- a/closest.go +++ b/closest.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "os" diff --git a/closest_test.go b/closest_test.go index 41a38f3..0643310 100644 --- a/closest_test.go +++ b/closest_test.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "fmt" diff --git a/cmd/getdpi/main.go b/cmd/getdpi/main.go index 56bacc3..3718e1f 100644 --- a/cmd/getdpi/main.go +++ b/cmd/getdpi/main.go @@ -4,12 +4,12 @@ import ( "fmt" "os" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" ) func main() { // Retrieve a slice of Monitor structs, or exit with an error - monitors, err := monitor.Detect() + monitors, err := wallutils.Monitors() if err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) @@ -28,7 +28,7 @@ func main() { fmt.Printf("%dx%d\n", DPIw, DPIh) return } else if len(os.Args) > 1 && os.Args[1] == "--version" { - fmt.Println(monitor.VersionString) + fmt.Println(wallutils.VersionString) os.Exit(0) } diff --git a/cmd/lscollection/main.go b/cmd/lscollection/main.go index 74de577..44d83c6 100644 --- a/cmd/lscollection/main.go +++ b/cmd/lscollection/main.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" "os" "path/filepath" "text/tabwriter" @@ -22,7 +22,7 @@ func main() { alsoPrintPath := len(os.Args) > 1 && os.Args[1] == "-l" // Find all wallpapers - searchResults, err := monitor.FindWallpapers() + searchResults, err := wallutils.FindWallpapers() if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) diff --git a/cmd/lsmon/main.go b/cmd/lsmon/main.go index 55319ca..1a9ec23 100644 --- a/cmd/lsmon/main.go +++ b/cmd/lsmon/main.go @@ -4,12 +4,12 @@ import ( "fmt" "os" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" ) func main() { // Retrieve a slice of Monitor structs, or exit with an error - monitors, err := monitor.Detect() + monitors, err := wallutils.Monitors() if err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) @@ -19,7 +19,7 @@ func main() { if len(os.Args) > 1 && (os.Args[1] == "-dpi" || os.Args[1] == "-l") { fmt.Printf("%d: %dx%d (DPI: %dx%d)\n", mon.ID, mon.Width, mon.Height, mon.DPIw, mon.DPIh) } else if len(os.Args) > 1 && os.Args[1] == "--version" { - fmt.Println(monitor.VersionString) + fmt.Println(wallutils.VersionString) os.Exit(0) } else { fmt.Printf("%d: %dx%d\n", mon.ID, mon.Width, mon.Height) diff --git a/cmd/lstimed/main.go b/cmd/lstimed/main.go index 3975891..a447767 100644 --- a/cmd/lstimed/main.go +++ b/cmd/lstimed/main.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" "os" "text/tabwriter" ) @@ -13,7 +13,7 @@ func main() { // Prepare to write text in columns w := tabwriter.NewWriter(os.Stdout, 0, 0, 10, ' ', tabwriter.AlignRight) - searchResults, err := monitor.FindWallpapers() + searchResults, err := wallutils.FindWallpapers() if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) diff --git a/cmd/lswallpaper/main.go b/cmd/lswallpaper/main.go index 059f8e9..49daec4 100644 --- a/cmd/lswallpaper/main.go +++ b/cmd/lswallpaper/main.go @@ -2,16 +2,16 @@ package main import ( "fmt" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" "os" ) func main() { if len(os.Args) > 1 && os.Args[1] == "--version" { - fmt.Println(monitor.VersionString) + fmt.Println(wallutils.VersionString) os.Exit(0) } - searchResults, err := monitor.FindWallpapers() + searchResults, err := wallutils.FindWallpapers() if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) diff --git a/cmd/setcollection/main.go b/cmd/setcollection/main.go index c7e258c..73ac20b 100644 --- a/cmd/setcollection/main.go +++ b/cmd/setcollection/main.go @@ -5,11 +5,11 @@ import ( "os" "path/filepath" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" ) // Select the wallpaper that is closest to the current monitor resolution and set that as the wallpaper -func SelectAndSetWallpaper(wallpapers []*monitor.Wallpaper) error { +func SelectAndSetWallpaper(wallpapers []*wallutils.Wallpaper) error { // Gather a slice of filenames var filenames []string for _, wp := range wallpapers { @@ -17,7 +17,7 @@ func SelectAndSetWallpaper(wallpapers []*monitor.Wallpaper) error { } // Select the image that is closest to the monitor resolution - imageFilename, err := monitor.Closest(filenames) + imageFilename, err := wallutils.Closest(filenames) if err != nil { return err } @@ -34,7 +34,7 @@ func SelectAndSetWallpaper(wallpapers []*monitor.Wallpaper) error { } // Set the desktop wallpaper - if err := monitor.SetWallpaper(imageFilename); err != nil { + if err := wallutils.SetWallpaper(imageFilename); err != nil { return fmt.Errorf("Could not set wallpaper: %s\n", err) } @@ -51,7 +51,7 @@ func main() { fmt.Printf("Setting wallpaper collection \"%s\"\n", collectionName) fmt.Print("Searching for wallpapers...") - searchResults, err := monitor.FindWallpapers() + searchResults, err := wallutils.FindWallpapers() if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) diff --git a/cmd/setrandom/main.go b/cmd/setrandom/main.go index 8370ad0..66970d4 100644 --- a/cmd/setrandom/main.go +++ b/cmd/setrandom/main.go @@ -7,7 +7,7 @@ import ( "path/filepath" "time" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" ) func init() { @@ -16,7 +16,7 @@ func init() { func main() { if len(os.Args) > 1 && os.Args[1] == "--version" { - fmt.Println(monitor.VersionString) + fmt.Println(wallutils.VersionString) os.Exit(0) } @@ -55,7 +55,7 @@ func main() { os.Exit(1) } fmt.Println("Setting background image to: " + imageFilename) - if err := monitor.SetWallpaper(imageFilename); err != nil { + if err := wallutils.SetWallpaper(imageFilename); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } diff --git a/cmd/settimed/main.go b/cmd/settimed/main.go index 518b142..f4b1dd8 100644 --- a/cmd/settimed/main.go +++ b/cmd/settimed/main.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/xyproto/gnometimed" - "github.com/xyproto/monitor" "github.com/xyproto/simpletimed" + "github.com/xyproto/wallutils" ) func exists(path string) bool { @@ -40,7 +40,7 @@ func main() { fmt.Printf("Using: %s\n", stw.Path) } // Start endless event loop - if err := stw.EventLoop(verbose, func(path string) error { return monitor.SetWallpaperVerbose(path, verbose) }); err != nil { + if err := stw.EventLoop(verbose, func(path string) error { return wallutils.SetWallpaperVerbose(path, verbose) }); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } @@ -54,7 +54,7 @@ func main() { fmt.Printf("Using: %s\n", gtw.Path) } // Start endless event loop - if err := gtw.EventLoop(verbose, func(path string) error { return monitor.SetWallpaperVerbose(path, verbose) }); err != nil { + if err := gtw.EventLoop(verbose, func(path string) error { return wallutils.SetWallpaperVerbose(path, verbose) }); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } @@ -68,7 +68,7 @@ func main() { fmt.Printf("Setting wallpaper collection: %s\n", collectionName) fmt.Println("Searching for wallpapers...") } - searchResults, err := monitor.FindWallpapers() + searchResults, err := wallutils.FindWallpapers() if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) @@ -101,7 +101,7 @@ func main() { fmt.Printf("Using: %s\n", stw.Path) } // Start endless event loop - if err := stw.EventLoop(verbose, func(path string) error { return monitor.SetWallpaperVerbose(path, verbose) }); err != nil { + if err := stw.EventLoop(verbose, func(path string) error { return wallutils.SetWallpaperVerbose(path, verbose) }); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } @@ -111,7 +111,7 @@ func main() { fmt.Printf("Using: %s\n", gtw.Path) } // Start endless event loop - if err := gtw.EventLoop(verbose, func(path string) error { return monitor.SetWallpaperVerbose(path, verbose) }); err != nil { + if err := gtw.EventLoop(verbose, func(path string) error { return wallutils.SetWallpaperVerbose(path, verbose) }); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } diff --git a/cmd/setwallpaper/main.go b/cmd/setwallpaper/main.go index ade66e1..c4c6c4a 100644 --- a/cmd/setwallpaper/main.go +++ b/cmd/setwallpaper/main.go @@ -5,14 +5,14 @@ import ( "os" "path/filepath" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" ) const versionString = "setwallpaper" func main() { if len(os.Args) > 1 && os.Args[1] == "--version" { - fmt.Println(monitor.VersionString) + fmt.Println(wallutils.VersionString) os.Exit(0) } @@ -36,7 +36,7 @@ func main() { } // Set the desktop wallpaper - if err := monitor.SetWallpaper(imageFilename); err != nil { + if err := wallutils.SetWallpaper(imageFilename); err != nil { fmt.Fprintf(os.Stderr, "Could not set wallpaper: %s\n", err) os.Exit(1) } diff --git a/cmd/timedinfo/main.go b/cmd/timedinfo/main.go index 7f4102b..8ad0289 100644 --- a/cmd/timedinfo/main.go +++ b/cmd/timedinfo/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" "github.com/fatih/color" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" "strings" "os" @@ -16,7 +16,7 @@ func Indent(s string, prefix string) string { } func main() { - searchResults, err := monitor.FindWallpapers() + searchResults, err := wallutils.FindWallpapers() if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) diff --git a/cmd/wayinfo/main.go b/cmd/wayinfo/main.go index d90bc1f..c4776bb 100644 --- a/cmd/wayinfo/main.go +++ b/cmd/wayinfo/main.go @@ -4,12 +4,12 @@ import ( "fmt" "os" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" ) func main() { // Fetch the info string - info, err := monitor.WaylandInfo() + info, err := wallutils.WaylandInfo() if err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) diff --git a/cmd/xinfo/main.go b/cmd/xinfo/main.go index febf322..986e0b1 100644 --- a/cmd/xinfo/main.go +++ b/cmd/xinfo/main.go @@ -2,13 +2,13 @@ package main import ( "fmt" - "github.com/xyproto/monitor" + "github.com/xyproto/wallutils" "os" ) func main() { // Fetch the info string - info, err := monitor.XInfo() + info, err := wallutils.XInfo() if err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) diff --git a/cmd/xml2stw/SPEC.md b/cmd/xml2stw/SPEC.md index 5892bc1..51157d1 100644 --- a/cmd/xml2stw/SPEC.md +++ b/cmd/xml2stw/SPEC.md @@ -1,277 +1,3 @@ # Simple Timed Wallpaper Format Spec -A text format for specifying images and image transitions that make up timed wallpapers. - -## Version 1.0 - -Simple timed wallpapers are UTF-8 encoded text files. - -Every line may either start with `@`, for timing information, or with a field name followed by a colon `:` and a value. - -### Key/value fields - -The recognized fields are: - - * `stw` (required), for specifying the version of the Simple Timed Wallpaper Format, for example `1.0`. - * `name` (optional), for giving the timed wallpaper a name. - * `format` (optional), for specifying a format string that may contain a `%s` marker. The format string will be used in the timing information. - -After the fields, timing information may be specified. There are two types of timing information: static images or image transitions. - -### Static images - -Specifying a static image at a certain time, may look like this: - - @08:00: /usr/share/wallpapers/morning.jpg - -This will change the wallpaper to `/usr/share/wallpapers/morning.jpg` when the event triggers at `08:00`. - -Format description: - -* The line must start with `@` followed by two digits which is the hour number. -* Then comes a colon `:` and two digits which is the minute number. -* Then comes a colon `:`, an optional whitespace, and a filename. -* The filename should not be quoted, and spaces in the filename are allowed, without any escaping. - -Alternatively, a format string may be used. That would make the above example look like this: - - format: /usr/share/wallpapers/%s.jpg - @08:00: morning - -The `%s` marker will be replaced with the word `morning` when interpreting the filename for the `@08:00` event. - -### Image transitions - -Specifying an image transition, may look like this: - - @10:00-12:00: /usr/share/wallpapers/morning.jpg .. /usr/share/wallpapers/day.jpg | overlay - -This will change the wallpaper to `/usr/share/wallpapers/morning.jpg` at `10:00`, then cross fade it to `/usr/share/wallpapers/day.jpg` in the 2 hours from `10:00` to `12:00` and the transition type will be `overlay`. - -`overlay` is the default transition type and may be omitted. Implementing a cross fade between the first and second image is acceptable. - -It is up to the implementation how often the wallpaper should be updated in the transition period from `10:00` to `12:00`. The recommendation is 10 times, regardless of the length of the time interval. - -Format description: - -* The line must start with `@` followed by two digits which is the hour number. -* Then comes a colon `:` and two digits which is the minute number. -* Then comes an optional whitespace, a dash `-` and another optional whitespace. -* Then comes two digits which is the hour number. -* Then comes a colon `:` and two digits which is the minute number. -* The first of the two timestamps is inclusive, while the second one is exclusive. -* Then comes a colon `:`, an optional whitespace, and an image filename that will be transitioned from. -* Then comes an optional whitespace, two dots `..` and another optional whitespace. -* Then comes an image filename that will be transitioned to. -* The filenames should not be quoted, and spaces in the filename are allowed, without any escaping. -* After the filenames, an optional space, a pipe `|`, an optional space and a transition type may be specified. This is optional. -* The only supported transition type for version 1.0 of the Simple Timed Wallpaper Format is `overlay`, which is also the default transition type. - -Alternatively, a format string may be used. That would make the above example look like this: - - format: /usr/share/wallpapers/%s.jpg - @10:00-12:00: morning .. day - -## Real world examples - -Two examples of GNOME Timed Wallpaper XML files converted to the Simple Timed Wallpaper format follows. - -### mojave-timed - -**mojave-timed.xml** - -```xml - - - 2000 - 01 - 01 - 01 - 00 - 00 - - - - 14400.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0100.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0500.jpg - - - 3600.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0500.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0600.jpg - - - 3600.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0600.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0700.jpg - - - 3600.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0700.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0800.jpg - - - 3600.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0800.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0900.jpg - - - 3600.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0900.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1000.jpg - - - 3600.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1000.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1100.jpg - - - 3600.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1100.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1200.jpg - - - 4800.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1200.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1320.jpg - - - 4800.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1320.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1440.jpg - - - 4800.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1440.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1600.jpg - - - 4800.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1600.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1720.jpg - - - 4800.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1720.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1840.jpg - - - 4800.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-1840.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-2000.jpg - - - 3600.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-2000.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-2100.jpg - - - 14400.0 - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-2100.jpg - /usr/share/backgrounds/gnome/mojave/mojave_dynamic-0100.jpg - - -``` - -**mojave-timed.stw** - -```yml -stw: 1.0 -name: mojave-timed -format: /usr/share/backgrounds/gnome/mojave/mojave_dynamic-%s0.jpg -@01:00-05:00: 010 .. 050 -@05:00-06:00: 050 .. 060 -@06:00-07:00: 060 .. 070 -@07:00-08:00: 070 .. 080 -@08:00-09:00: 080 .. 090 -@09:00-10:00: 090 .. 100 -@10:00-11:00: 100 .. 110 -@11:00-12:00: 110 .. 120 -@12:00-13:20: 120 .. 132 -@13:20-14:40: 132 .. 144 -@14:40-16:00: 144 .. 160 -@16:00-17:20: 160 .. 172 -@17:20-18:40: 172 .. 184 -@18:40-20:00: 184 .. 200 -@20:00-21:00: 200 .. 210 -@21:00-01:00: 210 .. 010 -``` - -### adwaita-timed - -**adwaita-timed.xml** - -```xml - - - 2011 - 11 - 24 - 7 - 00 - 00 - - - - - - -3600.0 -/usr/share/backgrounds/gnome/adwaita-morning.jpg - - - - -18000.0 -/usr/share/backgrounds/gnome/adwaita-morning.jpg -/usr/share/backgrounds/gnome/adwaita-day.jpg - - - - -18000.0 -/usr/share/backgrounds/gnome/adwaita-day.jpg - - - - -21600.0 -/usr/share/backgrounds/gnome/adwaita-day.jpg -/usr/share/backgrounds/gnome/adwaita-night.jpg - - - - -18000.0 -/usr/share/backgrounds/gnome/adwaita-night.jpg - - - - -7200.0 -/usr/share/backgrounds/gnome/adwaita-night.jpg -/usr/share/backgrounds/gnome/adwaita-morning.jpg - - -``` - -**adwaita-timed.stw** - -```yml -stw: 1.0 -name: adwaita-timed -format: /usr/share/backgrounds/gnome/adwaita-%s.jpg -@07:00: morning -@08:00-13:00: morning .. day -@13:00: day -@18:00-00:00: day .. night -@00:00: night -@05:00-07:00: night .. morning -``` - -### Final remarks - -The `xml2stw` utility can be used for converting GNOME timed XML files to the Simple Timed Wallpaper format. It was used for converting the examples above. - -This is a draft. Pull requests are welcome: https://github.com/xyproto/monitor/pulls +* [Simple Timed Wallpaper Format Spec 1.0](https://github.com/xyproto/simpletimed/blob/1.0.0/SPEC.md) diff --git a/collections.go b/collections.go index 9c1cb42..b4b4c71 100644 --- a/collections.go +++ b/collections.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "github.com/stretchr/powerwalk" diff --git a/deepin.go b/deepin.go index 909bbdf..bd3ad64 100644 --- a/deepin.go +++ b/deepin.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // Deepin windowmanager detector type Deepin struct { diff --git a/feh.go b/feh.go index aa50ee7..e48eea4 100644 --- a/feh.go +++ b/feh.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // This is the fallback if no specific windowmanager has been detected diff --git a/gnome2.go b/gnome2.go index bfa5f74..2f915e3 100644 --- a/gnome2.go +++ b/gnome2.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // Gnome2 windowmanager detector type Gnome2 struct { diff --git a/gnome3.go b/gnome3.go index 8ff8636..2efbd0b 100644 --- a/gnome3.go +++ b/gnome3.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // Gnome3 windowmanager detector type Gnome3 struct { diff --git a/go.mod b/go.mod index 6028f75..734d880 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,6 @@ -module github.com/xyproto/monitor +module github.com/xyproto/wallutils require ( - github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.7.0 github.com/mattn/go-colorable v0.1.0 // indirect github.com/mattn/go-isatty v0.0.4 // indirect diff --git a/go.sum b/go.sum index 9c7bb48..8e02c18 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/mattn/go-colorable v0.1.0 h1:v2XXALHHh6zHfYTJ+cSkwtyffnaOyR1MXaA91mTrb8o= diff --git a/mate.go b/mate.go index 07ec33e..7bf6a41 100644 --- a/mate.go +++ b/mate.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // Mate windowmanager detector type Mate struct { diff --git a/monitor.go b/monitor.go index 88405df..3e350dc 100644 --- a/monitor.go +++ b/monitor.go @@ -1,5 +1,5 @@ // monitor is a package for dealing with monitors, resolution, dpi, wallpapers, wallpaper collections, timed wallpapers and converting to the Simple Timed Wallpaper format. -package monitor +package wallutils import ( "errors" @@ -35,9 +35,9 @@ func Info() (string, error) { return "", errNoWaylandNoX } -// Detect returns information about all monitors, regardless of if it's under +// Monitors returns information about all monitors, regardless of if it's under // Wayland or X11. Will use additional plugins, if available. -func Detect() ([]Monitor, error) { +func Monitors() ([]Monitor, error) { IDs, widths, heights, wDPIs, hDPIs := []uint{}, []uint{}, []uint{}, []uint{}, []uint{} if WaylandCanConnect() { if err := WaylandMonitors(&IDs, &widths, &heights, &wDPIs, &hDPIs); err != nil { diff --git a/plasma.go b/plasma.go index 4acfed6..2ac33ac 100644 --- a/plasma.go +++ b/plasma.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // Plasma windowmanager detector type Plasma struct { diff --git a/res.go b/res.go index 1c5575b..0b9f875 100644 --- a/res.go +++ b/res.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "errors" @@ -39,7 +39,7 @@ func Distance(a, b *Res) int { // AverageResolution returns the average resolution for all connected monitors. func AverageResolution() (*Res, error) { - monitors, err := Detect() + monitors, err := Monitors() if err != nil { return nil, err } diff --git a/res_test.go b/res_test.go index bcd8f44..3b68895 100644 --- a/res_test.go +++ b/res_test.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "fmt" diff --git a/sway.go b/sway.go index caaf882..d811fc4 100644 --- a/sway.go +++ b/sway.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // Sway windowmanager detector type Sway struct { diff --git a/utils.go b/utils.go index cc91ea2..1f86300 100644 --- a/utils.go +++ b/utils.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "fmt" diff --git a/wallpaper.go b/wallpaper.go index 3ae8646..101d0ed 100644 --- a/wallpaper.go +++ b/wallpaper.go @@ -1,5 +1,5 @@ // Package wallpaper provides a way to set the desktop wallpaper, for any windowmanager -package monitor +package wallutils import ( "errors" diff --git a/wayinfo.go b/wayinfo.go index 63fee48..20885fb 100644 --- a/wayinfo.go +++ b/wayinfo.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // #cgo LDFLAGS: -lwayland-client //#include "wayinfo.h" diff --git a/wayinfo_test.go b/wayinfo_test.go index 1d57412..7be8fc7 100644 --- a/wayinfo_test.go +++ b/wayinfo_test.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "fmt" diff --git a/weston.go b/weston.go index bdee7fc..2b7dc07 100644 --- a/weston.go +++ b/weston.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "errors" diff --git a/x11.go b/x11.go index 6ca0c8d..2fc4a1e 100644 --- a/x11.go +++ b/x11.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // #cgo LDFLAGS: -lX11 // #include "xwallpaper.h" diff --git a/xfce4.go b/xfce4.go index a290a2f..7d024fe 100644 --- a/xfce4.go +++ b/xfce4.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "errors" diff --git a/xinfo.go b/xinfo.go index da7875c..471cf99 100644 --- a/xinfo.go +++ b/xinfo.go @@ -1,4 +1,4 @@ -package monitor +package wallutils // #cgo LDFLAGS: -lX11 // #include "xinfo.h" diff --git a/xinfo_test.go b/xinfo_test.go index 0d1413b..47cbbd3 100644 --- a/xinfo_test.go +++ b/xinfo_test.go @@ -1,4 +1,4 @@ -package monitor +package wallutils import ( "fmt"