Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
The first post of this thread is a WikiPost and can be edited by anyone with the appropiate permissions. Your edits will be public.
Mountain Lion needs the Tiger modification to the script in order to work. I verified this on my white Macbook4,1 running 10.8.5. Save it as an application that doesn't close using the script editor per @jbarley and you're golden.

Code:
-------------------------------
on idle
   
   (*Get current time in hours.*)
   
   set h to hours of (current date)
   
   (*Set the wallpaper number based on the time of day.*)
   
   set wallpaper to "13"
   if (h ≥ 8 and h < 12) then
       set wallpaper to "3"
   else if (h ≥ 12 and h < 15) then
       set wallpaper to "8"
   else if (h ≥ 15 and h < 18) then
       set wallpaper to "9"
   else if (h ≥ 18 and h < 21) then
       set wallpaper to "11"
   else if (h ≥ 21 and h < 8) then
       set wallpaper to "13"
   end if
   
   (* Change the wallpaper here. Change the file path to another directory if you have different folders. *)
   
   tell application "Finder"
       set desktop picture to {"HDD:Users:username:Pictures:mojave_dynamic:mojave_dynamic_" & wallpaper & ".jpeg"} as alias
   end tell
   return 900
end idle
end idle
 
Last edited:
@Slix I just copied the code written by jbarley in a new apple script (modifying the directory address for the wallpapers), saved as bundle application with the option "don't quit" flagged, and it worked

That's interesting. For me it didn't work on Leopard on my iBook. I'll try adding the tiger script and see if that does anything.

UPDATE: I tested the script and it now works and sets the background, but it doesn't run automatically. If I quit it and relaunch it, it updates the background, but that has to be done manually.
 
Last edited:
  • Like
Reactions: G4fanboy
Well, I don't have the exact times that the Mojave dynamic wallpapers change, but I did something anyway. :p

Here is my AppleScript, it's pretty simple, and the comments explain a little more if you guys are confused. I called it "DynamicWallpaper.scpt" and I put it in my Documents folder.

Code:
(*Get current time in hours.*)

set h to hours of (current date)

(*Set the wallpaper number based on the hour of day.*)

if (h < 4) then
    set wallpaper to "16"
else if (h ≥ 4 and h < 5) then
    set wallpaper to "1"
else if (h ≥ 5 and h < 6) then
    set wallpaper to "2"
else if (h ≥ 6 and h < 7) then
    set wallpaper to "3"
else if (h ≥ 7 and h < 9) then
    set wallpaper to "4"
else if (h ≥ 9 and h < 11) then
    set wallpaper to "5"
else if (h ≥ 11 and h < 12) then
    set wallpaper to "6"
else if (h ≥ 12 and h < 13) then
    set wallpaper to "7"
else if (h ≥ 13 and h < 14) then
    set wallpaper to "8"
else if (h ≥ 14 and h < 15) then
    set wallpaper to "9"
else if (h ≥ 15 and h < 16) then
    set wallpaper to "10"
else if (h ≥ 16 and h < 18) then
    set wallpaper to "11"
else if (h ≥ 18 and h < 19) then
    set wallpaper to "12"
else if (h ≥ 19 and h < 20) then
    set wallpaper to "13"
else if (h ≥ 20 and h < 21) then
    set wallpaper to "14"
else if (h ≥ 21 and h ≤ 23) then
    set wallpaper to "15"
end if

(* Change the wallpaper here. Change the file path to another directory if you have different folders. *)

tell application "System Events"
    tell every desktop
        set picture to "~/Documents/Apple/mojave_dynamic/mojave_dynamic_" & wallpaper & ".jpeg"
    end tell
end tell

I also am including my launchd plist file to automatically run the script every hour (since apparently Cron is deprecated in High Sierra). I don't know yet if this works on PowerPCs, but give it a go! Call the file "com.applescriptwallpaper.change.plist". You put the plist file (be sure to change the plist file name and string for the script file path accordingly) in ~/Library/LaunchAgents/.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <!-- The label should be the same as the filename without the extension -->
    <string>com.applescriptwallpaper.change</string>
    <!-- Specify how to run your program here -->
    <key>ProgramArguments</key>
    <array>
        <string>osascript</string>
        <string>/Users/name/Documents/DynamicWallpaper.scpt</string>
    </array>
    <key>RunAtLoad</key>
        <true/>
    <!-- Run every hour -->
    <key>StartInterval</key>
    <integer>3600</integer><!-- seconds -->
</dict>
</plist>

And then you run the commands in the Terminal to start the launchd command:
Code:
cd ~/Library/LaunchAgents/
launchctl load com.applescriptwallpaper.change.plist

I should also note, that if you want to remove this launchd command, enter these commands before deleting the plist file, for good measure.
Code:
cd ~/Library/LaunchAgents/
launchctl unload com.applescriptwallpaper.change.plist

I hope this helps someone! I had to dig around A LOT to find all the answers on how to run AppleScripts automatically without Cron, so here ya go. :D I found a lot of my answers here: https://apple.stackexchange.com/que...at-a-specific-time-on-a-weekday/249452#249452


Wow! Awesome! Will definitely try this on my G4, it will be a big dope if it works! :)
 
  • Like
Reactions: AphoticD and Slix
That's interesting. For me it didn't work on Leopard on my iBook. I'll try adding the tiger script and see if that does anything.

UPDATE: I tested the script and it now works and sets the background, but it doesn't run automatically. If I quit it and relaunch it, it updates the background, but that has to be done manually.

It seems to work with Leopard, but Dockless won't hide the icon...
 
  • Like
Reactions: G4fanboy
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.