Jump to content
InsanelyMac Forum
  • Announcements

    • Allan

      Solution to create a topic or post.   04/24/2018

      Hello guys. The majority of you are having issues to create a topic or post here. This are a problem with our current theme InsanelyMac.  Now the theme will be the Default IPS. Sorry for any inconvenience.
Sign in to follow this  
Rich20

iTunes script working with Lion but not with OSX 10.5.8 PPC

Recommended Posts

Hi all,

 

As a newbie I am only getting started with scripts and have written down a script that works with 10.8. (not perfectly though)

 

The script takes the genre of the song playing in iTunes, and changes the Desktop picture accordingly. If I try to run it on a PowerMac G5 it seems like it works on Script editor, no error message appears, only it doesn't change the picture.

 

Could you give me a few hints on how I could make this work on OSX 10.5.8 PPC?

 

 

 

repeat

tell application "iTunes"

if player state is playing then

set myAlbum to (get genre of current track)

 

 

 

 

tell application "System Events"

tell current desktop

 

set picture to file {"Untitled1:Users:raffle:Desktop:" & myAlbum & ".png"}

end tell

end tell

end if

if not application "iTunes" is running then exit repeat

 

end tell

end repeat

 

 

 

 

Thanks very much in advance.

 

Rich

Share this post


Link to post
Share on other sites
Advertisement

Thanks for your reply eep357!

 

I checked the path and it appears correct. I modified the script a bit.

 

I put a picture called Jazz.png in "Untitled 1/Styles/"

 

and played a song with genre set as "Jazz"

 

 

and run this:

 

 

 

tell application "iTunes"

if player state is playing then

set myAlbum to (get genre of current track)

 

 

 

 

tell application "System Events"

tell current desktop

 

set picture to file {"MacOSX:Untitled1:Styles:" & myAlbum & ".png"}

end tell

end tell

end if

end tell

 

 

 

...to no avail.

 

 

The event log reads:

 

tell application "iTunes"

get player state

playing

get genre of current track

"Jazz"

end tell

tell application "System Events"

set picture of current desktop to file {"MacOSXUntitled1:Styles:Jazz.png"} of current desktop

end tell

 

 

 

my first script had the effect of always bringing the default macOS purple-ish wallpaper and the new one doesn't.

 

if anyone has an idea, or even an old "change desktop picture" script working on PPC 10.5 so I can check how to complete this...

 

thanks for your help!

Share this post


Link to post
Share on other sites

Here, this should work as long as assisted devices are enabled in Universal Access. The file path will need minor adjustment for you, as I had a 2nd partition called Untitled 1 which was not my root partition, so assuming Untitled 1 were your root partition just remove Volumes and that's it:

 

repeat
tell application "iTunes"
 if player state is playing then
  set myAlbum to (get genre of current track)
  set theFile to ("Volumes:Untitled 1:Styles:" & myAlbum & ".png")
  tell application "Finder"
   set desktop picture to theFile as alias
  end tell
 else
  exit repeat
 end if
end tell
end repeat

 

The "as alias" part tripped me up for a while, doesn't work without it

Share this post


Link to post
Share on other sites

Hi5! A nice, simple, clean script really is a beautiful thing :thumbsup_anim:

 

A good little twist to it would be to have the script launch iTunes, so launching the script kills 2 birds so to speak, and don't really need the "else" other than to maybe kill it after you have reclosed iTunes. Otherwise it's gonna kill it's self if iTunes isn't running anyway, so what launches it?

 

could have it auto play a playlist or something on launch, or just have a delay before it would kill it's self giving you time to browse for a song to play

Share this post


Link to post
Share on other sites

Hi,

 

following your idea, i have modified the script in order to lauch iTunes.

 

It is working and it shows a specific backgroud if the player is stopped.

 

 

 

tell application "iTunes" to activate

 

repeat

 

 

 

tell application "iTunes"

if not player state is playing then

tell application "Finder"

set desktop picture to ("Untitled 1:Styles:notplaying.png") as alias

end tell

 

end if

 

if player state is playing then

set myAlbum to (get genre of current track)

set theFile to ("Untitled 1:Styles:" & myAlbum & ".png")

tell application "Finder"

set desktop picture to theFile as alias

end tell

end if

end tell

end repeat

 

 

+++Reason for edit: issue resolved--though if anyone has a bit of code he wants to add, or an idea to make it better, jump in! :) ++++

Share this post


Link to post
Share on other sites

I like it as is so long as it doesn't use CPU power running in the background after closing itunes

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.



×