Es ist schon praktisch, dass EyeTV den Rechner für eine Aufnahme starten kann (ja, auch aus dem ausgeschalteten Zustand, dies wird als StartUp-Time in der OpenFirmware verankert). Aber nach der Aufnahme fährt der Rechner nicht wieder runter, außer man schreibt hierfür ein kleines Script…
Dieses kleine, selbsterklärende Skript wird mit dem Skript-Editor erstellt und gespeichert. Ab sofort wird nach der Aufnahme versucht EyeTV zu beenden, sofern weder iTunes noch QuickTime laufen und auch keine weitere Aufnahme in den nächsten 15 Minuten ansteht.
on RecordingDone(recordingID)
-- Aufnahmetitel auslesen
tell application "EyeTV"
set Aufnahme to recordingID as integer
end tell
-- IDLE-Time abrufen
set idletime to do shell script "ioreg -c IOHIDSystem | grep Idle | tail -1 | awk '{printf(\"%d\", $NF/10^9);}'"
set idletime to idletime as integer
-- Wenn IDLE-Time abgelaufen ist, überprüfen ob eine Aufnahme ansteht
if idletime > 60 then
tell application "System Events"
set itunes_running to (name of processes) contains "iTunes"
set quicktime_running to (name of processes) contains "Quicktime Player"
end tell
if itunes_running is true then
tell application "iTunes"
if player state is not stopped then
set itunes_playing to true
else
set itunes_playing to false
end if
end tell
else
set itunes_playing to false
end if
if itunes_playing is false and quicktime_running is false then
tell application "EyeTV"
if is_recording = false then
-- überprüfen ob eine Aufnahme ansteht
set limitsleep to 15 * minutes
set limitoff to 30 * minutes
set ruhezustand to true
set ausmachen to true
set vorlauf to (prepad time + 2) * minutes
set jetzt to current date
repeat with Aufnahme in start time of every program
set diff to Aufnahme - jetzt
if diff ≥ vorlauf then set diff to diff - vorlauf
if diff ≥ 0 and diff ≤ limitsleep then set ruhezustand to false
if diff ≥ 0 and diff ≤ limitoff then set ausmachen to false
end repeat
-- Wenn keine Aufnahme in den nächsten 15 Minuten ansteht, in den Ruhezustand gehen
if ruhezustand = true and ausmachen = false then
activate
set antwort to display dialog "EyeTV hat eine Aufnahme beendet.
Die nächste Aufnahme steht in 15 - 30 Minuten an.
Soll der Computer in den Ruhezustand gehen?" buttons {"Nein", "Ja"} default button "nein" with icon note with title "EyeTV-Recorder" giving up after 30
if button returned of antwort = "Ja" or button returned of antwort = "" then
tell application "Finder"
ignoring application responses
sleep
end ignoring
end tell
end if
end if
-- Wenn keine Aufnahme in den nächsten 30 Minuten ansteht, herunterfahren
if ausmachen = true then
activate
set antwort to display dialog "EyeTV hat eine Aufnahme beendet.
Es steht keine EyeTV-Aufnahme bevor.
Soll der Computer ausgeschaltet werden?" buttons {"Nein", "Ja", "Ruhezustand"} default button "nein" with icon note with title "EyeTV-Recorder" giving up after 30
if button returned of antwort = "Ja" or button returned of antwort = "" then
tell application "Finder"
ignoring application responses
shut down
end ignoring
end tell
end if
if button returned of antwort = "Ruhezustand" then
tell application "Finder"
ignoring application responses
sleep
end ignoring
end tell
end if
end if
end if
end tell
end if
end if
end RecordingDone
Das fertige Skript wird in Ordner /Library/Application Support/EyeTV/Scripts/TriggeredScripts abgelegt. Wichtig ist hierbei, dass der Name korrekt ist (RecordingDone.scpt), ansonsten findet EyeTV das Skript nicht.