#!/bin/bash

folder=~/fonds/
sleepTime=60s
pid=$(ps xc |grep lxsession |awk ' { print $1 }')

while [ $(ps xc |grep lxsession |awk ' { print $1 }') == "$pid" ]; do
   file=$(find "$folder" -maxdepth 1 -type f |shuf |head -n 1)
   pcmanfm -w "$file" --wallpaper-mode=stretch
   sleep "$sleepTime"
done