Skip to content

🌆 Utilities for handling monitors, resolutions, wallpapers and timed wallpapers

License

Notifications You must be signed in to change notification settings

xyproto/wallutils

Folders and files

NameName
Last commit message
Last commit date
Feb 11, 2019
Feb 11, 2019
Feb 10, 2019
Feb 11, 2019
Feb 7, 2019
Feb 7, 2019
Feb 11, 2019
Feb 11, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 11, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 11, 2019
Feb 10, 2019
Feb 10, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 11, 2019
Feb 11, 2019
Feb 7, 2019
Feb 11, 2019
Feb 11, 2019
Feb 11, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 9, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 7, 2019
Feb 9, 2019
Feb 7, 2019
Feb 7, 2019

Repository files navigation

Monitor Build Status 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: FORMAT SPEC.

Highlighted functions

  • The monitor.Detect function can return a []Monitor slice in Go, with information about all connected monitors.
  • The monitor.SetTimedWallpaper function can be used for launching an event loop that handles GNOME timed wallpapers.

Included utilities

  • getdpi, for retrieving the average DPI, for all monitors.
  • lscollections, for listing installed wallpaper collections.
  • timedinfo, for showing more information about installed GNOME timed wallpapers.
  • lsmon lists the connected monitors and resolutions.
  • lstimed for listing installed GNOME timed wallpapers.
  • lswallpaper, for listing all installed wallpapers.
  • setcollection, for setting a suitable (in terms of resolution) wallpaper from a wallpaper collection.
  • setrandom, for setting a random wallpaper.
  • settimed, for setting GNOME timed wallpapers (will continue to run, to handle time events).
  • setwallpaper can be used for setting a wallpaper (works both for X11 and Wayland).
  • wayinfo shows detailed information about the connected monitors, via Wayland.
  • xinfo shows detailed information about the connected monitors, via X11.
  • xml2stw for converting GNOME timed wallpapers to the Simple Timed Wallpaper format.

Example use of the lsmon utility

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

Building and installing utilities

Using make, for building and installing all included utilities:

make
make install

Using Go 1.11 or later, for a single utility:

go get -u github.com/xyproto/monitor/cmd/setwallpaper

On Ubuntu, from a fresh installation:

sudo apt get update
sudo apt get install libxcursor-dev libxmu-dev libx11-dev git golang-go
go get -u github.com/xyproto/monitor/cmd/setwallpaper
cd ~/go/src/github.com/xyproto/monitor

Manually:

# clone the repository
git clone https://github.com/xyproto/monitor

# build and install the setwallpaper command
cd monitor/cmd/setwallpaper
go build
install -Dm755 setwallpaper /usr/bin/setwallpaper

Example use of setwallpaper

setwallpaper /path/to/background/image.png

Example use of the Go package

Retrieve monitor resolution(s)

package main

import (
	"fmt"
	"os"

	"github.com/xyproto/monitor"
)

func main() {
	// Retrieve a slice of Monitor structs, or exit with an error
	monitors, err := monitor.Detect()
	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 := monitor.SetWallpaper(imageFilename); err != nil {
	return err
}

Build requirements

  • Go 1.11 or later.
  • A working C compiler (tested with GCC 8.2.1)
  • libwayland-client.so and header files available, for Wayland support.
  • libX11.so and header files available, for X11 support.

General info