Skip to main content

Notify Users with a dialog (macOS)

Description

The provided Fileset is an example of notifying users, in particular, a message regarding the Fileset status when downloading and installing new Filesets.

 The Fileset is designed to:

  • Create a continually running service that monitors Fileset changes
  • 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 service has been built to be actioned automatically by the user logging in.  Where Filesets are disassociated, each has a pre-uninstallation script to ensure that the services are also removed.

Ingredients

  • Provided Fileset:

↓ macOS

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.promptuser.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:

    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:

    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