Skip to main content

Notify Users with a dialog (macOS)

Description

The provided Fileset is a legacy example of notifying macOS users about FileWave Client log messages while Filesets download and activate.

Do not deploy this download unchanged to macOS Monterey 12.3 or later. Its notification helper uses /usr/bin/python and imports Apple’s Foundation classes. Apple removed the bundled Python 2.7 runtime in macOS 12.3, so the supplied helper cannot rely on that interpreter being present. Installing Python 3 alone does not update the script’s interpreter path or validate its notification dependencies.

For administrator-written messages on current deployments, use FileWave End-User Notifications (15.5+) and check its platform requirements. That feature sends messages; it is not a drop-in replacement for this example’s automatic log monitoring. The download and instructions below remain available for understanding the legacy implementation, not as a validated current-macOS recipe.

riBuSpNNTheDzFoR-embedded-image-hxrvggcl.png

 The Fileset is designed to:

  • Install a user LaunchAgent that watches /var/FileWave for changes and starts the log-monitoring script when triggered
  • Where Fileset changes occur, begin monitoring the FileWave Client log file
  • If the preset text strings are found in the log file, send this to the Notification Centre
  • Lastly, where another preset text is found, stop monitoring the log file

The Fileset includes an activation script that attempts to load the LaunchAgent for the current console user, and a pre-uninstallation script that attempts to unload it. The LaunchAgent is installed in /Library/LaunchAgents for user sessions. Its RunAtLoad value is false: loading the agent is not itself a request to run the notification script. The WatchPaths entry triggers monitoring, and the script exits when it sees the inventory-completion text described below.

Ingredients

  • Provided Fileset:

↓ macOS

PAzy07eC1dKpC63Y-embedded-image-zblnwzvg.png

Directions

For the example provided:

  • Download the necessary provided Fileset
  • Upload using FileWave Admin
  • Create a Deployment to the appropriate devices
  • 'Update Model'.

Fileset scripts may be modified for personal preference.  In each Fileset, there is a script that is executed by the local computer service.  The scripts are using a pattern match.  The pattern matching may be edited as required, removing or adding appropriately.

    macOS

    Locate the "prompt_user.sh" file within the Fileset and choose to edit.  In the following code block snippet from this script, the case statement is pattern-matching text.  In the provided example, the script is looking for lines that contain any one of the following:

    • Model version
    • Downloading Fileset
    • Done activating
    • Activate all

    Where found, the 'show_message' function is being used to prompt the user:

    prompt_user.sh
    # * are wildcard entries and | acts as a logical OR
    case "$line" in
    		*"Model version"*|*"Downloading Fileset"*|*"Done activating"*|*"Activate all"*)
    			show_message
    			;;

    The second part of the case statement is causing the script to exit.  The pattern match this time is any line that contains:

    • Data successfully sent to the inventory server
    prompt_user.sh
    *"Data successfully sent to the inventory server"*)
    			exit 0
    			;;

    Notification Center Permissions

    Notifications are a user's choice.  Users must accept notifications when prompted.

    The section below of the 'com.filewave.prompt_user.plist' may be edited as desired, where the defined keys determine the following:

    • 'the_title' is the Title of the notification
    • 'bundle_id' defines an App bundle.  That bundle's name and icon will be displayed:

    SkS3naXfhIYEUCgB-embedded-image-0jsymbzk.png

    com.filewave.prompt_user.plist
    <key>EnvironmentVariables</key>
    	<dict>
    		<key>the_title</key>
    		<string>FileWave Message</string>
    		<key>the_subtitle</key>
    		<string></string>
    		<key>bundle_id</key>
    		<string>com.filewave.fwGUI</string>
    	</dict>

    Users may still allow Notifications in System Preferences if previously denied:

    vhOgqN3rohOjw0WU-embedded-image-k7zce59j.png

    Launch Services
    Once a launch service is running, editing an already loaded script will have no impact on the current service; the service itself must be reloaded.  If parts of the Fileset are edited after association, consideration should be taken into account to ensure those changes are made active.

    Notes

    The above provides an example of notifying users using a service.  However, with some adaptation, messages could be sent in other ways at alternate times to users.

    Related Content