wallutils

package module
v0.0.0-...-6dcbf21 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: BSD-3-Clause Imports: 22 Imported by: 1

README

Wallutils Build GoDoc License Go Report Card

  • 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).
  • Introduces a new file format for timed wallpapers: The Simple Timed Wallpaper format: Markdown | PDF.
  • GNOME timed wallpapers can be converted to the Simple Timed Wallpaper format with the xml2stw utility.
  • macOS dynamic wallpapers (in the HEIF format with the .heic extension) can be installed with heic-install and used with lstimed and settimed. This extracts the metadata with heic2stw (only timing information, not the azimuth and elevation for the sun, yet) and extracts the images with convert that comes with ImageMagick.

Packaging status

Timed Wallpapers

The Mojave timed wallpaper and other timed wallpapers can be set with the settimed command, and will cross fade from image to image as the day progresses:

Dynamic wallpaper example

Note that some window managers makes it hard to achieve smooth switches of desktop backgrounds, while others makes it easy.

Included utilities

  • getdpi, for retrieving the average DPI, for all monitors (use -b to see the DPI both horizontally and vertically).
  • lscollection, for listing installed wallpaper collections (use -l for also listing paths and collection names).
  • timedinfo, for showing more information about installed timed wallpapers.
  • lsmon lists the connected monitors and resolutions that are discovered by the current WM/DE (use -d for also listing DPI).
  • lstimed for listing installed timed wallpapers (use -l for also listing paths).
  • lswallpaper, for listing all installed wallpapers (use -l and -s to list more information).
  • setcollection, for setting a suitable (in terms of resolution) wallpaper from a wallpaper collection.
  • setrandom, for setting a random wallpaper.
  • settimed, for setting timed wallpapers (will continue to run, to handle time events). (This utility has recently been refactored and needs more testing).
  • 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 current X setup.
  • xml2stw for converting GNOME timed wallpapers to the Simple Timed Wallpaper format.
  • heic2stw for extracting the timing information from macOS dynamic wallpapers (.heic files) to the Simple Timed Wallpaper format.
  • vram for finding the minimum amount of VRAM available for non-integrated GPUs (use -l to list the bus ID, a description and available VRAM for each GPU).

Included scripts

  • heic-install for installing a macOS dynamic wallpaper to /usr/share/backgrounds using both ImageMagick convert and heic2stw.

Example use of the lsmon utility

$ lsmon
0: 1920x1200
1: 1920x1200
2: 1920x1200

Installing wallutils

Arch Linux
pacman -S wallutils
Fedora

With sudo, or as root, install the required dependencies:

sudo dnf update
sudo dnf install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install git golang ImageMagick libXcursor-devel libXmu-devel xorg-x11-xbitmaps libheif-devel wayland-devel

As a user, clone the repository and build the utilities:

git clone https://github.com/xyproto/wallutils
cd wallutils
make

Then with sudo, or as root, install the utilities:

sudo make PREFIX=/usr/local install
Debian 11

With sudo, or as root, install the required dependencies:

sudo apt install git golang imagemagick libx11-dev libxcursor-dev libxmu-dev libwayland-dev libxpm-dev xbitmaps libxmu-headers libheif-dev make

As a user, clone the repository and build the utilities:

git clone https://github.com/xyproto/wallutils
cd wallutils
make

Then with sudo, or as root, install the utilities:

sudo make PREFIX=/usr/local install

Installing a single utility

Using Go 1.17 or later, install ie. the getdpi utility:

go install github.com/xyproto/wallutils/cmd/getdpi@latest

Wayland or X only

The executables related to X can be removed after building if you only wish to keep the Wayland-related functionality. And the same for Wayland.

Example use of settimed

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)
package main

import (
    "fmt"
    "os"

    "github.com/xyproto/wallutils"
)

