wallpaper

package module
v0.0.0-...-7dd872c Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 9 Imported by: 0

README

wallpaper

A KDE Golang library for getting and setting the desktop background.

Installation

go get gitea.s1.thoxy.xyz/thoxy/wallpaper

Example

package main

import (
	"fmt"

	"gitea.s1.thoxy.xyz/thoxy/wallpaper"
)

func main() {
	backgrounds, err := wallpaper.Get()

	if err != nil {
		panic(err)
	}

	fmt.Println("Current wallpaper:", backgrounds)

	err = wallpaper.SetFromFile("/usr/share/backgrounds/gnome/adwaita-day.jpg", 1)
	if err != nil {
		panic(err)
	}

	err = wallpaper.SetFromURL("https://i.imgur.com/pIwrYeM.jpg", 0)
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
	err = wallpaper.SetFromURL("https://i.imgur.com/pIwrYeM.jpg", 1)
	if err != nil {
		panic(err)
	}
}

Supported desktops

  • KDE

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.

Functions

func Get

func Get() ([]string, error)

Get returns the current wallpaper.

func SetFromFile

func SetFromFile(file string, screen int) error

SetFromFile sets wallpaper from a file path.

func SetFromURL

func SetFromURL(url string, screen int) error

SetFromURL downloads the image to a cache directory and calls SetFromFile.

func SetMode

func SetMode(mode Mode, screen int) 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