Results 1 to 2 of 2
  1. #1

    Member Since
    Feb 24, 2007
    need help to amend a script so that it only runs if iTunes is running

    i have been using a script developed by someone else and posted online which uses geektool in combination with a script to display information about the currently playing track in iTunes in the menu bar. everything works fine, but there is one problem, namely that in order to get accurate information from iTunes (including the percentage of the track that has been played), i have set the refresh rate to 1 second, which means that each time I try to restart my Mac I have to disable geektool before I can do so, because if I don't geektool will relaunch iTunes one second after it has quit, and this cancels the restart.

    I would like to not have to disable and then enable geektool each time i restart my mac, and wonder if there is anything I can do, such as amending the script to only run if iTunes is running, so that I don't have to do disable/enable geektool. I have very little experience with scripting. Here is the script I am currently running:

    tell application "iTunes"
    -- This script extracts information about the track currently running in iTunes, and then
    -- formats it for one-line display (e.g., using GeekTool).
    -- See - iTunes, the menu bar, unicode, and GeekTool for a
    -- detailed description of a similar script that gave me the idea for this one.

    -- this spacer determines how many spaces are between some of the items in the display:
    set spacer to " "

    -- get some simple information and add spaces and punctuation:
    set myName to name of current track
    set myArtist to spacer & "< " & artist of current track & " >"
    set myYear to spacer & "< " & year of current track & " >"

    -- if the track is in an album, then put a dash before the album name (to separate
    -- it from the information that will be printed before the album):
    set myAlbum to album of current track
    if myAlbum is not "" then
    set myAlbum to spacer & myAlbum
    end if

    -- get the current position of the track and calculate how far through
    -- the track we are, as a percentage:
    set myPosition to player position
    set myDuration to duration of current track
    set myPercent to spacer & (round (myPosition / myDuration * 100)) & "%"

    -- this final line determines which pieces of information are displayed:
    set output to myName & myArtist & myAlbum & myYear & myPercent
    end tell


    OS X 10.5.7
    Mac Pro
    2 x 3 GHz Dual-Core Intel Xeon
    8 GB RAM

  2. #2

    Member Since
    Feb 24, 2007
    putting this one line before the script worked:

    tell application "System Events" to if not (process "iTunes" exists) then return
    OS X 10.5.7
    Mac Pro
    2 x 3 GHz Dual-Core Intel Xeon
    8 GB RAM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. help with imac running tiger! runs so slow all of a sudden!
    By jennefur8675 in forum macOS - Operating System
    Replies: 13
    Last Post: 09-18-2011, 06:26 PM
  2. Running a script within Mac 10.6
    By hso in forum macOS - Operating System
    Replies: 2
    Last Post: 11-23-2010, 08:01 PM
  3. How do i make a script that runs on shutdown/when finderquits
    By zentdayn in forum macOS - Operating System
    Replies: 0
    Last Post: 02-17-2010, 12:51 PM
  4. Running a script
    By TSilvino in forum macOS - Operating System
    Replies: 0
    Last Post: 08-20-2008, 01:43 AM
  5. iCal script running problem
    By goobimama in forum macOS - Operating System
    Replies: 0
    Last Post: 12-05-2007, 11:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts