xyproto / wallutils

:city_sunset: Utilities for handling monitors, resolutions, wallpapers and timed wallpapers
BSD 3-Clause "New" or "Revised" License
463 stars 17 forks source link
dpi freebsd getdpi gnome i3 i3wm imagemagick linux module plasma sway timed-wallpaper utility wallpaper wayland windowanagers x11 xorg

Wallutils Build GoDoc License Go Report Card

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

Included scripts

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

Runtime requirements

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.

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

Setting a wallpaper per monitor

General info