Looking at the parent pid helps regarding this.
[root@centos8 ranger-1.9.3]# ps -fp $PPID
UID PID PPID C STIME TTY TIME CMD
root 3240 3214 0 08:03 pts/1 00:00:00 /usr/bin/python3 -O /usr/local/bin/ranger
[root@centos8 ranger-1.9.3]#
So try
ps -fp $PPID | grep -q ranger && echo True || echo False