My Mac is at home and I am not, so I canβt check this solution, but what about something like:
ps -ef | grep [s]creencapture > nul; echo $?
The brackets [] prevent grep from matching this grep command, allowing it to match all other commands containing "screencapture". (Assuming "screencapture" is the name of the process you are trying to detect.)
source share