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.

G4fanboy

macrumors 6502
Original poster
Mar 9, 2013
324
202
Andalucia Spain
This post is a wiki, so if you have the appropriate user range you can edit it.

The 16 wallpaper pictures from macOS Mojave (or Mac OS X as we like to call it) are in Reddit:

https://www.reddit.com/r/MacOS/comments/8oz5h5/all_16_full_resolution_macos_mojave_dynamic/

In the comments, there is a link about an OS X wallpaper changer which allows the system to automatically change wallpapers based on the time of day:

https://github.com/pipwerks/OS-X-Wallpaper-Changer

This version was created with the Mojave dynamic wallpaper in mind so it works better with it:

https://github.com/jonbeebe/MacDynamicWallpaper

mojave_dynamic_1.jpeg

[doublepost=1528733565][/doublepost]I hope someone can make a script to accomplish the same on PowerPC.
 
Last edited:
  • Like
Reactions: philgxxd
I'll have to poke around again in AppleScript for this! I have some ideas, but I'll have to refresh my script memories. :p
 
Isn't there a way to do a slideshow as your background? Or am I thinking of Windows 7 again? I seem to remember being able to time when new pictures would be on the desktop.
 
Isn't there a way to do a slideshow as your background? Or am I thinking of Windows 7 again? I seem to remember being able to time when new pictures would be on the desktop.

You certainly can. But the only option is to set the delay between changing the picture (e.g. 5 sec, 30 sec, 30 mins, etc etc). This would work for the dynamic desktop series if it were manually reset at the same time each morning, but I believe the AppleScript above handles pictures labeled for specific periods of the day like “early afternoon” and then syncs the images to the appropriate time frame.
 
Just cleaned up the WikiPost, improved the grammar and punctuation.

Made the sentence structuring a little clearer to understand too.

G4, could you please change the title to display "Mojave"? "Mohave" is what it sounds like, but it isn't how it's spelled. Thank you.
 
Awesome! I'm working on combining a script I found online to change wallpapers in a shorter amount of code and the one you posted.

