It seems impossible to separately set wallpapers for the main screen and the second screen. What can be done however is to set a wallpaper, and have it spanned over two screens. We can automatically create a spanning image of two wallpapers of your choice and (also automatically) switch the wallpaper and the picture options, depending on whether the second screen is connected or not.
To make it look nice, it is necessary that at least the vertical screen resolution of both screens is identical, which is the case in your situation.
In this solution, The preparing work you have to do is:
First, install imagemagick to automaically create the spanning image:
sudo apt-get install imagemagick
Prepare two separate background images of your choice for both the screens:
- The dimensions should exactly match the screen's dimensions (16:9 in your case)
- The vertical resolution of both images should be exactly the same.
screen_2.jpeg (exactly those names). A script will create the spanning image.
Create a folder in your home directory and copy both images into the folder.
Copy the script below into an empty file and save it as
auto_wall.py, together with the two images you prepared.
In the head section of the script, there is a line:
screen_check = "HDMI-0 connected"
if necessary, replace
<your_second_screenname> (run the command
xrandr if necessary to find out)
Run the script (and keep it running in the background) by the command:
Now if you connect your second screen, the wallpaper on your second screen should switch within a few seconds to
screen_2.jpeg you prepared.
- If all works well, add it to your startup applications.
curr_dir = os.path.dirname(os.path.abspath(__file__))
screen_check = "HDMI-0 connected"
single_picture = "'file://"+curr_dir+"/screen_1.jpeg'"
double_picture = "'file://"+curr_dir+"/span_image.jpeg'"
subprocess.call(["/bin/bash", "-c", command])
return subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8").strip()
execute_set("gsettings set org.gnome.desktop.background picture-uri "+single_picture)
execute_set("gsettings set org.gnome.desktop.background picture-options zoom")
if not os.path.exists(double_picture):
execute_set("gsettings set org.gnome.desktop.background picture-uri "+double_picture)
execute_set("gsettings set org.gnome.desktop.background picture-options spanned")
image_1 = curr_dir+"/"+"screen_1.jpeg"
image_2 = curr_dir+"/"+"screen_2.jpeg"
span_image = curr_dir+"/"+"span_image.jpeg"
execute_set("convert "+image_1+" "+image_2+" "+"+append "+span_image)
command = "xrandr"
check = execute_get(command)
if screen_check in check:
check = execute_get("gsettings get org.gnome.desktop.background picture-uri")
if check == single_picture:
elif check == double_picture:
test = (check_ifconnected(), check_wallpaper())
if test == (True, "double") or test == (False, "single"):
elif test == True:
In case you want to change wallpaper(s), just replace one or both of the images you copied to the folder (but mind the name) and remove the
span_image.jpeg, created by the script.
I tested it on Ubuntu 14.04 and 14.10, and it worked perfectly. The fact that you use Gnome should not make a difference.
Switching wallpaper settings manually with a key combination
If, for some reason, you would prefer to switch to the spanned wallpaper manually after connecting / disconnecting the external monitor, you can replace the last three lines:
by a single line:
and add a keyboard shortcut to do the switch: "System Settings" > "Keyboard" > "Shortcuts" > "Custom Shortcuts"
Add the command:
to a key combination of your choice.