Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I trying to add to my OS X configuration script a command which sets the background to the plain dark grey, however, when applied, it only sets it to the main monitor and any additional monitors currently connected keep their current background and any added thereafter still receive the default space background. What I have so far is as follows:

# Change Desktop default BackgroundColor to grey
defaults write com.apple.desktop '{ Background = { default = {BackgroundColor = ( "0.2549019753932953", "0.4117647111415863", "0.6666666865348816" ); Change = Never; ChangePath = "/Library/Desktop Pictures/Solid Colors"; ChangeTime = 1800; DrawBackgroundColor = 1; ImageFileAlias = <00000000 00ce0003 00000000 c73804cd 0000482b 00000000 000c2624 000c2633 0000ca1c 0a310000 00000920 fffe0000 00000000 0000ffff ffff0001 000c000c 2624000c 25fc000a 0789000e 00280013 0053006f 006c0069 00640020 00470072 00610079 00200044 00610072 006b002e 0070006e 0067000f 000c0005 006f0073 00780038 00360012 00394c69 62726172 792f4465 736b746f 70205069 63747572 65732f53 6f6c6964 20436f6c 6f72732f 536f6c69 64204772 61792044 61726b2e 706e6700 00130001 2f00ffff 0000>; ImageFilePath = "/Library/Desktop Pictures/Solid Colors/Solid Gray Dark.png"; NewChangePath = "/Library/Desktop Pictures/Solid Colors"; NewImageFilePath = "/Library/Desktop Pictures/Solid Colors/Solid Gray Dark.png"; NoImage = 0; Placement = Crop; Random = 0; }; }; }'

How do I set the default the the dark grey background via a terminal command? How do I change all monitors already configured to grey via a terminal command?

share|improve this question
That's a pretty useful set of commands! I also like your .aliases one too. Thanks! –  binarybob Feb 16 '12 at 23:28
I can't take all the credit, I forked it from mathiasbynens, I did add the keyboard, mouse, and non-working background settings though. –  rudolph9 Feb 17 '12 at 3:15
Ohh and my mouse tracking speed is set hight than system preferences will allow :() thats me screaming because it tracks fast. –  rudolph9 Feb 17 '12 at 3:17

3 Answers 3

This should work for you:

tell application "Finder"
set desktop picture to file "/Library/Desktop Pictures/Solid Colors/Solid Gray Dark.png"
end tell

There are several other ways on this Mac Rumors thread, but his way is the easiest.

share|improve this answer
Did you get this to work your self? It didn't work for me. –  rudolph9 Feb 17 '12 at 1:50
gave me ./a.scpt:31:46: execution error: Finder got an error: Can’t set file "/Library/Desktop Pictures/Solid Colors/Solid Gray Dark.png" to file "/Library/Desktop Pictures/Solid Colors/Solid Gray Dark.png". (-10006) –  rudolph9 Feb 17 '12 at 2:09
Tried it again with a different color to see if it had something to do with the desktop already being set to dark grey and got ./a.scpt:31:46: execution error: Finder got an error: Can’t set file "/Library/Desktop Pictures/Solid Colors/Solid Gray Medium.png" to file "/Library/Desktop Pictures/Solid Colors/Solid Gray Medium.png". (-10006) –  rudolph9 Feb 17 '12 at 2:10
@KurtRudolph Try running it within AppleScript Editor. Does it work there? I did not try it, but I believe I have in the past. –  daviesgeek Feb 17 '12 at 4:22

The paths need to be properly referenced using POSIX file for /posix/paths or as alias with Old:Mac:Style:Paths.

Pick your poison...

POSIX path:

set desktopImage to POSIX file "/Library/Desktop Pictures/Solid Colors/Solid Gray Dark.png"
tell application "Finder"
    set desktop picture to desktopImage
end tell

Mac path:

set localLibrary to path to library folder from local domain as string
set desktopImage to localLibrary & "Desktop Pictures:Solid Colors:Solid Gray Dark.png" as alias

tell application "Finder"
    set desktop picture to desktopImage
end tell

You can easily turn any of the above Applescripts into a terminal command using osascript [-e statement]:

osascript -e 'set desktopImage to POSIX file "/Library/Desktop Pictures/Solid Colors/Solid Gray Light.png"
tell application "Finder"
    set desktop picture to desktopImage
end tell'

To set multiple desktops, you can try something like tell application "System Events" to set picture of every desktop to "<path>". Unfortunately, this seems to be broken in 10.7, so you'll end up getting the following error: Expected class name but found application constant or consideration.

share|improve this answer

a shell script: #!/usr/bin/perl use Cwd;

if ($#ARGV != 1) {
    die "\nUsage: ./changedesktop <filename> <startup disk> \nwhere <filename> may be    any JPEG, PNG, GIF, TIFF or PSD and <startup disk> is the name of your boot volume.\n\n";

my $filename = $ARGV[0];
my $bootdisk = $ARGV[1];
my $directory = getcwd;
my $file = $bootdisk.$directory."/".$filename;
$file =~ tr/\//:/;
system("osascript -e \'tell application \"Finder\"\' -e \'set theFile to \"$file\"\' -   e     \'set desktop picture to \(theFile as alias\)\' -e \'end tell'");
share|improve this answer
No that is a perl script which executes running an osascript performing the same operation as the first post with a bunch of unnecessary perl code inputing the the image file which is to be set as the background. –  rudolph9 Feb 17 '12 at 1:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.