12,278
edits
m (Created page with "Wehn setting up installations for exhibitions Automating the startup and shutdown is essential in order to make sure your piece is actually running. Never rely on staff to switch...") |
mNo edit summary |
||
(19 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
When setting up installations for exhibitions automating the startup and shutdown is essential in order to make sure your piece is actually running. Never rely on staff to switch on things. | |||
== Programmable time switches == | == Programmable time switches == | ||
are quite cheap and very useful | are quite cheap and very useful | ||
[[File:Zeitschaltuhr.jpg|300px]] | |||
left: a digital one, right: an analogue one | |||
== Raspberry Pi == | |||
Very useful inexpensive Linux Computer you can use for all kinds of scenarios. For example to play back a video in an exhibition: [[/RaspberryPi/]] | |||
== Startup and shutdown == | == Startup and shutdown == | ||
OS X has startup and shutdown automation included, it's hidden in the Energy Saving preference pane. | OS X has startup and shutdown automation included, it's hidden in the Energy Saving preference pane. | ||
[[OS X Preference Panes.png]] | [[File:OS X Preference Panes.png]] | ||
[[Energie sparen.png]] | [[File:Energie sparen.png]] | ||
[[Zeitplan.png]] | It is a good idea to tick the box that the computer will restart after a power failure. | ||
[[File:Zeitplan.png]] | |||
The computer will effectively shut down 10 minutes later than set there, because it will wait 10 minutes with a message open to give the user a chance to abort the shutdown process. | |||
== Do something on startup == | == Do something on startup == | ||
OS X can launch a script or application on startup. you can set this in the Users preference pane under startup items. | OS X can launch a script or application on startup. you can set this in the Users preference pane under startup items. | ||
[[Startobjekte.png]] | [[File:Startobjekte.png]] | ||
== shell scripts == | == shell scripts == | ||
Line 24: | Line 37: | ||
=== ScreenUtil === | === ScreenUtil === | ||
[http://www.osxsoft.net ScreenUtil] lets you set the screen resolution over the command line. | [http://www.osxsoft.net ScreenUtil] lets you set the screen resolution over the command line. | ||
=== launchd === | |||
launchd is the service in OS X that replaces the UNIX <tt>cron, init</tt> and <tt>at</tt> commands. Put the configuration files into <tt>~/Library/LaunchAgents</tt> | |||
== AppleScript == | |||
Unfortunately one can't use the control panel to only switch on the computer at certain days of the week. What you can do is check the day of the week and then shut the computer down again if it isn't the right day. | |||
<source lang="applescript"> | |||
-- wenn nicht Mittwoch, Samstag oder Sonntag it, dann schalte den rechner wieder aus. | |||
set closedDays to {Monday, Tuesday, Thursday, Friday} | |||
if closedDays contains ((current date)'s weekday) then | |||
tell application "System Events" | |||
shut down | |||
end tell | |||
return | |||
end if | |||
-- Systemlautstärke voll | |||
set volume 5 | |||
-- QuickTime starten | |||
tell application "Finder" | |||
activate | |||
open application file "QuickTime Player.app" of folder "Applications" of startup disk | |||
end tell | |||
tell application "QuickTime Player" | |||
activate | |||
open file "Macintosh HD:Users:name:Documents:Folder:subfolder:my_sound.wav" | |||
set looping of document "my_sound.wav" to true | |||
set audio volume of document "my_sound.wav" to 0.5 | |||
play document "my_sound.wav" | |||
end tell | |||
</source> | |||
To time events use iCal and run scripts on specific (repeating) entries. This creates <tt>launchd</tt> events. Alternatively use <tt>launchd</tt> directly. If you have an AppleScript running in a loop you may want to exit this loop at a specific time like this: | |||
<source lang="applescript"> | |||
repeat | |||
set currentMinute to minutes of (current date) | |||
set currentHour to hours of (current date) | |||
if (currentHour = 17) then | |||
if (currentMinute > 50) then | |||
tell application "System Events" | |||
shut down | |||
exit repeat | |||
end tell | |||
end if | |||
end if | |||
delay 0.3 | |||
end repeat | |||
</source> | |||
* [http://developer.apple.com/library/mac/#documentation/AppleScript/Conceptual/AppleScriptX/AppleScriptX.html AppleScript introduction] | |||
== Automator == | |||
Automator is an application in Mac OS X which lets you automate tasks in a very easy way. | |||
* [http://developer.apple.com/library/mac/#documentation/AppleApplications/Conceptual/AutomatorConcepts/Automator.html#//apple_ref/doc/uid/TP40001450 Automator reference] | |||
[[Category:AppleScript]] | |||
[[Category:Automation]] | |||
[[Category:Programmiersprachen]] | |||
[[Category:OS X]] |