Skip to content

Instantly share code, notes, and snippets.

@Pigpog
Last active August 30, 2021 17:12
Show Gist options
  • Save Pigpog/5a28b13c1e6ccafc58bb221bc7fdd6d5 to your computer and use it in GitHub Desktop.
Save Pigpog/5a28b13c1e6ccafc58bb221bc7fdd6d5 to your computer and use it in GitHub Desktop.
Multi-monitor wallpaper generator. One image per monitor.
#!/bin/bash
# Multi-monitor wallpaper generator
# Requires imagemagick, xrandr, feh
# Usage: pipe a list of images to this script
# Example: ls ~/Pictures/*.JPG | sort -R | sh wallpaper
{
# ignore first line
read -u 3 -r ign;
# reading from xrandr piped in last line
while IFS=\ read -u 3 -r ign ign specs ign; do
heighttmp=${specs##*x};
# read a filename from stdin
read -r image;
echo $image;
# add -composite statements to our convert command
composites+="\( '$image' -resize ${specs%%/*}\x${heighttmp%%/*} \) \
-geometry +$(echo $specs | cut -f2-3 -d+) -composite ";
done
# use imagemagick to assemble the wallpaper using xrandr to get
# the total virtual res of the X display, then pipe it to feh
eval convert -size "$(xrandr | head -1 | cut -f8-10 -d\ | tr -d ' ,')" \
xc:skyblue "${composites[@]}" jpg:- | feh --bg-tile -;
# read info about monitors
} 3<<< $(xrandr --listactivemonitors);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment