Firmware Updates Redux

Mac firmware updates generally need some sort of user intervention in order to apply them.

This makes it very difficult to automate the process. I did manage at one point to automate SMC updates, but EFI updates and other hardware (keyboards, trackpads, graphics) each have their own issues.

So I finally decided to just punt on the issue. Here’s what I do now: a script runs at login and checks softwareupdate, looking for available firmware updates. If there are any, the user is notified to call the help desk.
Continue reading “Firmware Updates Redux”

Firmware Updates Redux

Universal AppleScript applets

appletI hadn’t seen this documented anywhere else, and just stumbled across it… I wanted to update several AppleScript applets that were PowerPC applications into Univeral binaries.

Note I’m talking about the sort of AppleScript applications that one builds with Script Editor and saving the script as an application – not AppleScript Studio apps.

When you save an AppleScript in Script Editor, there are several options in the File Format menu. If you choose “application”, you’ll get a PowerPC-only app. However, if you choose “application bundle”, you’ll get a Universal app.

So open your AppleScript apps in Script Editor, and resave them as “application bundles” and you are set!

Universal AppleScript applets

Display appliance: The Revenge; or Scripting QuickTime Player

QuickTime PlayerIn previous posts, we’ve told launchd to watch a directory for changes and launch a Perl script when changes occur. This script will tell QuickTime Player what to do.

I have a web CGI that people can use to select which QuickTime movie to display. This CGI then creates a symlink called “next.mov” that points to the selected movie. The Perl script looks for this file. Note that we don’t need QuickTime Pro in order to display the movie full-screen; AppleScript can tell QuickTime Player to go full-screen even without QuickTime Pro.

Here is a stripped-down version of the script I use:


#!/usr/bin/perl -w
 
use strict;
 
my $loggedInUser = `who | grep console`;
 
# directory in which we look for movies to play
my $mediapath = "/Users/Shared/DigitalWalkway/display";
 
if ($loggedInUser ne "") {
   # if there is a symlink at "$mediapath/next.mov" then
   # close the current movie and rename next.mov to current.mov
   if (-l "$mediapath/next.mov") {
      closeCurrentMovie();
      rename "$mediapath/next.mov", "$mediapath/current.mov";
   }
 
   # if there is a symlink at "$mediapath/current.mov" then
   # play it if its not already playing
   if (-l "$mediapath/current.mov" ) {
      # readlink gets the actual path of the file
      # that the symlink points to
      my $realpath = `readlink "$mediapath/current.mov"`;
      chomp $realpath;
 
      # basename strips off the path
      # and leaves just the filename
      my $realname = `basename "$realpath"`;
      chomp $realname;
 
      # we use osascript to embed an AppleScript into the Perl
      # script. in the AppleScript, we check to see if the
      # currently playing movie's name is the real name of
      # he current.mov link so we don't keep restarting
      # the same movie over and over
      `osascript<<EOF
tell application "QuickTime Player"
   activate
   set show welcome movie automatically to false
   copy "" to movieName
   if number of movies > 0 then
      copy (name of front movie) to movieName
   end if
   if (movieName is not "$realname") then
      open POSIX file "$mediapath/current.mov"
      set looping of movie 1 to true
      present movie 1 scale screen
   else
      if (display state of front movie is not presentation) then
         present front movie scale screen
      end if
      if (playing of front movie is false) then
         play front movie
      end if
   end if
end tell
EOF`;
   }
}
 
 
sub closeCurrentMovie {
   `osascript<<EOF
tell application "QuickTime Player"
   close every movie
end tell
EOF`;
   if (-l "$mediapath/current.mov" ) {
      unlink "$mediapath/current.mov";
   }
}

Display appliance: The Revenge; or Scripting QuickTime Player