From the answers given above and the link I found to Enable Safari Zoom by Script
there are several possibilities:
Shell script
# set pagezoom to 125%
killall Safari
defaults write com.apple.Safari DefaultPageZoom "1.25"
open -a Safari
I added this to a Keyboard Maestro macro that is started by a keyboard shortcut trigger (for now).
# revert pagezoom to 100%
killall Safari
defaults write com.apple.Safari DefaultPageZoom 1
open -a Safari
I added this to another Keyboard Maestro macro that is started by a keyboard shortcut trigger (for now).
This works great but the downside is that Safari needs to be restarted.
Apple script
-- set pagezoom to 125%
tell application "System Events"
tell application process "Safari"
set frontmost to true
keystroke "," using command down
delay 0.5
tell window 1
click button "Advanced" of toolbar 1 of it
click pop up button 3 of group 1 of group 1 of it
click menu item 6 of menu 1 of pop up button 3 of group 1 of group 1 of it
keystroke "w" using command down
end tell
end tell
end tell
or revert back to 100%
tell application "System Events"
tell application process "Safari"
set frontmost to true
keystroke "," using command down
delay 0.5
tell window 1
click button "Advanced" of toolbar 1 of it
click pop up button 3 of group 1 of group 1 of it
click menu item 4 of menu 1 of pop up button 3 of group 1 of group 1 of it
keystroke "w" using command down
end tell
end tell
end tell
This changes the page without restarting Safari. But from a Keyboard Maestro macro it doesn't work consistently.
Tinkertool
Tinkertool not only offers the ability to set the pagezoom for Safari, but also to set the default system fontsize. Caveat: change only takes effect after relaunching applications and Tinkertool is not scriptable so it requires manual intervention.
Conclusion
For now I'll stick with the Keyboard Maestro macros running the Apple scripts. When my big monitor is connected, the Logitech webcam is also connected so I added an extra trigger to the macros:
USB Device with Name Containing 'Webcam' is Attached
to increase the pagezoom and
USB Device with Name Containing 'Webcam' is Detached
to revert the pagezoom to 100%.
This allows me to automatically switch the pagezoom when connecting or disconnecting the big screen.