Question

I administer a few computer labs using mostly Apple Remote Desktop (ARD). I've been trying to resize the desktop either via the command line using Terminal, or by using Applescript.

I found this handy script for changing the desktop:

tell application "System Events"
-- SET DESKTOP TO SPECIFIC PICTURE
tell current desktop
    set picture rotation to 0 -- (0=off, 1=interval, 2=login, 3=sleep)
    set picture to file "Mac OS X:Library:Desktop Pictures:Plants:Agave.jpg"
end tell 

And that does the trick to change the desktop, but I need to resize my desktop to "Stretch to Fill Screen" on my OSX 10.7 machines.

I suspect there are lots of Unix commands I can send via ARD to change com.apple.desktop.plist settings. You know, stuff like pmset:

pmset -a  hibernatemode 0 disksleep 10 womp 1 networkoversleep 0 sleep 180 powerbutton 0 ttyskeepawake 1 autorestart 0 panicrestart 157680000 displaysleep 18

That's pretty handy.

I've used "defaults read com.apple.desktop" and found that say, the Placement on my laptop is "Placement = Crop;".

(By the way, when you use the defaults command, are you setting them for every user?)

I even downloaded a Property List Converter to convert com.apple.desktop.plist into an XML file that I could read, and I found out stuff like this:

                    <key>Placement</key>
                <string>FillScreen</string>

But I don't know how to use this information.

I've tried overwriting the com.apple.desktop.plist file on my machines with settings I liked, but found that this did nothing at all, it didn't change the desktop, not even if I logged out and in of a client machine, or restarted.

I'm trying very hard to avoid GUI scripting the System Preferences because I know it's in bad form, plus I couldn't figure that out, either. Although I did try, by installing Xcode and looking though the Accessibility testing thing to figure out which pane of which window... and failed to script it.

I found this website of someone doing something similar to what I'm doing, but it's in German, and Google Translate isn't perfect.

P.S. I've never written a Python script, and I'm a beginning coder.

P.P.S. I've never used Automator successfully.

Was it helpful?

Solution

You can click the pop up button and then click some menu item of menu 1:

tell application "System Preferences"
    reveal anchor "DesktopPref" of pane id "com.apple.preference.desktopscreeneffect"
end tell
tell application "System Events" to tell process "System Preferences"
    tell pop up button 2 of tab group 1 of window 1
        click
        click menu item "Stretch to Fill Screen" of menu 1
    end tell
end tell

Changing the Placement keys in ~/Library/Preferences/com.apple.desktop.plist and logging out and back in worked for me in 10.8. Another way to edit the plist:

f=~/Library/Preferences/com.apple.desktop.plist; plist=$(plutil -convert xml1 $f -o - | awk '/<key>Placement<\/key>/{print;getline;sub(/>.*<\//,">FillScreen</")}1'); printf %s "$plist" > "$f"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top