Jump to content

iTunes script working with Lion but not with OSX 10.5.8 PPC


  • Please log in to reply
7 replies to this topic

#1
Rich20

Rich20

    InsanelyMac Protégé

  • Members
  • Pip
  • 7 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

#2
eep357

eep357

    Triple Platinum

  • Retired
  • 2,527 posts
  • Gender:Male
  • Location:Dark Side of The Wall
  • Interests:things and stuff
my guess would be an error in the naming of your file path.

#3
Rich20

Rich20

    InsanelyMac Protégé

  • Members
  • Pip
  • 7 posts
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!

#4
eep357

eep357

    Triple Platinum

  • Retired
  • 2,527 posts
  • Gender:Male
  • Location:Dark Side of The Wall
  • Interests:things and stuff
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

#5
Rich20

Rich20

    InsanelyMac Protégé

  • Members
  • Pip
  • 7 posts
eep357...it's working!


You solved this issue for me and I wish to thank you for the help you provided me!

#6
eep357

eep357

    Triple Platinum

  • Retired
  • 2,527 posts
  • Gender:Male
  • Location:Dark Side of The Wall
  • Interests:things and stuff
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

#7
Rich20

Rich20

    InsanelyMac Protégé

  • Members
  • Pip
  • 7 posts
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! :) ++++

#8
eep357

eep357

    Triple Platinum

  • Retired
  • 2,527 posts
  • Gender:Male
  • Location:Dark Side of The Wall
  • Interests:things and stuff
I like it as is so long as it doesn't use CPU power running in the background after closing itunes





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy