I am able to get this udev rule in 99-monitor-hotplug.rules to trigger:
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1",
RUN+="/usr/local/bin/monitor-hotplug.sh"
But I cannot seem to get it to trigger an OpenCV GUI application in the monitor-hotplug.sh script.
I understand fundamentally the udev rule runs as root but no matter what syntax I try I cannot get it to run properly at the user level for running the application (the actual script to run the application works fine).
I have tried in RUN this format:
su - your_X_user_here -c 'export DISPLAY=:0; bash -c "/path/to/script.sh"'
with script:
#!/bin/bash
#sleep 5
date >> /var/log/opencvlog.log
cd ~/Downloads
./displayimage /home/<username>/Pictures/picture.png
>/var/log/application.log
2>&1
Another attempt:
Adding in 99-monitor-hotplug.rules to the current syntax:
ACTION=="change", SUBSYSTEM=="drm", ENV{DISPLAY}=":0",
ENV{XAUTHORITY}="/home/<username>/.Xauthority" ENV{HOTPLUG}=="1",
RUN+="/usr/local/bin/monitor-hotplug.sh"
then in the actual script:
export DISPLAY=:0
export XAUTHORITY=/home/<username>/.Xauthority
cd ~/Downloads
date
./displayimage /home/<username>/Pictures/picture.png
None of this is working, any thoughts on how to get this to work?
Thanks