Nvidia Card doesn't register udev hotplug event

Don’t now, just always use full paths.

I added the path to the opencvapplication in my ~/.profile so I am able to run it from anywhere. The only other thing I can think of is that I pass a parameter to my opencvapplication when running. So to run I go
./opencvapplication 122

Is this part of the problem?

If you add the path to ~/.profile you’ll have to make sure that you’re running the application as that user and set up the environment correctly. This is basic shell scripting stuff and really beyond the scope of this forum.

Generix,

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//Pictures/picture.png >/var/log/application.log 2>&1

Another attempt:

Adding in 99-monitor-hotplug.rules :

ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home//.Xauthority"

then in the actual script:

export DISPLAY=:0
export XAUTHORITY=/home//.Xauthority
cd ~/Downloads
date
./displayimage /home//Pictures/picture.png

None of this is working, can you please assist, is there something specific one has to do on Nvidia Cards? Other people have confirmed the two solutions worked fine on other platforms.

Try this:

#!/bin/bash
su - <username> -c "export DISPLAY=:0 && cd ~/Downloads && ./displayimage /home/<username>/Pictures/picture.png >/home/<username>/application.log 2>&1"

Hi Generix,

Thanks for your help so far - when I run the script above from the terminal it asks for the password which I type in and then the GUI application launches (this makes sense as it needs to be run as root).

I then tried with 99-monitor-hotplug.rules:

SUBSYSTEM==“drm”, ACTION==“change”, ENV{HOTPLUG}==“1”, RUN+="/home//Downloads/hotplug.sh"

and the hotplug.sh script:

#!/bin/bash
su - -c “export DISPLAY=:0 && cd ~/Downloads && ./displayimage /home//Pictures/picture.png >/home//application.log 2>&1”

This doesn’t load the application nor does it create application.log

I then tried to run the command directly in RUN in 99-monitor-hotplug.rules:

SUBSYSTEM==“drm”, ACTION==“change”, ENV{HOTPLUG}==“1”, RUN+=“su - -c ‘export DISPLAY=:0 && cd ~/Downloads && ./displayimage /home//Pictures/picture.png >/home//application.log 2>&1’”

This also doesn’t load the application nor does it create application.log

What could be causing this?

Thanks