Skip to content

Script Examples

Simone Martorelli edited this page Apr 30, 2024 · 7 revisions

While the IBM Notifier (Mac@IBM Notifications) app can be run without administrative permissions, any framework that executes scripts outside of the user context will require that you capture and impersonate that user to display the popup.

Below are two script examples of a Pop-up Dialog box that can be run either locally or through an MDM script delivery framework like Jamf. The additional examples that follow are intended to be executed locally for testing purposes.

Pop-up Dialog box (1 or 2 Buttons)

Shell

#!/bin/bash

# IBM Notifier binary paths
NA_PATH="/Applications/IBM Notifier.app/Contents/MacOS/IBM Notifier"

# Variables for the popup notification for ease of customization
WINDOWTYPE="popup"
BAR_TITLE="My Organization's Notification"
TITLE="Enter App Specific Title Here"
TIMEOUT="" # leave empty for no notification time
BUTTON_1="OK"
BUTTON_2="Cancel"
SUBTITLE="Enter popup information here. \n\nThis can be whatever you want."

### FUNCTIONS ###

prompt_user() {
    # This will call the IBM Notifier Agent
    # USAGE: prompt_user "1" for two buttons, otherwise just the function for one
    if [[ "${#1}" -ge 1 ]]; then
        sec_button=("-secondary_button_label" "${BUTTON_2}")
    fi

    button=$("${NA_PATH}" \
        -type "${WINDOWTYPE}" \
        -bar_title "${BAR_TITLE}" \
        -title "${TITLE}" \
        -subtitle "${SUBTITLE}" \
        -timeout "${TIMEOUT}" \
        -main_button_label "${BUTTON_1}" \
        "${sec_button[@]}" \
        -always_on_top)

    echo "$?"
}

### END FUNCTIONS ###

# Example 1 button prompt
RESPONSE=$(prompt_user)
echo "$RESPONSE"

# Example 2 button prompt
RESPONSE=$(prompt_user "1")
echo "$RESPONSE"

Python

#!/usr/bin/env python3

# Put the rest of your python libraries below this list if required
import subprocess
from SystemConfiguration import SCDynamicStoreCopyConsoleUser

# IBM Notifier binary path
NA_PATH = "/Applications/IBM Notifier.app/Contents/MacOS/IBM Notifier"

# Variables for the popup notification for ease of customization
WINDOWTYPE = "popup"
BAR_TITLE = "My Organization's Notification"
TITLE = "Enter App Specific Title Here"
TIMEOUT = ""  # leave empty for no notification time
BUTTON_1 = "OK"
BUTTON_2 = "Cancel"
SUBTITLE = "Enter popup information here. \n\nThis can be whatever you want."

"""### FUNCTIONS ###"""

def prompt_user(two_button):
    """This will call the IBM Notifier Agent
    USAGE: prompt_user('1') for two buttons, otherwise just prompt_user('') for one"""
    nota = [
        NA_PATH,
        "-type", WINDOWTYPE,
        "-bar_title", BAR_TITLE,
        "-title", TITLE,
        "-subtitle", SUBTITLE,
        "-timeout", TIMEOUT,
        "-main_button_label", BUTTON_1,
        "-always_on_top",
    ]

    if two_button != "":
        sec_button = ["-secondary_button_label", BUTTON_2]
        temp_list = nota[: len(nota) - 1] + sec_button + nota[len(nota) - 1 :]
        nota = temp_list

    proc = subprocess.run(nota, check=False)
    return proc.returncode

"""### END FUNCTIONS ###"""

if __name__ == "__main__":
    # Example 1 button prompt
    BUT_RESP = prompt_user("")
    print(BUT_RESP)

    # Example 2 button prompt
    BUT_RESP = prompt_user("1")
    print(BUT_RESP)

Thanks @homebysix (Elliot Jordan) for this!

Custom Pop-up Dialog Box with Embedded Picture

Shell

#!/bin/bash
# Deploy an encoded jpg within the script to be used within a dialog popup

# IBM Notifier binary paths
NA_PATH="/Applications/IBM Notifier.app/Contents/MacOS/IBM Notifier"

# Variables for the popup notification for ease of customization
WINDOWTYPE="popup"
BAR_TITLE="My Organization's Notification"
TITLE="Enter App Specific Title Here"
TIMEOUT="" # leave empty for no notification time
BUTTON_1="OK"
BUTTON_2="Cancel"
SUBTITLE="Enter popup information here. \n\nThis can be whatever you want."

