The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 2,499     Votes:  3     ✅ Solution
Tags: scripts   nautilus   login   wallpaper   lock-screen  
Link: 🔍 See Original Answer on Ask Ubuntu 🔗

Title: Nautilus can set desktop wallpaper. How can it set login and lock screen wallpaper?
ID: /2017/01/13/Nautilus-can-set-desktop-wallpaper.-How-can-it-set-login-and-lock-screen-wallpaper_
Created: January 13, 2017    Edited:  July 8, 2018
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false

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:


## Set login wallpaper

# strip new line char passed by Nautilus

# Multiple files can't be selected.

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

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

# 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 \

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

    # Already sudo so simply copy and compile
    # copy working file to real file
    cp /tmp/set-login-wallpaper.tmp \

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

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.

⇧ ISO Linux 6.03 error booting Live USB What is CSM option  ⇩