System doesn't detect hot-plugged display port(through thunderbolt connector)

I found your code and persisted in trying to make it work. Under NO conditions could i make it work with an "if then" paradigm. the "xrandr|grep" ALWAYS failed to be true when run as udev trigger, but worked if i ran it manually. I was FORCED to break it into two scripts.

Although my device is different (StarTech CDPVGDVHDMDP), i will post my version here.

First, i found it helpful to reload udev rules when troubleshooting:

sudo udevadm control --reload-rules

My device was a little different, and i found that subsystem "hidraw" was something i could trigger off of. Also, I was forced to run /bin/bash /path/to/script"; otherwise it did not run. This is my udev rule (/etc/udev/rules.d/95-monitor-hotplug.rules):

ACTION=="remove", SUBSYSTEM=="hidraw", RUN+="/bin/bash /home/user/scripts/hotunplug-displayport.sh"
ACTION=="add", SUBSYSTEM=="hidraw", RUN+="/bin/bash /home/user/scripts/hotplug-displayport.sh"

This is my hotplug script

#!/bin/bash
export XAUTHORITY=/home/user/.Xauthority
DISPLAY=:0 /usr/bin/xrandr --addmode DP-1 1680x1050
DISPLAY=:0 /usr/bin/xrandr --output DP-1 --right-of  eDP-1 --mode 1680x1050
echo "$(date) : Hotplug Connect DP-1" >> /var/log/hotplug.txt
DISPLAY=:0 /usr/bin/xrandr --addmode DP-2 1680x1050
DISPLAY=:0 /usr/bin/xrandr --output DP-2 --right-of  eDP-1 --mode 1680x1050
echo "$(date) : Hotplug Connect DP-2" >> /var/log/hotplug.txt

This is my hot-unplug script

#!/bin/bash
export XAUTHORITY=/home/user/.Xauthority
DISPLAY=:0 /usr/bin/xrandr --output DP-1 --off
echo "$(date) : Hotplug Disconnect DP-1" >> /var/log/hotplug.txt
DISPLAY=:0 /usr/bin/xrandr --output DP-2 --off
echo "$(date) : Hotplug Disconnect DP-2" >> /var/log/hotplug.txt