# Base64 encoded picture, can be replaced with a static location in -accessory_view_payload
# The benefit here is that a custom picture can be distributed with a script without requiring a separate
# payload to deliver it if it is not accessible via network path
PU_PIC="/9j/4AAQSkZJRgABAQAAkACQAAD/4QCeRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAACQAAAAAQAAAJAAAAABAAOShgAHAAAAEgAAAISgAgAEAAAAAQAAAS2gAwA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jExMTExNzc3Nzc3Nzc3Nz/2wBDASIkJDg0OGA0NGDmnICc5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ubm5ub/3QAEABP/2gAMAwEAAhEDEQA/AMOiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9DDooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//Rw6KKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAoqdYHYZJoa3YDIwanmRp7Kdr2IKKKKozCiiigAooooAKKKKAP//Sw6KKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAFFWbdAwLGqtXLc/KfrUz2NqCTnqTkqoy1Irq43CoZIS7ZzxUyIEGBWOh3JyctdircKFfI71Xqadgz8dqhreOx59W3NoFFFFMzCiiigAooooA//08OiiigAooooAKKKKAQoBJwKCCDg0+P/AFi/WnT8SGlfWxaj7vMQ0UUUyAooooAKKKKACiiigAoopQCelA0r7CUUUUCCiiigAooooAKKKKACno5jORTKKGhxbWqLouEPJGDUTzkjCiq9FTyI1debVgoooqjEKKKKACiiigAooooA/9TDooooAKKKKACiiigCSL/WCnXH+spsf+sFPuP9ZUP4jZfw36kFFFFWYhRRRQAUUUUAFFFFABVq26saq1aturfhUSNqPxld/vn602nyffb60yqWxnJasKKKKZIUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAH//1cOiiigAooooAKKKKAHKcMDVi5HIb1qr05q5J88QNRLdG8PgcSnRRRVmAUUUUAFFFFABRRRQAVbtup/CqlWbbjP4VEtjah8ZFIMO1R1NOMSmoapbET3YUUUUyAooooAKKKKACiiigAoqaGMSE7uwqIjBIHalcpwaVxKKKKZIUUUUAFFFFABRRRQB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RRRQAUUUUAFFFFAH//08OiiigAooooAKKKKACiiigAqzbH5iKrVNAcSVMtjWi7SQkww5qKrFwPnzVenHYVRWkwooopmYUUUUAFFFFABVu2PDD3qpVi3PzEetRLY2oO00NuP9aahqe4/wBYagqo7E1PiYUUUUzMKKKKACiiigC7b/cNVpf9Y1WLb7h+tV5v9Y1Zx+JnVP8AhIjooorQ5QooooAKKKKACiiigD//1MOiiigAooooAKKKKACiiigAqSLhwajpQcEGk9hxdmmWLjqKrVNNIJCCB0qGlHY0qu8m0FFFFUZBRRRQAUUUUAFORijbhTaKBp2d0PkcyNuNMooo2Bu+rCiiigQUUUUAFFFFAFy3+4frUE3+tJpYpfLG0jIqNm3MTUJe8dE5p00htFFFWc4UUUUAFFFFABRRRQB//9XDooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//Ww6KKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/18OiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/9DDooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//Z"


# Draw the pop-up with custom embedded picture
RESPONSE=$("${NA_PATH}" \
    -type "${WINDOWTYPE}" \
    -bar_title "${BAR_TITLE}" \
    -title "${TITLE}" \
    -subtitle "${SUBTITLE}" \
    -timeout "${TIMEOUT}" \
    -main_button_label "${BUTTON_1}" \
    -secondary_button_label "${BUTTON_2}" \
    -accessory_view_type "image" \
    -accessory_view_payload "${PU_PIC}" \
    -always_on_top)


Progress Bar with Cancel button

Shell


#!/bin/bash

RAND_QUOTE=("Making Things Faster" "Adding Sparkles" "Reticulating Splines" "Thowing Wrenches" \
"rm -rf'ing Directories" "Lorem Ipsumming" "Agitating Employees" "Eating Doughnuts")
PIPE_NAME="pbnota"
COUNTER=0

# FIFO creation and setup process for updating the progress bar
find /private/tmp -name "$PIPE_NAME" -delete
mkfifo /private/tmp/${PIPE_NAME}
exec 3<> /private/tmp/${PIPE_NAME}

# IBM Notifier Progress Bar configuration
"/Applications/IBM Notifier.app/Contents/MacOS/IBM Notifier" \
-type "popup" \
-title "Test Progress Bar" \
-subtitle "You should see some progress here" \
-accessory_view_type "progressbar" \
-accessory_view_payload "/percent 0 /user_interruption_allowed True" \
-main_button_label "OK" < /private/tmp/${PIPE_NAME} &

