##
## pygaw.py
## Login : <kizlum@gmail.com>
## Started on  Sat Feb 23 11:02:14 2008 PELLETIER Thomas
## 
## Copyright (C) 2008 PELLETIER Thomas
## 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##

import glob ##Pour lister les fichiers
import os ##Pour executer la commande
import random ##C'est compris je crois
import time ##Pour attendre

CHEMIN = "/home/user/images"
TEMPS = 10

COMMANDE_DEBUT = "gconftool-2 -t str -s /desktop/gnome/background/picture_filename \""
COMMANDE_FIN = "\""

while(1):
    print 'Chargement de la liste des fichiers'
    liste_fichiers = glob.glob(CHEMIN+"/*")
    nbr_fichiers = len(liste_fichiers)
    nbr_alea = random.randint(0,nbr_fichiers-1)
    cmd_a_executer = COMMANDE_DEBUT + liste_fichiers[nbr_alea] + COMMANDE_FIN
    os.system(cmd_a_executer)
    print 'COMMANDE:'
    print cmd_a_executer
    time.sleep(TEMPS)
