wallpaper

package module
v0.0.0-...-5f9f655 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Unlicense Imports: 13 Imported by: 75 modules, 75 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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()
	check(err)
	fmt.Println("Current wallpaper:", background)

	err = wallpaper.SetFromFile("/usr/share/backgrounds/gnome/adwaita-day.jpg")
	check(err)

	err = wallpaper.SetFromURL("https://i.imgur.com/pIwrYeM.jpg")
	check(err)

	err = wallpaper.SetMode(wallpaper.Crop)
	check(err)
}

Supported desktops

  • Windows
  • macOS
  • GNOME
  • KDE
  • Cinnamon
  • Unity
  • Budgie
  • XFCE
  • LXDE
  • MATE
  • Deepin
  • Most Wayland compositors (set only, requires swaybg)
  • i3 (set only, requires feh)

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

DesktopSession is used by LXDE on Linux.

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 downloads the image to a cache directory and calls SetFromFile.

func SetMode

func SetMode(mode Mode) error

SetMode sets the wallpaper mode.

Types

type Mode

type Mode int
const (
	Center Mode = iota
	Crop
	Fit
	Span
	Stretch
	Tile
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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