A cross-platform (Linux, Windows, and macOS) Golang library for getting and setting the desktop background.
go get github.com/reujab/wallpaper
package main
import (
"fmt"
"github.com/reujab/wallpaper"
)
func main() {
background, err := wallpaper.Get()
if err != nil {
panic(err)
}
fmt.Println("Current wallpaper:", background)
wallpaper.SetFromFile("/usr/share/backgrounds/gnome/adwaita-day.jpg")
wallpaper.SetFromURL("https://i.imgur.com/pIwrYeM.jpg")
}
- On Windows and KDE, you must log out and in again for the background to update.
- Enlightenment is not supported.