The script reads a config file containing three lines, the first being the path to pictures to include, the second is the delay between picture changes and the third is the size of the image as shown in conky. eg:
Code: Select all
/home/username/Pictures
30
160x120
To add the slideshow to conky, include the following in .conkyrc
Code: Select all
${image /dev/shm/conkypic.png -p 70,95 -n}
You may want to set the script to run at system startup by adding it to startup applications.
The script itself:
Code: Select all
#!/bin/bash
# Have the script recognise spaces in directory paths and filenames
IFS='
'
#Now we need to check if the script is already running. For some odd reason it seems to survive after a relog
PDIR=${0%`basename $0`}
LCK_FILE=`basename $0`.lck
if [ -f "${LCK_FILE}" ]; then
MYPID=`head -n 1 "${LCK_FILE}"`
TEST_RUNNING=`ps -p ${MYPID} | grep ${MYPID}`
if [ -z "${TEST_RUNNING}" ]; then
# It's not running, let's signal that
echo $$ > "${LCK_FILE}"
else
# An instance is already running. Exit gracefully
exit 0
fi
else
echo $$ > "${LCK_FILE}"
fi
#This is the main bit
done="yes"
while [ $done = "yes" ]
do
# Read the config file
exec 3<> ~/.conkypic
read <&3 dirpath
read <&3 timeout
read <&3 as
exec 3>&-
# Nopw get a liist of files
cd $dirpath
files=(`ls -1 *.[Jj]??`)
len=${#files[*]}
if [ "$len" != "0" ]; then
# Pick a file at random
number=$RANDOM
let "number %= $len"
# Now we copy it a temporary location. The following copies to RAM. If you are short
# on memory change the location to somewhere in /home
cp "${wd}${files[$number]}" /dev/shm/conkypic.jpg
# Convert the image for conky
mogrify -format png -resize $as /dev/shm/*.jpg &
fi
# Wait before repeating
sleep $timeout
done
Edit: It's currently setup to accept jpg as input files. If you want to add other files (eg png) change the line "files=(`ls -1 *.[Jj]??`)" to "files=(`ls -1 *.[JPjp]??`)". Note that this is very basic matching and there is no error checking. Best to use a folder as the source with only picture files.