Setting desktop background/wallpaper on Mac

BlitzMax Forums/BlitzMax Programming/Setting desktop background/wallpaper on Mac

GfK(Posted 2010) [#1]
Is this possible?

I'm using WinAPI to do it in Windows, but what about changing it on a Mac?

[edit] needs to work on 10.4+


GfK(Posted 2010) [#2]
Nobody??!


d-bug(Posted 2010) [#3]
It is possible. Follow the link: setDesktopImage!
You need some other informations too, like the screen or the way you want to stretch the image. This will not work for Tiger or Leopard machines, but it's a start. :>


GfK(Posted 2010) [#4]
Thanks - already found that but I need a solution that works on 10.4+

(guess I should've said that earlier)


N(Posted 2010) [#5]
http://stackoverflow.com/questions/2538920/how-to-set-desktop-wallpaper-and-screen-saver

There's an alternative mentioned in the comments, but it's not exactly a nice one:
You could use something like NSAppleScript and then use AppleScript to change the wallpaper


Something like this should work, according to this page:
tell application "Finder"
    set desktop picture to POSIX file "/your/filename.jpg"
end tell


Not sure why there wasn't any way to do this without AppleScript before now, although chances are this is something almost all applications will never use...

At any rate, probably check for the version of Mac OS the user is running and then only use the AppleScript option when necessary (since the Cocoa API is probably safer, and a lot of Mac OS users will have upgraded to 10.6 by now, I think).


GfK(Posted 2010) [#6]
Yeah I'm thinking it'll be a lot simpler to drop the 'set wallpaper' option for Mac. I really didn't want to be doing an awful lot outside of Blitzmax native stuff (plus tried and tester user mods) since I really don't know what I'm doing anyway.


Robert Cummings(Posted 2010) [#7]
I don't think it in any way makes people buy it or not, and it doesn't actually increase enjoyment. It's just a nice quirk to have so you would not be robbing anyone really.


GfK(Posted 2010) [#8]
Most people won't even get to see it anyway - I just had an 'extras' menu which only appears after the game is completed, with some desktop backgrounds and stuff in.


ziggy(Posted 2010) [#9]
@Gfk: Couldn't you just reveal an URL to get the wallpapers when the game is complete? Maybe you could even use OpenURL and bring them to a website with the wallpaper libraries.