#!/bin/bash
usage()
{
cat << EOF
usage: $0 -t transition_time -s static_time (-d dirs|-r recursive_dirs)
OPTIONS:
-h Show this message
-t required. time of transition between images, in seconds
-s required. time each image is show
-d comma separated list of directories containing images.
-r comma separated list of directories that contain images and
other directories with more images
Either dirs, recursive_dirs, or both is required
EOF
if [[ -z $1 ]]; then exit 1; else exit $1; fi
}
set_img_paths()
{
dir_path=$1
find_opts=$2
for file_path in $(find ${dir_path} ${find_opts} -type f)
do
mime_type=$(file --mime-type ${file_path})
if [[ $mime_type =~ ^.*:[[:space:]]+image/(.*)$ ]]
then
img_paths[${#img_paths[*]}]=$file_path
fi
done
}
while getopts ":hd:r:t:s:" x
do
case $x in
h) usage 0 ;;
t) transition_time=$OPTARG ;;
s) static_time=$OPTARG ;;
d) dirs[${#dirs[*]}]=$OPTARG ;;
r) recursive_dirs[${#recursive_dirs[*]}]=$OPTARG ;;
esac
done
if [[ -z $transition_time ]]; then usage; fi
if [[ -z $static_time ]]; then usage; fi
if [[ ${#dirs[*]} -eq 0 && ${#recursive_dirs[*]} -eq 0 ]]; then usage; fi
# array for our image paths
declare -a img_paths
# loop over directories to search non-recursively for images
for ((i=0; i<${#dirs[*]}; i++))
do
set_img_paths "${dirs[$i]}" "-maxdepth 1"
done
# loop over directories to search recursively for images
for ((i=0; i<${#recursive_dirs[*]}; i++))
do
set_img_paths "${recursive_dirs[$i]}" ""
done
# make sure we have some images
if [[ ${#img_paths[*]} -eq 0 ]]
then
echo "Error: could not find any images"
exit 2
fi
# randomize our array
random_order=$(seq ${#img_paths[*]} | shuf)
i=0
for r in $random_order
do
randomized[$i]=${img_paths[$r-1]}
i=$(( $i + 1 ))
done
# write our background xml file to stdout
echo ""
for ((i=0; i<${#randomized[*]}; i++))
do
img_path=${randomized[$i]}
echo -n "
${static_time}
${img_path}
"
# transition to next image, or, if we are showing the last image, transition back to first image
[[ $(( $i + 1 )) -lt ${#randomized[*]} ]] && next_img=${randomized[$i+1]} || next_img=${randomized[0]}
echo -n "
${transition_time}
${img_path}
${next_img}
"
done
echo " "
Showing posts with label oneiric ocelot. Show all posts
Showing posts with label oneiric ocelot. Show all posts
Sunday, October 23, 2011
ubuntu oneiric ocelot write desktop background image file
here is a script which takes in path to one or more directories containing images and writes a gnome desktop background file to show those images
Tuesday, October 18, 2011
oneiric ocelot 11.10 set background to xml file
gsettings set org.gnome.desktop.background picture-uri 'file:///path/to/file/background.xml'
http://askubuntu.com/questions/67218/how-do-i-create-a-desktop-wallpaper-slideshow-in-oneiric
as best I can tell this property is stored in ~/.gconf/desktop/gnome/background/%gconf.xml
more to come on this in a bit
Subscribe to:
Comments (Atom)