Gimme Wallpaper script

If you are new to Linux or new to Sabayon Linux and just not sure where to post, here ya go. Post without fear of being told to RTFM :-)

Moderator: Moderators

Post Reply
Baby Hen
Posts: 1
Joined: Fri Jan 01, 2010 10:53

Gimme Wallpaper script

Post by Sototh » Fri Jan 01, 2010 11:08

Hi and thanks for stopping by. Searched for "gimme wallpaper" and could not find anything, hopefully I am not asking something already covered.

I found a script online to rotate background images called gimme wallpaper. It actually works, but i cannot see it. Let me explain; after putting the script in and setting it up I cannot see the wallpapers I set it to use, instead the one being used by the Sabayon shows. When I log off/on or shut down, it will flash the wallpapers, a different one each time. So, it is working, but seems to be in a layer below the Sabayon background image.

If anyone knows a way to make the Sabayon desktop transparent (choosing the blank one does not work either), tell Sabayon to display the script in preference, or to tell the script how to display in preference that would be great. Thanks!!!!!

The script it below:

Code: Select all

#!/usr/bin/env bash
#   vim:ft=sh:fenc=UTF-8:ts=4:sts=4:sw=4:expandtab:foldmethod=marker:foldlevel=0:
#   $Id$
#   This script will load a random wallpaper on each boot.
#   Copyright (C) 2006, Wael Nasreddine <[email protected]>
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your option) any later version.
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   GNU General Public License for more details.
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

# Load the functions.#{{{
# Determine the location of the functions file and source it.
if [ -f "${HOME}/bin/functions/scripts" ]; then
    source "${HOME}/bin/functions/scripts"
elif [ -f "${HOME}/lib/functions/scripts" ]; then
    source "${HOME}/lib/functions/scripts"
elif [ -f "$(dirname "${0}")/functions/scripts" ]; then
    source "$(dirname "${0}")/functions/scripts"
elif [ -f "$(dirname "${0}")/../bin/functions/scripts" ]; then
    source "$(dirname "${0}")/../bin/functions/scripts"
elif [ -f "$(dirname "${0}")/../lib/functions/scripts" ]; then
    source "$(dirname "${0}")/../lib/functions/scripts"
elif [ -f "./functions/scripts" ]; then
    source "./functions/scripts"
elif [ -f "./scripts" ]; then
    source "./scripts"
    echo "The required functions file could not be found, Aborting..."
    exit 54
# Source/Create the configurations file.#{{{
if [ -f ${HOME}/.gwallrc ]; then
    source ${HOME}/.gwallrc
    cat <<EOF > ${HOME}/.gwallrc
# Configurations for Gwall.
# First you have to set which program you want to use, I've
# tested this script with feh and gconftool-2, to set the
# background with feh use the following combination:
#   PROG="feh"
#   ARGS="--bg-scale"
# If you would like to use gconftool-2 which is used by
# Gnome desktop, use the following combination:
#   PROG="gconftool-2"
#   ARGS="-s /desktop/gnome/background/picture_filename -t string --"
# Next you should set the time to wait before actually rotating
# the background(ROTATE_SLEEP), this time is defined in seconds
# and will be passed to sleep(1), you can disable the rotating
# feature by setting ROTATE to 'false'...
# Last but not least you should add wallpaper folders to the
# FOLDERS array which we will take the wallpapers from, remember
# that it is an array so it should look like this example:
#            \${HOME}/Pictures/Wallpapers/1024x768
#            \${HOME}/Pictures/Wallpapers/1280x1024
#            \${HOME}/Pictures/Wallpapers/1280x800
#            \${HOME}/Pictures/Wallpapers/1600x1200
#            \${HOME}/Pictures/Wallpapers/800x600
#            \${HOME}/Pictures/Wallpapers/Other
#           )
# You can disable the image randomizer by setting DISABLE
# to true, this will disable looking for any wallpaper, and
# actually will use the image you have used before (or
# define by yourself). NOTE: this currently works with feh
# and gconftool-2 only, so don't bother setting it to false
# if you use another program.

# Disable Gwall and use whatever is pre-defined?

# Program to use to set the background

# Program parameters
ARGS="-s /desktop/gnome/background/picture_filename -t string --"

# Rotate ??

# Sleep for how long while rotating?? (in seconds)

# Folders array
FOLDERS=( \${HOME}/Pictures/Wallpapers/my image.jpg
          \${HOME}/Pictures/Wallpapers/my image1.jpg
          \${HOME}/Pictures/Wallpapers/my image2.jpg
          \${HOME}/Pictures/Wallpapers/my image3.jpg
          \${HOME}/Pictures/Wallpapers/my image4.jpg
          \${HOME}/Pictures/Wallpapers/my image5.jpg
          \${HOME}/Pictures/Wallpapers/my image6.jpg
          \${HOME}/Pictures/Wallpapers/my image7.jpg
          \${HOME}/Pictures/Wallpapers/my image8.jpg
          \${HOME}/Pictures/Wallpapers/my image9.jpg
          \${HOME}/Pictures/Wallpapers/my image10.jpg
    print_error 0 "Please edit ~/.gwallrc and try again."
    exit 1
# Check if we have Gwall autostart desktop file.#{{{
if [ ! -f "${HOME}/.config/autostart/Gwall.desktop" ]; then
    cat << EOF > "${HOME}/.config/autostart/Gwall.desktop"

[Desktop Entry]
Name=No Name
Comment[en_US]=Gwall is a background randomiser and rotator.
Comment=Gwall is a background randomiser and rotator.
    print_warning 1 "Gwall autostart file has been installed for you in '${HOME}/.config/autostart/Gwall.desktop'\n  It is disabled by default, to enable it please run 'gnome-session-properties'."
# If the program is disabled just set the pre-defined wallpaper.#{{{
if [ ! -z "${DISABLE}" -a "${DISABLE}" = "true" -a "${PROG}" = "feh" ]; then
    # Setting wallpaper
    ${PROG} ${ARGS} $(cat ~/.fehbg)
    exit $?
elif [ ! -z "${DISABLE}" -a "${DISABLE}" = "true" -a "${PROG}" = "gconftool-2" ]; then
    # There's no need to set anything up, this is handled by Gnome.
    exit 0
# Sanity checks#{{{
if [ -f "${HOME}/" ]; then
    OldPID="$( cat "${HOME}/" )"
    if ps aux | grep -v grep | awk '{print $2}' | grep -q "${OldPID}"; then
        print_error 0 "Gwall already running, aborting..."
        exit 1
        rm -f "${HOME}/"
if [ ${#FOLDERS[@]} -lt 1 ]; then
    print_error 0 "Please add folders to FOLDERS array in ~/.gwallrc"
    exit 1
for folder in ${FOLDERS[@]}; do
    [ ! -d "${folder}" ] && \
        print_warning 0 "The folder '${folder}' does not exist, please review the FOLDERS array in ~/.gwallrc"
if ! type "${PROG}" &>/dev/null ; then
    print_error 0 "${PROG} is not a valid program"
    exit 1
# Build the images array#{{{
for folder in ${FOLDERS[@]}; do
    # make sure folder does exist
    [ ! -d "${folder}" ] && \

    # make sure path is absolute
    folder="$(cd ${folder}; pwd)"

    # Build images array
    images=(${images[*]} $(find ${folder} -mindepth 1 -maxdepth 1 -name *.jpg -o -name *.png -o -name *.gif 2>/dev/null))

if [ ${#images[@]} -lt 1 ]; then
    print_error 0 "Folders does not contain any image."
    exit 1
# Set the wallpaper.#{{{
# If ROTATE is true then rotate the wallpaper while sleeping for ROTATE_SLEEP
    while true; do

        # Generating a random number between 0 and ${#images[@]}
        rand="$(expr $RANDOM % ${#images[@]})"

        # Setting wallpaper
        ${PROG} ${ARGS} ${images[$rand]}
        if isTrue "${ROTATE}" && isNumber "${ROTATE_SLEEP}"; then
            sleep "${ROTATE_SLEEP}"
) &
# Record the PID#{{{
# but only if we are rotating..
if isTrue "${ROTATE}" && isNumber "${ROTATE_SLEEP}"; then
    echo "${NewPID}" > "${HOME}/"

MODERATOR EDIT: Please use the Code button when inserting large amounts of code in a post.

Sagely Hen
Posts: 2669
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands

Re: Gimme Wallpaper script

Post by joost » Fri Jan 01, 2010 15:57

Copyright (C) 2006, Wael Nasreddine

Wael is actually IRC moderator in #sabayon. I advice to visit our IRC.

Simple Hen
Posts: 86
Joined: Wed Dec 27, 2006 20:03
Location: Bethel, Alaska

Re: Gimme Wallpaper script

Post by Azerthoth » Fri Jan 01, 2010 21:18

Obviously a Gnome user, that function is built into KDE already.

Look here:

Post Reply