|
|
Perl solution
This Perl script seems to work. Don't blame me if it breaks anything :-). Note that I don't know if HUPing the Desktop process is the right way to activate the change but it seems to work.
#!/usr/bin/perl
# This is freeware, do whatever you want with it apart from passing it
# off as your own work.
# Use it at your own risk. It has been tested on Mac OSX Public Beta.
# Rob Hartill, 19/March/2001
use strict;
my $pic_dir = "/Users/rob/Documents/Images"; # change for local dir
my $prefs = `defaults read com.apple.finder`; # read existing finder prefs
# read all the jpeg images in the local dir
my $dirhandle;
opendir($dirhandle, $pic_dir) || die "Failed to open $pic_dir, $!";
my @jpegs = grep(/jpe?g$/i, readdir($dirhandle));
closedir($dirhandle);
# pick a random jpeg image
my $new_pic = $jpegs[rand(@jpegs)];
# insert the URL for the image
$prefs =~ s|(BackgroundPictureURL = )"?([^;]+)"?;|$1"file://localhost$pic_dir/$new_pic";|;
# switch on background image
$prefs =~ s/(BackgroundType = )"?([^;]+)"?;/${1}PctB;/;
# remove old finder prefs and replace with new prefs
print STDERR `defaults delete com.apple.finder`;
print STDERR `defaults write com.apple.finder '$prefs'`;
# find the process id of the 'Desktop' process
my $pid = `ps x | grep Desktop`;
$pid =~ s/^ ?(d+) .*/$1/;
# if we have a process id for the Desktop, send it a restart signal
if ($pid >0) {
kill(1, $pid);
} else {
die "Failed to find pid of Desktop processn";
}
Perl solution
hold off using my script. After using it a few times it stops working - the kill signal to restart the Desktop process will eventually fail with the desktop error 'The system has detected a minor problem and repaired it. Some of your preferences may have changed'. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|