func main() {
    // Retrieve a slice of Monitor structs, or exit with an error
    monitors, err := wallutils.Monitors()
    if err != nil {
        fmt.Fprintf(os.Stderr, "%s\n", err)
        os.Exit(1)
    }
    // For every monitor, output the ID, width and height
    for _, monitor := range monitors {
        fmt.Printf("%d: %dx%d\n", monitor.ID, monitor.Width, monitor.Height)
    }
}
Change the wallpaper
fmt.Println("Setting background image to: " + imageFilename)
if err := wallutils.SetWallpaper(imageFilename); err != nil {
    return err
}

Build requirements

  • Go 1.11 or later. 1.17 or later is recommended.
  • A working C compiler (tested with GCC 8.2.1).
  • Header files for Wayland and X.
  • libheif for heic2stw and heic-install.

Runtime requirements

  • libwayland-client.so, for Wayland support.
  • libX11.so, for X support.
  • libheif.so for HEIF/.heic image support.

It is also possible to build with make static, to only build the utilities that does not depend on any of the above .so files, as statically compiled ELF executables.

  • swaybg and pkill for Wayland-based window managers like Labwc.

The vram utility depends on lspci (from pciutils) and also nvidia-smi for NVIDIA GPUs.

Wallpaper collections

The XML format from GNOME for specifying wallpaper collections is not yet supported (and I'm not sure if it's needed). Creating a directory with images where the filename of the images specify the resolution (like wallpaper_5639x3561.jpg) is enough for lscollection to recognize it as a collection (if the directory is placed in /usr/share/backgrounds or /usr/share/wallpapers).

Refreshing the wallpaper after waking from sleep

Send the USR1 signal to the settimed process:

pkill settimed -USR1

This should refresh the wallpaper.

A note about i3

  • When using wallutils together with i3, it works best with also having feh and imlib2 installed.

Setting a wallpaper per monitor

  • Setting a wallpaper per monitor is not supported, yet. Currently, a wallpaper is set for all monitors.

General info

Documentation

Overview

Package wallutils can deal with monitors, resolution, dpi, wallpapers, wallpaper collections, timed wallpapers and converting GNOME timed wallpapers to the Simple Timed Wallpaper format.

Index

Examples

Constants

View Source
const VersionString = "5.12.7"

VersionString is the current version of wallutils and all included utilities

Variables

View Source
var DefaultWallpaperDirectories = []string{
	"/usr/share/pixmaps",
	"/usr/share/wallpapers",
	"/usr/share/backgrounds",
	"/usr/local/share/pixmaps",
	"/usr/local/share/wallpapers",
	"/usr/local/share/backgrounds",
	"/usr/share/archlinux",
}

DefaultWallpaperDirectories lists the default locations to look for wallpapers

View Source
var WMs = []WM{
	&Sway{},
	&Deepin{},
	&Xfce4{},
	&Mate{},
	&Cinnamon{},
	&Plasma{},
	&Gnome3{},
	&Gnome2{},
	&Pekwm{},
	&SwayBG{},
	&Weston{},

	&Feh{},
}

WMs contains all available backends for changing the wallpaper Some backends may require cgo (sway + x11)

Functions

func Closest

func Closest(filenames []string) (string, error)

Closest does the same as ClosestByResolutionInfilename. It is provided for backwards compatibility.

func ClosestByResolutionInFilename

func ClosestByResolutionInFilename(filenames []string) (string, error)

ClosestByResolutionInFilename takes a list of filenames on the form "*_WIDTHxHEIGHT.ext", where WIDTH and HEIGHT are numbers. The filename that is closest to the average monitor resolution is returned. Any filenames not following the pattern will cause an error being returned.

func CommonPrefix

func CommonPrefix(sl []string) string

CommonPrefix will find the longest common prefix in a slice of strings

func CommonSuffix

func CommonSuffix(sl []string) string

CommonSuffix will find the longest common suffix in a slice of strings

func Distance

func Distance(a, b *Res) int

Distance returns the distance between two resolutions (Euclidean distance)

func FindImagesAt

func FindImagesAt(searchPath string, _ []string, onlyLarge bool) ([]string, error)

FindImagesAt will find images at the given search path. Set onlyLarge to true if the images should be large enough for the desktop.

func Info

func Info() (string, error)

Info returns a long info string that looks different for Wayland and for X. The string contains all available information about the connected monitors.

