Posts

Post not yet marked as solved
0 Replies
459 Views
I have the following script to take a screenshot programmatically $ cat /Users/bamboo/capture/capture #!/bin/bash screencapture -o "$(dirname "$0")/screenshot.png" When I run the script from a Terminal window for the first time, macOS asks me to give permission to the Terminal app for recording the screen. Afterwards the screenshot is stored in screenshot.png as expected. When I try to run the same script from a launch agent, however, I only get a screenshot of the empty desktop with none of the open windows displayed. This is the launch-agent plist $ cat /Users/bamboo/Library/LaunchAgents/com.capture.screen.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> &#9;&#9;<dict> &#9;&#9;&#9;&#9;<key>Label</key> &#9;&#9;&#9;&#9;<string>com.capture.screen</string> &#9;&#9;&#9;&#9;<key>KeepAlive</key> &#9;&#9;&#9;&#9;<true/> &#9;&#9;&#9;&#9;<key>ProgramArguments</key> &#9;&#9;&#9;&#9;<array> &#9;&#9;&#9;&#9;&#9;&#9;<string>/Users/bamboo/capture/capture</string> &#9;&#9;&#9;&#9;</array> &#9;&#9;&#9;&#9;<key>RunAtLoad</key> &#9;&#9;&#9;&#9;<true/> &#9;&#9;&#9;&#9;<key>StandardOutPath</key> &#9;&#9;&#9;&#9;<string>/Users/bamboo/capture/stdout.log</string> &#9;&#9;&#9;&#9;<key>StandardErrorPath</key> &#9;&#9;&#9;&#9;<string>/Users/bamboo/capture/stderr.log</string> &#9;&#9;</dict> </plist> I suspect this is a permission problem because before having granted permission for the Terminal app to record the screen, I was getting the same empty screenshot when running the script manually. However, no new entry shows up under Preferences > Security & Privacy > Privacy > Screen Recording after running the launch agent. How can I give permission to the launch agent for recording the screen?
Posted
by jm_kayak.
Last updated
.