See Software Update notifications as a non-admin user

Mar 03, '09 07:30:03AM

Contributed by: ansiwen

I use Mac OS X while logged in as a non-admin user. The problem with this is that the Software Update notification only appears if I am logged in as a user with administrative rights. In a real multi-user environment this makes sense, because the ordinary user should not be confused with things he's not responsible for.

But what about the situation with the typical single user machine, where the owner uses a non-admin account for normal work? (And everybody should do so!) In this case, the user is the administrator, although he or she is using a non-admin account. In this very common case, the user should get the software update notifications so he/she can react to them. However, even if the Check for Updates option is selected in the Software Update panel of System Preferences, there will be no notifications. You can argue if this is a bug or not, but it's how it works.

To solve this problem, I wrote a little AppleScript (in fact, it's embedded into a launchd plist file, so you only have to care about one file) that checks once per day if there are any software updates available. If there are any, they are displayed in a nice looking Growl notification, if Growl is installed (highly recommended!). Otherwise, they show up in a standard system dialog. Here's the code (note that the latest version can be found in this post on my blog):

<?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">
<!--
    updateCheck - Copyright 2008 Sven Anderson sven_at_anderson.de

    This is an applescript based launch agent, that checks once per day
    for available software updates. If there are any, it announces them
    as a Growl notification or - if it is not installed - as a system
    dialog. This agent also works for users without administrative rights.

    To install it, move this file to ~/Library/LaunchAgents/ and
    re-login.

    Installing Growl is highly recommended: http://growl.info/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

For a copy of the GNU General Public License see
   http://www.gnu.org/licenses/

-->
<dict>
    <key>Label</key>
    <string>de.anderson.sven.updateCheck</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Nice</key>
    <integer>1</integer>
    <key>ProgramArguments</key>
    <array>
        <string>osascript</string>
        <string>-e</string>
        <string>
set theList to every paragraph of (do shell script "softwareupdate -l")
set updates to ""
repeat with anItem in theList
    if anItem starts with "   * " then
        if updates is not "" then
            set updates to updates &amp; return
        end if
        set updates to updates &amp; (characters 6 thru -1 of anItem)
    end if
end repeat
if updates is not "" then
    tell application "System Events"
        set isRunning to (count of (every process whose name is "GrowlHelperApp")) &gt; 0
    end tell
    if isRunning then
        tell application "GrowlHelperApp"
            register as application "UpdateCheck" all notifications {"Update Available"} default notifications {"Update Available"} icon of application "Software Update"
            notify with name "Update Available" title "Software Update available" description updates application name "UpdateCheck" sticky yes
        end tell
    else
        tell application "Finder"
            ignoring application responses
                display dialog "Software Update available:" &amp; return &amp; updates with title "Software Update available" buttons "OK" default button 1 with icon file "System:Library:CoreServices:Software Update.app:Contents:Resources:Software Update.icns"
            end ignoring
        end tell
    end if
end if
</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>86400</integer>
</dict>
</plist>
Save the above code as de.anderson.sven.updateCheck.plist into your user's Library/LaunchAgents folder (create this folder if necessary). Then logout and login, or enter the following command in the Terminal, to activate the code:
$ launchctl load ~/Library/LaunchAgents/de.anderson.sven.updateCheck.plist
I've been using this code for over a year now without any problems, so I decided to make it available to everybody.

Comments (20)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090227092240386