func Meat

func Meat(s, prefix, suffix string) string

Meat returns the meat of the string: the part that is after the prefix and before the suffix. It does not check if the prefix and suffix exists in the string. If the given string is too short to contain the prefix and suffix, it will be returned as it is.

func MonConfOverlap

func MonConfOverlap(filename string) bool

MonConfOverlap is a convenience function for checking if the x,y,w,h monitor configurations in ie. ~/.config/monitors.xml are overlapping or not. If monitors.xml can not be parsed or read, false is returned.

func NewRect

func NewRect(x, y, w, h uint) image.Rectangle

NewRect is a convenience function for creating an image.Rectangle, given the upper left corner (x and y), a width and a height.

func NoXRandrOverlapOrExit

func NoXRandrOverlapOrExit(verbose bool)

NoXRandrOverlapOrExit is a convenience function for making sure monitor configurations are not overlapping, as reported by "xrandr".

func Overlaps

func Overlaps(rects []image.Rectangle) bool

Overlaps checks if any rectangles in a slice of rectangles overlaps.

func ParseSize

func ParseSize(widthHeight string) (uint, uint, error)

ParseSize parses a string on the form "1234x1234"

func Quit

func Quit(err error)

Quit with a nicely formatted error message to stderr

func SetWallpaper

func SetWallpaper(imageFilename string) error

SetWallpaper will set the desktop wallpaper, for any supported windowmanager. The fallback is to use `feh`. The wallpaper mode is "fill".

func SetWallpaperCustom

func SetWallpaperCustom(imageFilename, mode string, verbose bool) error

SetWallpaperCustom will set the given image filename as the wallpaper, regardless of which display server, window manager or desktop environment is in use.

func SetWallpaperVerbose

func SetWallpaperVerbose(imageFilename string, verbose bool) error

SetWallpaperVerbose will set the desktop wallpaper, for any supported windowmanager. The fallback is to use `feh`. The wallpaper mode is "fill".

func WaylandCanConnect

func WaylandCanConnect() bool

WaylandCanConnect checks if a Wayland server is up and running

func WaylandInfo

func WaylandInfo() (string, error)

WaylandInfo returns a long info string about the current Wayland setup

func WaylandMonitors

func WaylandMonitors(IDs, widths, heights, wDPIs, hDPIs *[]uint) error

WaylandMonitors returns information about the available monitors. The given slices are filled with data about resolution and DPI.

func XCanConnect

func XCanConnect() bool

XCanConnect checks if an X server is up and running

func XInfo

func XInfo() (string, error)

XInfo returns a long info string about the current X server setup

func XMonitors

func XMonitors(IDs, widths, heights, wDPIs, hDPIs *[]uint) error

XMonitors returns information about the available monitors. The given slices are filled with data about resolution and DPI.

Types

type Cinnamon

type Cinnamon struct {
	// contains filtered or unexported fields
}

Cinnamon windowmanager detector

func (*Cinnamon) ExecutablesExists

func (c *Cinnamon) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Cinnamon) Name

func (c *Cinnamon) Name() string

Name returns the name of this window manager or desktop environment

func (*Cinnamon) Running

func (c *Cinnamon) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Cinnamon) SetMode

func (c *Cinnamon) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Cinnamon) SetVerbose

func (c *Cinnamon) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Cinnamon) SetWallpaper

func (c *Cinnamon) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type Deepin

type Deepin struct {
	// contains filtered or unexported fields
}

Deepin windowmanager detector

func (*Deepin) ExecutablesExists

func (d *Deepin) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Deepin) Name

func (d *Deepin) Name() string

Name returns the name of this window manager or desktop environment

func (*Deepin) Running

func (d *Deepin) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Deepin) SetMode

func (d *Deepin) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Deepin) SetVerbose

func (d *Deepin) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Deepin) SetWallpaper

func (d *Deepin) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type Feh

type Feh struct {
	// contains filtered or unexported fields
}

Feh is a structure containing settings for running the "feh" executable

func (*Feh) ExecutablesExists

func (f *Feh) ExecutablesExists() bool

