Bookmark and Share

This is a note on how to save Kuvva wallpaper images automatically.

Kuvva is a desktop wallpaper app. It automatically streams beautiful images to one's computer as wallpapers. Every week they introduce a featured artist whose selected work is streamed. I've used the service for a while and like the selection much.

On Mac 10.8+, one can find information of the desktop wallpaper images with the following command

$ plutil -p ~/Library/Preferences/com.apple.desktop.plist

More concise result with only image file paths:

$ plutil -p ~/Library/Preferences/com.apple.desktop.plist | grep "\"ImageFilePath\"" | sed 's/^ *//' | sort
"ImageFilePath" => "/Users/lumeng/Library/Caches/com.kuvva.Kuvva-Wallpapers/Wallpapers/2728c21dc3d845f1b05c209cded453a3"
"ImageFilePath" => "/Users/lumeng/Library/Caches/com.kuvva.Kuvva-Wallpapers/Wallpapers/ba94b2bd2056554428d9792fe6523877"
"ImageFilePath" => "/Users/lumeng/Library/Caches/com.kuvva.Kuvva-Wallpapers/Wallpapers/ba94b2bd2056554428d9792fe6523877"
"ImageFilePath" => "/Users/lumeng/Library/Caches/com.kuvva.Kuvva-Wallpapers/Wallpapers/ba94b2bd2056554428d9792fe6523877"
"ImageFilePath" => "/Users/lumeng/Library/Containers/com.kuvva.Kuvva-Wallpapers/Data/Library/Application Support/Kuvva/1ac5adfe90bd5b73367769111329ddf9de396d3e"
"ImageFilePath" => "/Users/lumeng/Library/Containers/com.kuvva.Kuvva-Wallpapers/Data/Library/Application Support/Kuvva/1ac5adfe90bd5b73367769111329ddf9de396d3e"
"ImageFilePath" => "/Users/lumeng/Library/Containers/com.kuvva.Kuvva-Wallpapers/Data/Library/Application Support/Kuvva/1ac5adfe90bd5b73367769111329ddf9de396d3e"
"ImageFilePath" => "/Users/lumeng/Library/Containers/com.kuvva.Kuvva-Wallpapers/Data/Library/Application Support/Kuvva/2f47f6bcbb93acb1729beeb9177e2a64c3b688dc"    

It turns out every image used as wallpaper will be cached in

/Users/lumeng/Library/Containers/com.kuvva.Kuvva-Wallpapers/Data/Library/Application Support/Kuvva/

I then added cron job to save the images in a different directory:

$ crontab -l
## save newest Kuvva wallpaper image
@hourly rsync -qrihp "/Users/lumeng/Library/Containers/com.kuvva.Kuvva-Wallpapers/Data/Library/Application Support/Kuvva/" "/Users/lumeng/Dropbox/Image/Wallpaper/kuvva_wallpaper/new/"

## copy new images out
@daily rsync -qrihp "/Users/lumeng/Dropbox/Image/Wallpaper/kuvva_wallpaper/new/" "/Users/lumeng/Dropbox-x4430/Dropbox/DataSpace-Dropbox/Image/Wallpaper/kuvva_wallpaper/"

## add filename extesion to image files names
@daily add-filename-extesion-to-image-files.sh -d "/Users/lumeng/Dropbox-x4430/Dropbox/DataSpace-Dropbox/Image/Wallpaper/kuvva_wallpaper/"

The original file names don't have extension. One can use ImageMagick's identify utility to detect the image file type and add file name extension accordingly. The Bash script I'm using to do that add-filename-extension-to-image-files.sh:

#!/usr/bin/env bash

## Summary: identify image file type and add filename extension appropriately when applicable
## Example:
## $ add-filename-extension-to-image-files.sh -d ~/temp

IMAGE_FILE_DIR=

while getopts d:d opt; do
  case $opt in
  d)
      IMAGE_FILE_DIR=$OPTARG
      ;;
  esac
done


if <span class="createlink"><a href="/pages/cgi-bin/ikiwiki.cgi?page=_-d___36__IMAGE_FILE_DIR_&amp;from=blog%2Fsave_kuvva_wallpaper_images_automatically&amp;do=create" rel="nofollow">?</a> -d &#36;IMAGE FILE DIR </span>; then    
    FILES=`find $IMAGE_FILE_DIR -maxdepth 1 -type f`
else
    FILES=()
fi


IMAGEMAGICK_IDENTIFY_BIN="/opt/local/bin/identify"


for file in $FILES
do
    filename=$(basename "$file")
    extension="${filename##*.}"
    if [ "$extension" == "$filename" ]; then
        newextension=`$IMAGEMAGICK_IDENTIFY_BIN $file | cut -d ' '  -f 2 | tr '[:upper:]' '[:lower:]'`
        rsync -qrthp $file "$file.$newextension"
        rm $file
    fi
done

## END

blog comments powered by Disqus