Does anyone know the exact times that Mojave's dynamic wallpapers change? I'm looking for hours (for example, 1pm to 3pm it's x.jpeg).
 
I tried getting Mojave beta to run in VMWare Fusion. It installed okay but just doesn’t want to get to the setup assistant on its first run... if it does eventually load, I’ll let you know!
 
  • 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 15 minutes -->
    <key>StartInterval</key>
    <integer>900</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
 
Last edited:
Thanks for the support you guys! I fixed up a minor bug in the AppleScript code (some of the hours of the day were missing!). I also tried it on Tiger, and I had to make some adjustments, but they're minimal:

Change the bottom "change wallpaper here" code to this (must be a Script/Mac OS X change issue):
Code:
tell application "Finder"
	set desktop picture to {"HDname:Users:username:Documents:Apple:mojave_dynamic:mojave_dynamic_" & wallpaper & ".jpeg"} as alias
end tell

Glad to see this works. I'm enjoying using it so far!
 
Thanks for the support you guys! I fixed up a minor bug in the AppleScript code (some of the hours of the day were missing!). I also tried it on Tiger, and I had to make some adjustments, but they're minimal:

Change the bottom "change wallpaper here" code to this (must be a Script/Mac OS X change issue):
Code:
tell application "Finder"
    set desktop picture to {"HDname:Users:username:Documents:Apple:mojave_dynamic:mojave_dynamic_" & wallpaper & ".jpeg"} as alias
end tell
Is the code change shown above for the Tiger "minimal" change you mention or is it for the script in general?
 
Is the code change shown above for the Tiger "minimal" change you mention or is it for the script in general?

Tiger. I tested the script in both Tiger and High Sierra and the change is meant for Tiger. Not sure if it works with Leopard yet (haven't tested it), or whether the change is also meant for Leopard.
 
  • Like
Reactions: AphoticD
Is the code change shown above for the Tiger "minimal" change you mention or is it for the script in general?
Tiger only. (As far as I know.)

I'm now having issues with the script auto running with launchd on Tiger after wake, so I don't know if it's because of how launchd works on older version, but as far as I can tell, it still works on High Sierra. I changed the StartInterval time to 900 (15 minutes) on Tiger because of that. Might be smart to have it run that often on other machines too, just so it stays up to date if the computer is asleep for a while.

Is anyone having good results with launchd and this set up so far?

EDIT: Looks like the way launchd works is that it will run after the next scheduled time if the computer is asleep, and stores those tasks in a "queue". Interesting. The wallpapers then change after a short time of being awake (but it is slightly jarring having it be dark and then suddenly light, for example, when it's daytime now. :p).

 
Last edited:
  • Like
Reactions: G4fanboy
This one is for "Slix", is there a reason for this duplicate line of code in your script?
Sorry to ask but I'm not savvy enough to understand why it is there.

View attachment 766928
Probably because I was tired when I was writing this, and that's what copy pasting code does to you. XD Thanks for pointing it out, I'll fix it up and update the original post!

I also went ahead and tweaked the times to make them a little more inline with common sunrise and sunset times, and the middle of the day image now aligns better with noon. I also updated the original post with those update times in the code.
 
  • Like
Reactions: G4fanboy
Probably because I was tired when I was writing this, and that's what copy pasting code does to you.
LOL...
been there - done that.:D

For some reason or another I cannot get your .plist file to fire the script for me, so I came up with this solution which works well.
I compiled your "DynamicWallpaper.scpt" into an App.

Then I came up with this script which is also complied into an App with the "Stay Open flag set",
installed it in my Login items so it runs when I start up.
This App runs the "DynamicWallpaper" App every 15 minutes, (this time period can be changed)
Finally I choose to hide this running app from my Dock using a little utility called "DockLess"
Works like a charm, takes only a second to update things every 15 minutes.
I'm betting someone wiser then I could incorporate something like this code snippet into your script so as to have a single self looping file. Seems the "Idle" command is the magic bullet.
Good info here, but it somehow gets short circuited by my thick skull.:(
https://macscripter.net/viewtopic.php?id=24568
---------------------------
on idle
tell application "System Events"
tell application "/Applications/DynamicWallpaper .app"
run
end tell
return 900
end tell
end idle

----------------------------
 
Last edited:
Probably because I was tired when I was writing this.
LOL...
been there - done that.:D

I've come to the carefully considered conclusion that everybody here is tired when writing posts - myself almost constantly.

...Maybe that's what happens when most of western population is desperately deprived of precious sleep...

...You have to wonder, what would have happened if civilization never progressed past the point of hunting/gathering food for your family and creating bonds with your community instead of the current model of critical incentives to earn enough money to support yourself and future generations... ...To instead proceed life the way the planet intended it to be, so we would be swimming in sleep and possible good health instead of long-term stress...

...But then again, if we lived that way for tens of thousands of years and never progressed as a society, we may be inadvertently dooming the ultimate fate of the human species. We would never transcend planets, for example, or discover cures to deadly diseases.

Well damn, now I've gone and turned a simple thread about AppleScripts into contemplation of various forks in societal paths (plus ramifications) of which the human species could have taken long ago.

...But I suppose that's what happens when you write posts when you're tired...

Eh.

In any case, goodnight all.
 
Last edited:
  • Like
Reactions: G4fanboy and Slix
LOL...
been there - done that.:D

For some reason or another I cannot get your .plist file to fire the script for me, so I came up with this solution which works well.
I compiled your "DynamicWallpaper.scpt" into an App.

Then I came up with this script which is also complied into an App with the "Stay Open flag set",
installed it in my Login items so it runs when I start up.
This App runs the "DynamicWallpaper" App every 15 minutes, (this time period can be changed)
Finally I choose to hide this running app from my Dock using a little utility called "DockLess"
Works like a charm, takes only a second to update things every 15 minutes.
I'm betting someone wiser then I could incorporate something like this code snippet into your script so as to have a single self looping file. Seems the "Idle" command is the magic bullet.
Good info here, but it somehow gets short circuited by my thick skull.:(
https://macscripter.net/viewtopic.php?id=24568
---------------------------
on idle
tell application "System Events"
tell application "/Applications/DynamicWallpaper .app"
run
end tell
return 900
end tell
end idle

----------------------------
Another good solution! I avoided the application route because I didn't want an app showing up in my dock and running and closing and stuff every so often.

(I also fixed another bug with the times I changed last night - the first if statement was wrong, so it now works, see if that fixes your plist issue!)
 
  • Like
Reactions: G4fanboy
Finally figured out how to get it all together and working in one AppleScript.
Using Slix's script as a starting point, and adding the idle commands, saving it as an Application with the stay open flag set, and it runs just fine.
As I mentioned earlier I use a utility called "Dockless" to hide the App from my Dock to keep things neat and tidy.
The Application runs from my Login items each time I start up the computer.
For my own use I narrowed the time periods down to 6, I just prefer it this way.
In closing I'd like to thank those who started and contributed to this thread, and for forcing me to find a way to achieve what I wanted, who was it that said "you can't teach an ole dog new tricks".:D

-------------------------------
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 "System Events"
tell every desktop
set picture to "~/Pictures/mojave_dynamic/mojave_dynamic_" & wallpaper & ".jpeg"
end tell
return 900
end tell
end idle
--------------------------------
 
Very nice! I tested it out and customized it a little bit, and it looks great on my TiBook. One of my favorite parts of this forum is the projects people come together and do to keep PPC feeling fresh. Combine this with one of the Sierra Themes and you could claim it's running the Mojave beta! :D
 
Very nice! I tested it out and customized it a little bit, and it looks great on my TiBook. One of my favorite parts of this forum is the projects people come together and do to keep PPC feeling fresh. Combine this with one of the Sierra Themes and you could claim it's running the Mojave beta! :D

That's what happens when everyone puts a little elbow grease into it. Amazing what some groupwork can do.

Though I still think Mountain Leopard is far more convincing.
 
Last edited:
  • Like
Reactions: G4fanboy
@jbarley: Nice work! I didn't know about the idle command!

@pochopsp: You're on Leopard, did you have to use the modified AppleScript I posted for setting the wallpaper itself for Tiger? Or does the "tell every desktop" commands work on Leopard?

@AL1630: I agree! It's really neat to see everyone coming together to make this type of thing happen.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.