ExecutablesExists checks if the feh executable exists in the PATH

func (*Feh) Name

func (f *Feh) Name() string

Name returns the name of this method of setting a wallpaper

func (*Feh) Running

func (f *Feh) Running() bool

Running just returns true for the Feh backend, since this is an application and not a WM / DM

func (*Feh) SetMode

func (f *Feh) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc). The selected mode must be compatible with feh.

func (*Feh) SetVerbose

func (f *Feh) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Feh) SetWallpaper

func (f *Feh) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable. `feh` is used for setting the desktop background, and must be in the PATH.

type GPU

type GPU struct {
	ID   uint   // GPU number, from 0 and up
	Name string // GPU name
	VRAM uint   // VRAM, in MiB
	VGA  bool   // Integrated / shows up as "VGA" with lspci
	Bus  string // ie. 01:00.0
}

GPU contains an ID and the VRAM in MiB

func GPUs

func GPUs(alsoIntegrated bool) ([]GPU, error)

GPUs returns information about all available GPUs. This function will run "nvidia-smi" or any needed utility in order to collect the information. If alsoIntegrated is set to true, also integrated graphic cards will be detected (listed as "VGA" in the lspci output, or contains the string "UHD")

func (GPU) String

func (gpu GPU) String() string

String returns a string with GPU ID and VRAM in MiB

type GSettings

type GSettings struct {
	// contains filtered or unexported fields
}

GSettings can be used for getting and setting configuration options with gsettings

func NewGSettings

func NewGSettings(schema string, verbose bool) *GSettings

NewGSettings creates a new GSettings struct given a schema/category and a bool for if the commands should be printed to stdout before running.

func (*GSettings) Get

func (g *GSettings) Get(key string) string

Get a key using gsettings. Will return an empty string if there are errors.

func (*GSettings) Set

func (g *GSettings) Set(key, value string) error

Set a key using gsettings. Will single-quote the given value.

type Gnome2

type Gnome2 struct {
	// contains filtered or unexported fields
}

Gnome2 windowmanager detector

func (*Gnome2) ExecutablesExists

func (g2 *Gnome2) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Gnome2) Name

func (g2 *Gnome2) Name() string

Name returns the name of this window manager or desktop environment

func (*Gnome2) Running

func (g2 *Gnome2) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Gnome2) SetMode

func (g2 *Gnome2) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Gnome2) SetVerbose

func (g2 *Gnome2) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Gnome2) SetWallpaper

func (g2 *Gnome2) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type Gnome3

type Gnome3 struct {
	// contains filtered or unexported fields
}

Gnome3 windowmanager detector

func (*Gnome3) ExecutablesExists

func (g3 *Gnome3) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Gnome3) Name

func (g3 *Gnome3) Name() string

Name returns the name of this window manager or desktop environment

func (*Gnome3) Running

func (g3 *Gnome3) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Gnome3) SetMode

func (g3 *Gnome3) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Gnome3) SetVerbose

func (g3 *Gnome3) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Gnome3) SetWallpaper

func (g3 *Gnome3) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type MConfiguration

type MConfiguration struct {
	XMLName xml.Name  `xml:"configuration"`
	Clone   string    `xml:"clone,omitempty"`
	Outputs []MOutput `xml:"output"`
}

MConfiguration is mainly a collection of MOutput + a Clone field

type MOutput

type MOutput struct {
	XMLName  xml.Name `xml:"output"`
	Name     string   `xml:"name,attr"`
	Vendor   string   `xml:"vendor,omitempty"`
	Product  string   `xml:"product,omitempty"`
	Serial   string   `xml:"serial,omitempty"`
	Width    string   `xml:"width,omitempty"`
	Height   string   `xml:"height,omitempty"`
	Rate     string   `xml:"rate,omitempty"`
	X        string   `xml:"x,omitempty"`
	Y        string   `xml:"y,omitempty"`
	Rotation string   `xml:"rotation,omitempty"`
	ReflectX string   `xml:"reflect_x,omitempty"`
	ReflectY string   `xml:"reflect_y,omitempty"`
	Primary  string   `xml:"primary,omitempty"`
}

