3

I don't run a desktop environment, but instead use a bare window manager (StumpWM). Thus, my usual method for setting a desktop background is to run display -window root <image file> from a WM startup script, which does what I want.

When using multiple monitors, the X root window stretches across both and includes dead space. Thus, running that command line causes the image to either be stretched or tiled across the entire window, which isn't useful. I can use -geometry to display an image on either monitor, but if I run that again (to view on both monitors) it overwrites the other. There doesn't seem to be any ability with display to display two images in one invocation.

How can I use display to display different images on both monitors? Alternatively, how else can I get the "desktop background image" effect without a desktop environment?

3 Answers 3

3

You could use montage to generate a single image that encompasses your whole display, and call display -window root on the resulting image.

Alternatively, you can use xloadimage which is happy to tile multiple images. It doesn't know about separate monitors, so if your images aren't full-screen or if you have different-size monitors, you may need to use -at or -geometry to adjust the image positions manually.

xloadimage -onroot -at 1680,0 image1.jpg -at 0,0 image2.png
1
  • xloadimage works perfectly. Thanks.
    – Tom Hunt
    Commented Mar 14, 2016 at 3:41
1

This is what I ended up using:

DIR=$HOME/Pictures/Desktop
IMG1="$(ls $DIR/*jpg | shuf | head -1)"
IMG2="$(ls $DIR/*jpg | shuf | head -1)"
montage  -background "#000000" -geometry 1920x1080 $IMG1 $IMG2 jpg:- | display  -foreground "#000000" -backdrop  -window root jpg:-

Displays 2 random images on the root window, luckily my monitors are running at the same resolution.

0

If the X-Server supports xrandr - I found using xwallpaper easier and straight forward. The following is a part from my Xsetup:

# Display different wallpapers for each monitor
cmd='xwallpaper '
if xrandr --listactivemonitors
then
    # xrandr is available: get output names from xrandr
    for output in $(xrandr --listactivemonitors | cut -d ' ' -f6 )
    do
       # set different image for each monitor
       img=$(ls /usr/share/backgrounds/active/*.jpg | shuf | head -1 )
       cmd="$cmd --output $output --stretch $img "
    done
else
    # fallback: xrandr not available
    img=$(ls /usr/share/backgrounds/active/*.jpg | shuf | head -1 )
    cmd="$cmd --no-randr --stretch $img "
fi
$cmd

2
  • Nice solution, except shouldn't the head -1 come before the shuf in the pipeline? Otherwise, won't a random line be stripped, rather than the "total=" line which I presume you're trying to remove? Commented Jun 1, 2021 at 10:17
  • You dont get a total line for ls. What that line is doing is to get a random image from the list of files. Commented Jun 1, 2021 at 10:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .