2

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?

K7AAY
  • 3,696
  • 4
  • 22
  • 39
Tom Hunt
  • 9,808
  • 4
  • 25
  • 43

3 Answers3

2

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
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
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

  • 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? – Graham Nicholls Jun 01 '21 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. – Dakshinamurthy Karra Jun 01 '21 at 10:24