MOutput represents a monitor configuration, including: width, height, rotation and if the monitor is the primary monitor.

type Mate

type Mate struct {
	// contains filtered or unexported fields
}

Mate windowmanager detector

func (*Mate) ExecutablesExists

func (m *Mate) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Mate) Name

func (m *Mate) Name() string

Name returns the name of this window manager or desktop environment

func (*Mate) Running

func (m *Mate) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Mate) SetMode

func (m *Mate) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Mate) SetVerbose

func (m *Mate) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Mate) SetWallpaper

func (m *Mate) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type Monitor

type Monitor struct {
	ID     uint // monitor number, from 0 and up
	Width  uint // width, in pixels
	Height uint // height, in pixels
	DPIw   uint // DPI, if available (width)
	DPIh   uint // DPI, if available (height)
}

Monitor contains an ID, the width in pixels and the height in pixels

func Monitors

func Monitors() ([]Monitor, error)

Monitors returns information about all monitors, regardless of if it's under Wayland or X11. Will use additional plugins, if available.

func (Monitor) String

func (m Monitor) String() string

String returns a string with monitor ID and resolution

type MonitorConfiguration

type MonitorConfiguration struct {
	XMLName        xml.Name         `xml:"monitors"`
	Version        string           `xml:"version,attr"`
	Configurations []MConfiguration `xml:"configuration"`
}

MonitorConfiguration is mainly a collection of MConfiguration + a Version field

func NewMonitorConfiguration

func NewMonitorConfiguration() (*MonitorConfiguration, error)

NewMonitorConfiguration returns a new MonitorConfiguration struct, filled with the contents of ~/.config/monitors.xml.

func ParseMonitorFile

func ParseMonitorFile(filename string) (*MonitorConfiguration, error)

ParseMonitorFile can parse monitor XML files, like the one that typically exists in ~/.config/monitors.xml

func (*MonitorConfiguration) Overlapping

func (mc *MonitorConfiguration) Overlapping() bool

Overlapping can check if configurations in monitors.xml have overlapping areas.

type Pekwm

type Pekwm struct {
	// contains filtered or unexported fields
}

Pekwm is a structure containing settings for running the "pekwm_bg" executable

func (*Pekwm) ExecutablesExists

func (f *Pekwm) ExecutablesExists() bool

ExecutablesExists checks if the "pekwm_bg" executable exists in the PATH (comes with pekwm 0.2.0 or later)

func (*Pekwm) Name

func (f *Pekwm) Name() string

Name returns the name of this method of setting a wallpaper

func (*Pekwm) Running

func (f *Pekwm) Running() bool

Running checks if $PEKWM_CONFIG_FILE is set

func (*Pekwm) SetMode

func (f *Pekwm) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc). The selected mode must be compatible with pekwm_bg.

func (*Pekwm) SetVerbose

func (f *Pekwm) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Pekwm) SetWallpaper

func (f *Pekwm) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type Plasma

type Plasma struct {
	// contains filtered or unexported fields
}

Plasma windowmanager detector

func (*Plasma) ExecutablesExists

func (p *Plasma) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Plasma) Name

func (p *Plasma) Name() string

Name returns the name of this window manager or desktop environment

func (*Plasma) Running

func (p *Plasma) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Plasma) SetMode

func (p *Plasma) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Plasma) SetVerbose

func (p *Plasma) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Plasma) SetWallpaper

func (p *Plasma) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type Res

type Res struct {
	// contains filtered or unexported fields
}

Res is a structure containing width and height

func AverageResolution

func AverageResolution() (*Res, error)

AverageResolution returns the average resolution for all connected monitors.

func ExtractResolutions

func ExtractResolutions(filenames []string) ([]*Res, error)

ExtractResolutions extracts Res structs from a slice of filenames All the filenames must be on the form *_WIDTHxHEIGHT.ext, where WIDTH and HEIGHT are numbers.

func FilenameToRes

func FilenameToRes(filename string) (*Res, error)

FilenameToRes extracts width and height from a filename on the form: "asdf_123x123.xyz", or filenames that are just on the form "123x123.xyz".

Example
fn := "hello_there_320x200.png"
res, err := FilenameToRes(fn)
if err != nil {
	panic(err)
}
fmt.Println(res)
Output:

320x200

func NewRes

func NewRes(w, h uint) *Res

NewRes creates a new resolution structure

func (*Res) H

func (r *Res) H() uint

H is the height

func (*Res) String

func (r *Res) String() string

func (*Res) W

func (r *Res) W() uint

W is the width

type SearchResults

type SearchResults struct {
	// contains filtered or unexported fields
}

SearchResults is a struct containing all found wallpaper collections, of these types: * wallpaper images (several in one directory, of different sizes) * gnome wallpapers (contains a GNOME-compatible XML file) * sime timed wallpapers (contains a .stw file)

func FindWallpapers

func FindWallpapers() (*SearchResults, error)

FindWallpapers will search for wallpaper collections, simple timed wallpapers and GNOME timed wallpapers in all default wallpaper directories on the system.

func FindWallpapersAt

func FindWallpapersAt(path string) (*SearchResults, error)

FindWallpapersAt will search for wallpaper collections, simple timed wallpapers and GNOME timed wallpapers in the given path.

func NewSearchResults

func NewSearchResults() *SearchResults

NewSearchResults will reset the search and prepare to search again

func (*SearchResults) CollectionNames

func (sr *SearchResults) CollectionNames() []string

CollectionNames gathers all the names of all available wallpaper packs or GNOME timed backgrounds

func (*SearchResults) Empty

func (sr *SearchResults) Empty() bool

Empty checks if these search results are empty

func (*SearchResults) GnomeTimedWallpapers

func (sr *SearchResults) GnomeTimedWallpapers() []*gnometimed.Wallpaper

GnomeTimedWallpapers returns a sorted slice of all found gnome timed wallpapers

func (*SearchResults) GnomeTimedWallpapersByName

func (sr *SearchResults) GnomeTimedWallpapersByName(name string) []*gnometimed.Wallpaper

GnomeTimedWallpapersByName will return gnome timed wallpapers that match with the collection name

func (*SearchResults) NoTimedWallpapers

func (sr *SearchResults) NoTimedWallpapers() bool

NoTimedWallpapers checks if the current search results contains no timed wallpapers

func (*SearchResults) SimpleTimedWallpapers

func (sr *SearchResults) SimpleTimedWallpapers() []*simpletimed.Wallpaper

SimpleTimedWallpapers returns a sorted slice of all found simple timed wallpapers

func (*SearchResults) SimpleTimedWallpapersByName

func (sr *SearchResults) SimpleTimedWallpapersByName(name string) []*simpletimed.Wallpaper

SimpleTimedWallpapersByName will return simple timed wallpapers that match with the collection name

func (*SearchResults) Wallpapers

func (sr *SearchResults) Wallpapers() []*Wallpaper

Wallpapers returns a sorted slice of all found wallpapers

func (*SearchResults) WallpapersByName

func (sr *SearchResults) WallpapersByName(name string) []*Wallpaper

WallpapersByName will return simple timed wallpapers that match with the collection name

type Sway

type Sway struct {
	// contains filtered or unexported fields
}

Sway windowmanager detector

func (*Sway) ExecutablesExists

func (s *Sway) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Sway) Name

func (s *Sway) Name() string

Name returns the name of this window manager or desktop environment

func (*Sway) Running

func (s *Sway) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Sway) SetMode

func (s *Sway) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Sway) SetVerbose

func (s *Sway) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Sway) SetWallpaper

func (s *Sway) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type SwayBG

type SwayBG struct {
	// contains filtered or unexported fields
}

SwayBG compatible windowmanager

func (*SwayBG) ExecutablesExists

func (sb *SwayBG) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*SwayBG) Name

func (sb *SwayBG) Name() string

Name returns the name of this window manager or desktop environment

func (*SwayBG) Running

func (sb *SwayBG) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*SwayBG) SetMode

func (sb *SwayBG) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*SwayBG) SetVerbose

