home > mac > restartTiVoDesktop.txt

Sunday, November 5th, 2006

Restarting TiVo Desktop Automagically Using Launchd and AppleScript

For some reason, TiVo Desktop version 1.9.3 (008) for Mac OS X is a processor hog for me. Especially after I’ve committed the crime of actually running iTunes or iPhoto on a given day.

I’ve noticed that stopping and starting TiVo Desktop improves this situation, but I’ve also gotten personally tired of doing this, so now I offer you a way of automating an escape from this monotony. Use the plist file here:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.dailyburrito.restartTiVoDesktop</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/restartTiVo.app</string>
    </array>
    <key>ServiceDescription</key>
    <string>Restarts TiVo Desktop periodically.</string>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>3</integer>
        <key>Minute</key>
        <integer>18</integer>
    </dict>
</dict>
</plist>

saved in the /Users/uname/Library/LaunchAgents/ folder with a name something like com.QuickSilverWatch.plist in combo with these launchd instructions. Or, just use lingon as described is this Mac OS X Hint. Either way, you’ll need this applescript to actually reboot TiVo Desktop:

-- open Sys Prefs and wait for it to open
tell application "System Preferences"
    activate
end tell

-- stop/start TiVo Desktop w/10 trys
repeat 10 times
    delay 1
    try
        tell application "System Events"
            tell application process "System Preferences"
                -- set frontmost to true w/10 trys
                repeat 10 times
                    try
                        click menu item "TiVo Desktop" of menu ...
                            "View" of menu bar 1
                        delay 1
                        tell window "TiVo Desktop"
                            click button "Stop"
                            click button "Start"
                        end tell
                        exit repeat
                    end try
                end repeat
            end tell
        end tell
        exit repeat
    end try
end repeat

-- quit Sys Prefs
tell application "System Preferences"
    quit
end tell

You must have GUI Scripting enabled to run this AppleScript.

/mac   〆   permalink