You are not logged in.

#1 2009-07-05 12:18:06

k3ttc4r
Member
From: around somewhere
Registered: 2008-12-28
Posts: 137
Website

WA.R.T. - WAllpaper RoTator (another one)

hi guys!

well, i know there already are a bunch of these around.. but i couldn't really find what i wanted, and i have like zero experience scripting bash. actually, this is pretty much my first script. it uses fbsetbg (can be changed pretty easily, though) to change my wallpaper every X minutes, or it can put a random wall every time it is executed. tell me what you think, and PLEASE let me know how i can improve it big_smile

#!/bin/sh

##########################################################################
##              Wallpaper rotator by Christian Brassat                  ##
##    __         __    __    __           __ __                         ##
##   /\ \      /'__`\ /\ \__/\ \__       /\ \\ \                        ##
##   \ \ \/'\ /\_\L\ \\ \ ,_\ \ ,_\   ___\ \ \\ \    _ __               ##
##    \ \ , < \/_/_\_<_\ \ \/\ \ \/  /'___\ \ \\ \_ /\`'__\             ##
##     \ \ \\`\ /\ \L\ \\ \ \_\ \ \_/\ \__/\ \__ ,__\ \ \/              ##
##      \ \_\ \_\ \____/ \ \__\\ \__\ \____\\/_/\_\_/\ \_\              ##
##       \/_/\/_/\/___/   \/__/ \/__/\/____/   \/_/   \/_/              ##
##                                                                      ##
##                          GNU GPLv3 2009                              ##
##########################################################################

##########################################################################
# Settings
##########################################################################

displaytime="10"                        # Minutes every wallpaper should be displayed
directory="/##DIRECTORY##"              # Directory containing the walls to be switched
loop="true"                             # Loop or no loop - values: true or false

##########################################################################
# Script (do not change unless you know what you're doing)
##########################################################################

let "displaytime *= 60"                 # Converts minutes to seconds for 'sleep' function

# Loops wallpapers when 'loop = true'
while [ $loop = "true" ]
do
     for i in $(ls $directory)
     do
          fbsetbg $directory/$i
          sleep $displaytime
     done
done

# Switches to random wallpaper when 'loop = false'
if [ $loop = "false" ]
then
     # Creates an array from all wallpapers
     files=($directory/*.*)           # create an array of the files.
     N=${#files[@]}                     # Number of members in the array
     ((N=RANDOM%N))
     randomfile=${files[$N]}

     # Sets wallpaper from random file
     fbsetbg $randomfile
fi

arch64   ||   github | dotshare | blog

Offline

#2 2009-07-05 18:17:09

scarecrow
Member
From: Greece
Registered: 2004-11-18
Posts: 715

Re: WA.R.T. - WAllpaper RoTator (another one)

Perhaps you could combine it with that one, which is made for XFCE4 and works fine:

#!/bin/bash

export PATH="/sbin:/bin:/usr/sbin:/usr/bin"

ROTATEDELAY=120

WORKDIR=/tmp/.rotate_wallpaper

FILELIST=$WORKDIR/.imagefiles

# Location of the directories of your image files.
IMAGEFILES="$HOME/wallpapers"


if [ ! -d $WORKDIR ]
then
    mkdir $WORKDIR
fi

if [ -e FILELIST ]
then
    rm -f FILELIST
fi

# Build file list
for I in $IMAGEFILES
do
    find $I -type f \( -name '*.jpg' -o -name '*.png' -o -name '*.gif' \)>> $FILELIST
done

# Load list of images into array and remove unneeded file.
oIFS=$IFS IFS=$'\n' LINES=($(<"$FILELIST")) IFS=$oIFS
rm $FILELIST


# Pick random image, set the background, and loop forever.
cd $WORKDIR
while :
do
    n=${#LINES[@]}
    r=$((RANDOM % n))
    IMAGE="`echo ${LINES[r]}`"
    xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s ""
    xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "${IMAGE}"
    killall -USR1 xfdesktop
    sleep $ROTATEDELAY
done

That one is using the regular means for setting the XFCE4 background (xfdesktop and xfconf).
KDE3/4 users do not need scripts for that, and while I'm not sure (not using Gnome) there are a couple of GNOME apps that can rotate the wallpaper.

Last edited by scarecrow (2009-07-05 18:17:59)


Microshaft delenda est

Offline

#3 2009-07-12 06:03:57

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: WA.R.T. - WAllpaper RoTator (another one)

sorry for barging in.
I am really new to the whole issue of xfce. I see the script that scarecrow posted. I however have no idea how to get it to run while i am in xfce. Could you please explain how to do this. Sorry if this seems like a noobie thing.


AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64

Offline

Board footer

Powered by FluxBB