func (sb *SwayBG) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*SwayBG) SetWallpaper

func (sb *SwayBG) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type WM

type WM interface {
	Name() string
	ExecutablesExists() bool
	Running() bool
	SetWallpaper(string) error
	SetVerbose(bool)
	SetMode(string)
}

WM is an interface with the functions that needs to be implemented for adding support for setting the wallpaper for a new WM or DE

type Wallpaper

type Wallpaper struct {
	CollectionName   string // the name of the directory containing this wallpaper, if it's not "pixmaps", "images" or "contents". May use the parent of the parent.
	Path             string // full path to the image filename
	Width            uint   // width of the image
	Height           uint   // height of the image
	PartOfCollection bool   // likely to be part of a wallpaper collection
}

Wallpaper represents an image file that is part of a wallpaper collection (in a directory with several resolutions of the same image, for example)

func ClosestByResolution

func ClosestByResolution(wallpapers []*Wallpaper) (*Wallpaper, error)

ClosestByResolution returns a wallpaper that is closest to the average monitor resolution. If several wallpapers matches, a random one is returned. The idea is that a slice of wallpapers in a wallpaper collection with several available resolutions is given as input, and a suitable wallpaper is returned.

func (*Wallpaper) Res

func (wp *Wallpaper) Res() *Res

Res returns the wallpaper resolution as a Res struct

func (*Wallpaper) String

func (wp *Wallpaper) String() string

String returns a string with information about the wallpaper: - if it's part of a wallpaper collection or not - width - height - collection name - path

type Weston

type Weston struct {
	// contains filtered or unexported fields
}

Weston windowmanager detector

func (*Weston) ExecutablesExists

func (w *Weston) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Weston) Name

func (w *Weston) Name() string

Name returns the name of this window manager or desktop environment

func (*Weston) Running

func (w *Weston) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Weston) SetMode

func (w *Weston) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Weston) SetVerbose

func (w *Weston) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Weston) SetWallpaper

func (*Weston) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

type XRandr

type XRandr struct {
	// contains filtered or unexported fields
}

XRandr can contain information that has been extracted by running the xrandr executable

func NewXRandr

func NewXRandr(verbose bool) (*XRandr, error)

NewXRandr creates a new XRandr struct and fills it with information by running "xrandr". An error is returned if xrandr could not be found.

func (*XRandr) CheckOverlap

func (x *XRandr) CheckOverlap()

CheckOverlap checks if the displays listed by "xrandr" overlaps, or not A slice of relevant lines from the xrandr output is stored in the struct.

func (*XRandr) QuitIfOverlap

func (x *XRandr) QuitIfOverlap()

QuitIfOverlap will quit with an error if monitor configurations overlap

func (*XRandr) Reset

func (x *XRandr) Reset()

Reset the XRander check, for preparing to run xrandr again

func (*XRandr) String

func (x *XRandr) String() string

String returns a multiline string with the collected resolution lines from xrandr (if any).

type Xfce4

type Xfce4 struct {
	// contains filtered or unexported fields
}

Xfce4 windowmanager detector

func (*Xfce4) ExecutablesExists

func (x *Xfce4) ExecutablesExists() bool

ExecutablesExists checks if executables associated with this backend exists in the PATH

func (*Xfce4) Name

func (x *Xfce4) Name() string

Name returns the name of this window manager or desktop environment

func (*Xfce4) Running

func (x *Xfce4) Running() bool

Running examines environment variables to try to figure out if this backend is currently running

func (*Xfce4) SetMode

func (x *Xfce4) SetMode(mode string)

SetMode will set the current way to display the wallpaper (stretched, tiled etc)

func (*Xfce4) SetVerbose

func (x *Xfce4) SetVerbose(verbose bool)

SetVerbose can be used for setting the verbose field to true or false. This will cause this backend to output information about what is is doing on stdout.

func (*Xfce4) SetWallpaper

func (x *Xfce4) SetWallpaper(imageFilename string) error

SetWallpaper sets the desktop wallpaper, given an image filename. The image must exist and be readable.

Jump to

Keyboard shortcuts

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