desktop background plist settings not behaving consistently
To automate the process of "cleaning up" my desktop for screencasting purposes, I wrote a bash script, called DesktopClean.sh, that hides all icons on the desktop and changes the background image to something suitably non-distracting. To allow for pre-clean-up-desktop-settings recovery, I added a line that dumps the previous settings into a text file. A second script, DesktopMessUp.sh reads that file and resets the plist settings to the original ones. It seems to work, mostly. I usually have the background set to change every 30 minutes to a random image from a particular folder. After running DesktopMessUp.sh, I get a random image from the correct folder but it's static (no random change every 30 minutes). If I dump the settings into a file before and after, running them through diff shows no difference except for the variable "LastName" which contains the names of the displayed image before and after the scripts ran. In particular, after running DesktopMessUp.sh, the variable Change is correctly set to TimeInterval, ChangeTime to 5 (I tested it out using a 5 sec change setting) and Random is set to 1. Can anyone explain why I'm not recovering the original random bg change every 5 seconds?
Here is DesktopClean.sh:
#!/bin/bash
defaults write com.apple.finder CreateDesktop -bool false
killall Finder
defaults read com.apple.desktop Background>/Users/cytryn/.desktopbgsettings
desktopsettings=`cat /Users/cytryn/.desktopbgsettingsclean`
defaults write com.apple.desktop Background "$desktopsettings"
killall Dock
And here is DesktopMessUp.sh:
#!/bin/bash
defaults write com.apple.finder CreateDesktop -bool true
killall Finder
desktopsettings=`cat /Users/cytryn/.desktopbgsettings`
defaults write com.apple.desktop Background "$desktopsettings"
killall Dock
Here is how I checked the settings:
$ defaults read com.apple.desktop Background > temp1.txt
$ DesktopClean.sh
$ defaults read com.apple.desktop Background > temp2.txt
$ DesktopMessUp.sh
$ defaults read com.apple.desktop Background > temp3.txt
$ diff temp1.txt temp3.txt
iMac, Mac OS X (10.6.8)