익명 04:48

How can I change wallpaper automatically?

How can I change wallpaper automatically?

I have found a guide for that but doesn't sure if it will work or it is safe to use. The guide: http://www.linuxandubuntu.com/home/how-to-automatically-change-gnome-background-in-intervals-using-bash

I am asking if is these introductions safe and will work? If not, is there any other solutions for that?

I am using Ubuntu 20.04 LTS

Thank you.



Top Answer/Comment:

The script worked when I tested in GNOME SHELL 3.36.6

[admin@ADMIN ~]$ gnome-shell --version
GNOME Shell 3.36.6
[admin@ADMIN ~]$ 

Here is the modified content under my $HOME/.profile file.

# start my custom script for setting random background wallpapers
if [ -f "$HOME/wp.sh" ] ; then
    bash $HOME/wp.sh &
fi

Here is the modified content under my $HOME/wp.sh file.

#!/bin/bash
# script to set random background wallpapers on my GNOME desktop
# set base path
export wallpaper_path=/home/admin/Pictures
shopt -s nullglob
# store all the image file names in wallpapers array
wallpapers=(
    "$wallpaper_path"/*.jpg
    "$wallpaper_path"/*.jpeg
    "$wallpaper_path"/*.png
    "$wallpaper_path"/*.bmp
    "$wallpaper_path"/*.svg
)
# get array size
wallpapers_size=${#wallpapers[*]}

# set wallpapers in incremental order
index=0
while [ $index -lt $wallpapers_size ]
do
    gsettings set org.gnome.desktop.background picture-uri "${wallpapers[$index]}"
    # index is maxing out, so reset it
    if [ $(($index+1)) -eq $wallpapers_size ]
    then
        index=0
    else
        index=$(($index + 1))
    fi
    # keep the wallpaper for the specified time
    sleep 1m
done

Wallpapers changed at 1m interval as expected.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다