• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get list of desktops?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get list of desktops?


  • Subject: Re: Get list of desktops?
  • From: Shane Stanley <email@hidden>
  • Date: Fri, 19 Jul 2013 21:32:47 +1000

On 19/07/2013, at 12:20 AM, Alex Zavatone <email@hidden> wrote:

I'm trying to cook up a simple little AS app that I might be able to make into a right click service on the desktop to that I can have the desktop randomly pick another photo from the desktops folder.  

If it's going to be a service, you can use AppleScriptObjC:

-- get list of pics
set theURL to current application's NSURL's fileURLWithPath_("/Library/Desktop Pictures")
set theFileManager to current application's NSFileManager's alloc()'s init()
set theURLs to theFileManager's contentsOfDirectoryAtURL_includingPropertiesForKeys_options_error_(theURL, missing value, 7, missing value) as list
set theWorkspace to current application's NSWorkspace's sharedWorkspace()
-- get list of screens
set theScreens to current application's NSScreen's screens() as list
repeat with i from 1 to count of theScreens
repeat -- keep repeating if file is not .jpg or .png
set aPic to some item of theURLs
if (aPic's pathExtension() as text) is in {"jpg", "png"} then
exit repeat
end if
end repeat
-- change the pic
tell theWorkspace to setDesktopImageURL_forScreen_options_error_(aPic, item i of theScreens, missing value, missing value)
end repeat

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Get list of desktops?
      • From: Alex Zavatone <email@hidden>
References: 
 >Get list of desktops? (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: Get list of desktops?
  • Next by Date: email and messages
  • Previous by thread: Re: Get list of desktops?
  • Next by thread: Re: Get list of desktops?
  • Index(es):
    • Date
    • Thread