Advertisement
MichalMMac

Desktop Changer

Feb 14th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. on findNextDesktopPicture(dektop_pictures_folder)
  2.     tell application "Finder"
  3.         set set_next to false
  4.         repeat with each_file in folder dektop_pictures_folder
  5.             if set_next is true then
  6.                 set desktop picture to each_file
  7.                 return
  8.             end if
  9.             if (each_file as POSIX file) is (desktop picture as POSIX file) then
  10.                 set set_next to true
  11.             end if
  12.         end repeat
  13.         set desktop picture to first file of folder dektop_pictures_folder
  14.     end tell
  15.    
  16. end findNextDesktopPicture
  17.  
  18. on changeDesktopPicture(dektop_pictures_folder)
  19.     tell application "Finder"
  20.         -- Pokud Finder nezná cestu k obrázku na ploše
  21.         if desktop picture is missing value then
  22.             set desktop picture to first file of folder dektop_pictures_folder
  23.         else
  24.             my findNextDesktopPicture(dektop_pictures_folder)
  25.         end if
  26.     end tell
  27. end changeDesktopPicture
  28.  
  29. on run argv
  30.     --display dialog first item of argv
  31.     tell application "Finder"
  32.         set dektop_pictures_folder to first item of argv as POSIX file
  33.        
  34.         -- Zkontrolovat, zda dodaná složka existuje
  35.         if not (exists dektop_pictures_folder) then
  36.             return
  37.         end if
  38.         -- Zkontrolovat, zda v zadané složce něco je
  39.         if (count (every file in folder dektop_pictures_folder)) is less than 1 then
  40.             return
  41.         end if
  42.        
  43.         my changeDesktopPicture(dektop_pictures_folder)
  44.     end tell
  45. end run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement