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

#!/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 ""

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

Thursday, September 29, 2011

remove svn dirs

I'm sure this is out there on the internet already somewhere, but

find . -name ".svn" -type d | xargs rm -rf

Tuesday, September 27, 2011

setting up proxy pass

Make sure you load all the right modules, eg

http://www.webmasterworld.com/forum92/1727.htm

If you are getting a bunch of Error: proxy: ap_get_scoreboard_lb errors, you may need to stop and start apache (instead of reloading/restarting) (http://old.nabble.com/Error%3A-proxy%3A-ap_get_scoreboard_lb%2890%29-failed-in-child-td12128044.html)


Another error I got: client denied by server configuration: proxy:http://example.com

debian/ubuntu "Deny from all" by default in mods-available/proxy.conf, comment that out (http://artur.hefczyc.net/node/10)

Monday, September 26, 2011

add unversioned files to svn

svn st | sed -rn 's/^\?\s+(.*)$/\1/p' | xargs svn add

Monday, September 12, 2011

tasks

When I feel like I have to do some little task, I will post about it here. Usually this means google couldn't tell me the answer to my question on its first page of results, so I tried to do it myself. Wish I would have started this a long time ago. You know what they say.. a cat may look at a king