2

In Nautilus there is a menu option to use the current image as desktop wallpaper:

Nautilus Wallpaper

How can I use the current image as wallpaper for the Login screen and Lock screen?

3

After using Nautilus to navigate and view an appropriate .png or .jpg file to use as login screen and lock screen wallpaper, Nautilus can set this for you using a script:

Set Login Wallpaper.gif

Note: In Ubuntu 18.04 only the lock screen wallpaper is changed. A different technique will be required to change the login wallpaper.

To create the script use:

cd ~/.local/share/nautilus/scripts/
gedit set-login-wallpaper

Paste in these lines:

#!/bin/bash

## Set login wallpaper

# strip new line char passed by Nautilus
FILENAME=$(echo $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS | sed -e 's/\r//g')

# Multiple files can't be selected.
LINE_COUNT=$(wc -l <<< "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS")
LINE_COUNT=$((LINE_COUNT-1))

if [[ $LINE_COUNT > 1 ]] ; then
    zenity --error --text "Ony one file can be selected at a time! "
    exit 1
fi

# Object type must be "file..." (ie no directories, etc.)
if [ -d "${FILENAME}" ] ; then
    zenity --error --text "$FILENAME is a directory!";
    exit 1
else
    if [ -f "${FILENAME}" ]; then
        : # Bash noop
    else
        zenity --error --text "${FILENAME} is not a file!";
        exit 2
    fi
fi

# Build working file in /tmp
echo "[com.canonical.unity-greeter]" > /tmp/set-login-wallpaper.tmp
echo "draw-user-backgrounds=false" >> /tmp/set-login-wallpaper.tmp
echo "background='$FILENAME'" >> /tmp/set-login-wallpaper.tmp

# Must run as sudo
if [ "$EUID" -ne 0 ] ; then

    # Get sudo password
    PASSWORD=$(zenity --password --title="Set Login Wallpaper" --timeout=20)

    # copy working file to real file using sudo
    echo $PASSWORD | sudo -S cp /tmp/set-login-wallpaper.tmp \
/usr/share/glib-2.0/schemas/10_unity_greeter_background.gschema.override

    # compile using sudo
    echo $PASSWORD | sudo -S glib-compile-schemas /usr/share/glib-2.0/schemas

else
    # Already sudo so simply copy and compile
    # copy working file to real file
    cp /tmp/set-login-wallpaper.tmp \
/usr/share/glib-2.0/schemas/10_unity_greeter_background.gschema.override

    # compile
    glib-compile-schemas /usr/share/glib-2.0/schemas
fi

exit 0

Save the file and exit the gedit editor.

Now mark the script as executable using:

chmod +x set-login-wallpaper

Open Nautilus and navigate to your directory with wallpaper images. Find an appropriate image and right-click on it. This drop-down menu appears:

Nautilus Right Click Drop Down

Click on the third option Scripts. Another drop down menu appears with all your scripts:

Nautilus set-login-wallpaper Drop Down

Select set-login-wallpaper.

When the script runs you will have to enter your sudo password.

Reboot and enjoy your new login wallpaper.

  • You need gksu as well for glib-compile-schemas /usr/share/glib-2.0/schemas part. Also, note that this approach does change login ( greeter ) wallpaper, but not lock-screen. I've written a script for that in the past, so feel free to search through my answers – Sergiy Kolodyazhnyy Jan 13 '17 at 5:16
  • I had two lines of gksudo during development phase but added shortcut at last minute merging two lines into one. I've revered back to original version where password has to be entered twice (which) I still like to change. It does change Lock Screen too-- at least on my Ubuntu 16.04. I've just retested it twice. – WinEunuuchs2Unix Jan 13 '17 at 11:33
  • well, I've solved that problem a while ago. askubuntu.com/q/746350/295286 In fact, you're basically re-doing the same thing I've already done like almost year ago. github.com/SergKolo/sergrep/blob/master/chgreeterbg.sh – Sergiy Kolodyazhnyy Jan 13 '17 at 11:38
  • Part I - I've seen similar stuff around but this is running in GUI not terminal. Part II - Nice script. Trivial point line #71 should say "check if root, else prompt for sudo password" and not "...quit". After work I'll do some more googling for GUI password. I know the -a (askpass) parameter can be used in conjunction with Zenity. Just need to invest more time. – WinEunuuchs2Unix Jan 13 '17 at 11:48
  • Principles are the same - just substitute pkexec or gksu instead of sudo - and there's your GUI. Line #71 was relevant before - I changed code without changing the comment. Thanks for pointing out though - I should correct that – Sergiy Kolodyazhnyy Jan 13 '17 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.