Enabling the Zoom Accessibility Keyboard Setting Programmatically

apizz
Valued Contributor

One of the features many of teachers use is the keyboard shortcut to Zoom ( Command Option + ; Command Option - ). Know there is zoom / text enlarging functionality in browsers, but sometimes the OS Zoom method is required.

I've been trying to come up with a script that enables this feature, without having to have users (or IT) manually turn this on.

I've been able to isolate the PLIST keys and values within com.apple.symbolichotkeys.plist to 5 keys that need to be enabled: 15, 17, 179, 19, and 23.

Using PlistBuddy I've been able to write a script that changes these boolean logic from false to true, but open System Prefs and navigating to the Keyboard shortcuts does not show this as enabled. Trying the keyboard combinations does not work either. Only when we manually enable the preference.

Any ideas?

#!/bin/bash

# In current form, it sets the preferences that change when Zoom is enabled,
# but it doesn't actually enable unless you click the checkbox in Keyboard prefs.

USER=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
PLIST_BUDDY="/usr/libexec/PlistBuddy"
PLIST="/Users/$USER/Library/Preferences/com.apple.symbolichotkeys.plist"
ZOOM_PREF=(':AppleSymbolicHotKeys:15:enabled'
':AppleSymbolicHotKeys:17:enabled'
':AppleSymbolicHotKeys:179:enabled'
':AppleSymbolicHotKeys:19:enabled'
':AppleSymbolicHotKeys:23:enabled')

for ((i = 0; i < "${#ZOOM_PREF[@]}"; i++))
do
    $PLIST_BUDDY -c "set ${ZOOM_PREF[$i]} true" "$PLIST"

    if [ $? = 0 ]; then
        /bin/echo "${ZOOM_PREF[$i]} Successful for ${USER}!"
    else
        /bin/echo "${ZOOM_PREF[$i]} Failed for ${USER}."
    fi
done

/usr/bin/defaults write /Users/$USER/Library/Preferences/com.apple.universalaccess closeViewHotkeysEnabled -bool true

if [ $? = 0 ]; then
    /bin/echo "com.apple.universalaccess pref successful for ${USER}!"
else
    /bin/echo "com.apple.universalaccess pref failed for ${USER}."
fi
0 REPLIES 0