Monday, 21 September 2020

Setting different background images in each monitor in a multi-monitor system under Cinnamon

The beauty of open source is that we can almost always "scratch an itch". If you don't know that term, in software, it refers to the possibility of solve problems that are bothersome to us but not bothersome enough to the creator(s) to solve it.

In this case, I wanted to have different images in each of my monitors under Linux Mint 20, Cinnamon.

Looking for solutions, I came across a post in the Linux Mint forum which had a solution: Create a large image and span it across all the monitors.

I have many pictures and I like rotating them, so editing all the pictures manually to fit the screen didn't seem too practical.

Looking at ways to automate it I found out that with imagemagick and xrandr I had pretty much all I needed.

That's when I decided to create a script to do what I originally wanted and then more.

  • Set the proper image in each active monitor regardless of resolution or relative positioning
  • Span a single file across monitors
  • Display a different file in each monitor
  • Select random files from a directory
  • Change the background at a given interval (to use it as a startup application)

 I ended up with a nice script that I hope other people can use.

Right now the script is "production ready" with, hopefully, all the validation  required

If you use it, add a comment here or under the git repo and let me know how I can improve it. 

Here is a copy of the script help 

Usage: multiMonitorBackground [OPTIONS] [FILE] [FILE] ...

This script to set up a background image spaning multiple monitors
under Cinnamon. If no parameters are specified: A random file per monitor is
selected from current directory.

Note: Files are scaled and shaved to fit the display area without loosing aspect radio.

It can receive the following parameters:
 FILE          Files to set as background. FILE paths must be relative to the
               DIRECTORY unless they have an absolute path. Each FILE must be
               an image file.
               - If the script receives less files than the number of monitors
                 it will cycle through the files repeating them until all
                 monitors have a file
               - If the script receives no files and the parameter -s is not
                 specified the script will select one random image per active
 -d DIRECTORY  A directory containing image files (jpg, jpeg and png). The
               default is the current directory
 -s            Span a single FILE across monitors.  
               If no FILE is passed, and the parameter -s is present, a random
               file from the DIRECTORY is displayed.
 -t MINUTES    Time in MINUTES to refresh the background       
 -version      Displays the version number
 -verbose      Displays additional information
: put the same image in each monitor mypic.jpg     
: span an image across all the monitors mypic.jpg     
: select one random image per monitor from the directory indicated -d ~/Pics
: assign each image received to one or more monitors -d ~/Pics pic1.jpg pic2.jpg
: select one random image from the directory indicated and span
  it across all the monitors, changing the image every 5 minutes -s -t 5 -d ~/Pics
Author: Raul Suarez

No comments:
Write comments

© 2014 Using FOSS. Designed by Bloggertheme9
Powered by Blogger.