udev rule doesnt trigger GUI application
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
linux ubuntu linux-device-driver udev hotplugging
add a comment |
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
linux ubuntu linux-device-driver udev hotplugging
add a comment |
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
linux ubuntu linux-device-driver udev hotplugging
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
linux ubuntu linux-device-driver udev hotplugging
linux ubuntu linux-device-driver udev hotplugging
edited Nov 22 '18 at 22:01
Mr OpenCV
asked Nov 22 '18 at 21:55
Mr OpenCVMr OpenCV
265
265
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
When using display managers like gdm the current X authority file might not be in the user home directory, but in runtime directories like /run or /var/run.
You may try something like:
USER=<username>
export XAUTHORITY=$(find /var/run/gdm3/ -type f -path "*${USER}*" 2> /dev/null)
Newer gdm versions seem to put the file in a more generic location:
export XAUTHORITY=$(find /run/user/$(id -u "$USER")/ -name Xauthority 2> /dev/null)
I used this technique to call xrandr to adjust the screen resolution from a udev rule:
https://git.ao2.it/libam7xxx.git/blob/HEAD:/contrib/am7xxx-autodisplay.sh
Thanks for your response, I think what you are saying makes sense. I am using lightdm window manager, I think this is the correct path for Xauthority: XAUTHORITY=/var/run/lightdm/root/:0 . Even with this my script for gui application doesn't trigger based on the udev rule. Does this Xauthority value appear correct to you? Thanks
– Mr OpenCV
Dec 3 '18 at 15:34
I would expect something like/var/run/lightdm/$USER/xauthoritycheck if something like this is available after$USERhas logged in. It might be that this feature is not enabled by default by LightDM, see bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1648107/comments/… and askubuntu.com/questions/960793/…
– Antonio Ospite
Dec 4 '18 at 16:07
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438382%2fudev-rule-doesnt-trigger-gui-application%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When using display managers like gdm the current X authority file might not be in the user home directory, but in runtime directories like /run or /var/run.
You may try something like:
USER=<username>
export XAUTHORITY=$(find /var/run/gdm3/ -type f -path "*${USER}*" 2> /dev/null)
Newer gdm versions seem to put the file in a more generic location:
export XAUTHORITY=$(find /run/user/$(id -u "$USER")/ -name Xauthority 2> /dev/null)
I used this technique to call xrandr to adjust the screen resolution from a udev rule:
https://git.ao2.it/libam7xxx.git/blob/HEAD:/contrib/am7xxx-autodisplay.sh
Thanks for your response, I think what you are saying makes sense. I am using lightdm window manager, I think this is the correct path for Xauthority: XAUTHORITY=/var/run/lightdm/root/:0 . Even with this my script for gui application doesn't trigger based on the udev rule. Does this Xauthority value appear correct to you? Thanks
– Mr OpenCV
Dec 3 '18 at 15:34
I would expect something like/var/run/lightdm/$USER/xauthoritycheck if something like this is available after$USERhas logged in. It might be that this feature is not enabled by default by LightDM, see bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1648107/comments/… and askubuntu.com/questions/960793/…
– Antonio Ospite
Dec 4 '18 at 16:07
add a comment |
When using display managers like gdm the current X authority file might not be in the user home directory, but in runtime directories like /run or /var/run.
You may try something like:
USER=<username>
export XAUTHORITY=$(find /var/run/gdm3/ -type f -path "*${USER}*" 2> /dev/null)
Newer gdm versions seem to put the file in a more generic location:
export XAUTHORITY=$(find /run/user/$(id -u "$USER")/ -name Xauthority 2> /dev/null)
I used this technique to call xrandr to adjust the screen resolution from a udev rule:
https://git.ao2.it/libam7xxx.git/blob/HEAD:/contrib/am7xxx-autodisplay.sh
Thanks for your response, I think what you are saying makes sense. I am using lightdm window manager, I think this is the correct path for Xauthority: XAUTHORITY=/var/run/lightdm/root/:0 . Even with this my script for gui application doesn't trigger based on the udev rule. Does this Xauthority value appear correct to you? Thanks
– Mr OpenCV
Dec 3 '18 at 15:34
I would expect something like/var/run/lightdm/$USER/xauthoritycheck if something like this is available after$USERhas logged in. It might be that this feature is not enabled by default by LightDM, see bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1648107/comments/… and askubuntu.com/questions/960793/…
– Antonio Ospite
Dec 4 '18 at 16:07
add a comment |
When using display managers like gdm the current X authority file might not be in the user home directory, but in runtime directories like /run or /var/run.
You may try something like:
USER=<username>
export XAUTHORITY=$(find /var/run/gdm3/ -type f -path "*${USER}*" 2> /dev/null)
Newer gdm versions seem to put the file in a more generic location:
export XAUTHORITY=$(find /run/user/$(id -u "$USER")/ -name Xauthority 2> /dev/null)
I used this technique to call xrandr to adjust the screen resolution from a udev rule:
https://git.ao2.it/libam7xxx.git/blob/HEAD:/contrib/am7xxx-autodisplay.sh
When using display managers like gdm the current X authority file might not be in the user home directory, but in runtime directories like /run or /var/run.
You may try something like:
USER=<username>
export XAUTHORITY=$(find /var/run/gdm3/ -type f -path "*${USER}*" 2> /dev/null)
Newer gdm versions seem to put the file in a more generic location:
export XAUTHORITY=$(find /run/user/$(id -u "$USER")/ -name Xauthority 2> /dev/null)
I used this technique to call xrandr to adjust the screen resolution from a udev rule:
https://git.ao2.it/libam7xxx.git/blob/HEAD:/contrib/am7xxx-autodisplay.sh
answered Nov 26 '18 at 11:13
Antonio OspiteAntonio Ospite
364
364
Thanks for your response, I think what you are saying makes sense. I am using lightdm window manager, I think this is the correct path for Xauthority: XAUTHORITY=/var/run/lightdm/root/:0 . Even with this my script for gui application doesn't trigger based on the udev rule. Does this Xauthority value appear correct to you? Thanks
– Mr OpenCV
Dec 3 '18 at 15:34
I would expect something like/var/run/lightdm/$USER/xauthoritycheck if something like this is available after$USERhas logged in. It might be that this feature is not enabled by default by LightDM, see bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1648107/comments/… and askubuntu.com/questions/960793/…
– Antonio Ospite
Dec 4 '18 at 16:07
add a comment |
Thanks for your response, I think what you are saying makes sense. I am using lightdm window manager, I think this is the correct path for Xauthority: XAUTHORITY=/var/run/lightdm/root/:0 . Even with this my script for gui application doesn't trigger based on the udev rule. Does this Xauthority value appear correct to you? Thanks
– Mr OpenCV
Dec 3 '18 at 15:34
I would expect something like/var/run/lightdm/$USER/xauthoritycheck if something like this is available after$USERhas logged in. It might be that this feature is not enabled by default by LightDM, see bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1648107/comments/… and askubuntu.com/questions/960793/…
– Antonio Ospite
Dec 4 '18 at 16:07
Thanks for your response, I think what you are saying makes sense. I am using lightdm window manager, I think this is the correct path for Xauthority: XAUTHORITY=/var/run/lightdm/root/:0 . Even with this my script for gui application doesn't trigger based on the udev rule. Does this Xauthority value appear correct to you? Thanks
– Mr OpenCV
Dec 3 '18 at 15:34
Thanks for your response, I think what you are saying makes sense. I am using lightdm window manager, I think this is the correct path for Xauthority: XAUTHORITY=/var/run/lightdm/root/:0 . Even with this my script for gui application doesn't trigger based on the udev rule. Does this Xauthority value appear correct to you? Thanks
– Mr OpenCV
Dec 3 '18 at 15:34
I would expect something like
/var/run/lightdm/$USER/xauthority check if something like this is available after $USER has logged in. It might be that this feature is not enabled by default by LightDM, see bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1648107/comments/… and askubuntu.com/questions/960793/…– Antonio Ospite
Dec 4 '18 at 16:07
I would expect something like
/var/run/lightdm/$USER/xauthority check if something like this is available after $USER has logged in. It might be that this feature is not enabled by default by LightDM, see bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1648107/comments/… and askubuntu.com/questions/960793/…– Antonio Ospite
Dec 4 '18 at 16:07
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438382%2fudev-rule-doesnt-trigger-gui-application%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown