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

Gimme Wallpaper script

Postby 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
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   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"
else
    echo "The required functions file could not be found, Aborting..."
    exit 54
fi
#}}}
# Source/Create the configurations file.#{{{
if [ -f ${HOME}/.gwallrc ]; then
    source ${HOME}/.gwallrc
else
    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:
#
#   FOLDERS=(
#            \${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?
DISABLE="false"

# Program to use to set the background
PROG="gconftool-2"

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

# Rotate ??
ROTATE="true"

# Sleep for how long while rotating?? (in seconds)
ROTATE_SLEEP="1200"

# 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
       )
EOF
    print_error 0 "Please edit ~/.gwallrc and try again."
    exit 1
fi
#}}}
# 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]
Type=Application
Encoding=UTF-8
Version=1.0
Name=No Name
Name[en_US]=Gwall
Comment[en_US]=Gwall is a background randomiser and rotator.
Comment=Gwall is a background randomiser and rotator.
Exec=Gwall
X-GNOME-Autostart-enabled=True
EOF
    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'."
fi
#}}}
# 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
fi
#}}}
# Sanity checks#{{{
if [ -f "${HOME}/.gwall.pid" ]; then
    OldPID="$( cat "${HOME}/.gwall.pid" )"
    if ps aux | grep -v grep | awk '{print $2}' | grep -q "${OldPID}"; then
        print_error 0 "Gwall already running, aborting..."
        exit 1
    else
        rm -f "${HOME}/.gwall.pid"
    fi
fi
if [ ${#FOLDERS[@]} -lt 1 ]; then
    print_error 0 "Please add folders to FOLDERS array in ~/.gwallrc"
    exit 1
fi
for folder in ${FOLDERS[@]}; do
    [ ! -d "${folder}" ] && \
        print_warning 0 "The folder '${folder}' does not exist, please review the FOLDERS array in ~/.gwallrc"
done
if ! type "${PROG}" &>/dev/null ; then
    print_error 0 "${PROG} is not a valid program"
    exit 1
fi
#}}}
# Build the images array#{{{
images=()
for folder in ${FOLDERS[@]}; do
    # make sure folder does exist
    [ ! -d "${folder}" ] && \
        continue

    # 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))
done

if [ ${#images[@]} -lt 1 ]; then
    print_error 0 "Folders does not contain any image."
    exit 1
fi
#}}}
# 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}"
            continue
        else
            break
        fi
    done
) &
NewPID="$!"
#}}}
# Record the PID#{{{
# but only if we are rotating..
if isTrue "${ROTATE}" && isNumber "${ROTATE_SLEEP}"; then
    echo "${NewPID}" > "${HOME}/.gwall.pid"
fi
#}}}



MODERATOR EDIT: Please use the Code button when inserting large amounts of code in a post.
Sototh
Baby Hen
 
Posts: 1
Joined: Fri Jan 01, 2010 10:53

Re: Gimme Wallpaper script

Postby joost » Fri Jan 01, 2010 15:57

Copyright (C) 2006, Wael Nasreddine

LoL!
Wael is actually IRC moderator in #sabayon. I advice to visit our IRC.
joost
Sagely Hen
 
Posts: 2582
Joined: Fri Nov 17, 2006 12:11
Location: The Netherlands

Re: Gimme Wallpaper script

Postby Azerthoth » Fri Jan 01, 2010 21:18

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

Look here:
http://forum.sabayon.org/viewtopic.php?f=53&t=19273
Azerthoth
Simple Hen
 
Posts: 86
Joined: Wed Dec 27, 2006 20:03
Location: Bethel, Alaska


Return to Beginners|Newbies Area

Who is online

Users browsing this forum: No registered users and 2 guests

cron