wallpaper

package module
v0.0.0-...-fbd022e Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: Unlicense Imports: 16 Imported by: 0

README

wallpaper godoc

A cross-platform (Linux, Windows, and macOS) Golang library for getting and setting the desktop background.

Installation

go get github.com/reujab/wallpaper

Example

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")
}

Notes

  • Enlightenment is not supported.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Desktop = os.Getenv("XDG_CURRENT_DESKTOP")

Desktop contains the current desktop environment on Linux. Empty string on all other operating systems.

View Source
var DesktopSession = os.Getenv("DESKTOP_SESSION")
View Source
var ErrUnsupportedDE = errors.New("your desktop environment is not supported")

ErrUnsupportedDE is thrown when Desktop is not a supported desktop environment.

Functions

func Get

func Get() (string, error)

Get returns the current wallpaper.

func SetFromFile

func SetFromFile(file string) error

SetFromFile sets wallpaper from a file path.

func SetFromURL

func SetFromURL(url string) error

SetFromURL sets wallpaper from a URL.

In GNOME, it sets org.gnome.desktop.background.picture-uri to the URL. In other desktops, it downloads the image and calls SetFromFile.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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