PB_PS=$(pgrep "IBM Notifier")
echo "$PB_PS"

# In this example we are doing a 5 digit increment up to 100 and updating the progress bar messages with a
# random selection from our quote array defined above. In real world usage your update commands would run
# in the until block and update your progress percentage and description accordingly.
until [[ "$COUNTER" -ge 100 ]]; do
    if [[ $(pgrep -q "IBM Notifier"; echo $?) -ne 0 ]]; then
        # Cancel initiated, roll back changes and break the until loop here
        CANCEL=1
        echo "Rolling back"
        break
    fi
    COUNTER=$((COUNTER + 5))
    QUOTE_NBR=$(jot -r 1 0 7)
    echo -n "/percent $COUNTER /top_message ${RAND_QUOTE[$QUOTE_NBR]} /bottom_message ${COUNTER}% completed" >&3
    sleep 1
done

wait "$PB_PS"

# Clean up the progress bar after completion or early exit
exec 3>&-
find /private/tmp -name ${PIPE_NAME} -delete

if [[ "$CANCEL" -eq 1 ]]; then
    echo "Progress bar terminated early"
else
    echo "Progress bar completed successfully"
fi

Onboarding

Shell

#!/bin/bash

# IBM Notifier binary paths
NA_PATH="/Applications/IBM Notifier.app/Contents/MacOS/IBM Notifier"

# Variables for the popup notification for ease of customization
WINDOWTYPE="onboarding"
PAYLOAD=$(cat <<-END
{
   "pages":[
      {
         "title":"First page's title",
         "subtitle":"First page's subtitle",
         "body":"First page's body",
         "mediaType":"image",
         "mediaPayload":"http://image.address"
      },
      {
         "title":"Second page's title",
         "subtitle":"Second page's subtitle",
         "body":"Second page's body",
         "mediaType":"video",
         "mediaPayload":"http://video.address"
      },
      {
         "title":"Third page's title",
         "subtitle":"Third page's subtitle",
         "body":"Third page's body",
         "mediaType":"image",
         "mediaPayload":"base64encodedimage",
         "infoSection":{
            "fields":[
               {
                  "label":"First label only"
               },
               {
                  "label":"Second label only"
               },
               {
                  "label":"Third label only"
               }
            ]
         }
      }
   ]
}
END
)

### FUNCTIONS ###

prompt_user() {
    button=$("${NA_PATH}" \
        -type "${WINDOWTYPE}" \
        -payload "${PAYLOAD}")

    echo "$?"
}

### END FUNCTIONS ###

RESPONSE=$(prompt_user)
echo "$RESPONSE"

Legacy Scripts (Unsupported)

Python

#!/usr/bin/env python2.7

# Put the rest of your python libraries below this list if required
import subprocess
from SystemConfiguration import SCDynamicStoreCopyConsoleUser

# IBM Notifier binary paths
NA_PATH = '/Applications/IBM Notifier.app/Contents/MacOS/IBM Notifier'

# Variables for the popup notification for ease of customization
WINDOWTYPE = 'popup'
BAR_TITLE = "My Organization's Notification"
TITLE = 'Enter App Specific Title Here'
TIMEOUT = '' # leave empty for no notification time
BUTTON_1 = 'OK'
BUTTON_2 = 'Cancel'
SUBTITLE = 'Enter popup information here. \n\nThis can be whatever you want.'

'''### FUNCTIONS ###'''

def prompt_user(two_button):
    '''This will call the IBM Notifier Agent
       USAGE: prompt_user('1') for two buttons, otherwise just prompt_user('') for one'''
    nota = [NA_PATH,
                '-type', WINDOWTYPE,
                '-bar_title', BAR_TITLE,
                '-title', TITLE,
                '-subtitle', SUBTITLE,
                '-timeout', TIMEOUT,
                '-main_button_label', BUTTON_1,
                '-always_on_top']

    if two_button <> '':
        sec_button = ['-secondary_button_label', BUTTON_2]
        temp_list = nota[:len(nota) - 1] + sec_button + nota[len(nota) - 1:]
        nota = temp_list

    proc = subprocess.Popen(nota, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    proc.communicate()[0]
    return proc.returncode

'''### END FUNCTIONS ###'''


if __name__ == "__main__":
    # Example 1 button prompt
    BUT_RESP = prompt_user('')
    print BUT_RESP

    # Example 2 button prompt
    BUT_RESP = prompt_user('1')
    print BUT_RESP