udev rule at boot time

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite
3












I have a udev rule to execute a simple command when a USB device is plugged (any device).



The rule is:



ACTION=="add", SUBSYSTEM=="usb", RUN+="/bin/sh -c 'xhost +local:pi; sudo -u pi xscreensaver-command -lock'"


This works quite well and the screen is blocked when I plug something into any of the USB ports.



But this isn't working when I already boot with the device plugged in. I expected to boot with the screen already locked.



What can I do to execute this rule at boot time? Is it possible?










share|improve this question





















  • Try sudo udevadm control --reload-rules && udevadm trigger and if that works incorporate it into boot after appropriate sleep of 10 seconds or so.
    – WinEunuuchs2Unix
    Apr 3 at 0:46














up vote
1
down vote

favorite
3












I have a udev rule to execute a simple command when a USB device is plugged (any device).



The rule is:



ACTION=="add", SUBSYSTEM=="usb", RUN+="/bin/sh -c 'xhost +local:pi; sudo -u pi xscreensaver-command -lock'"


This works quite well and the screen is blocked when I plug something into any of the USB ports.



But this isn't working when I already boot with the device plugged in. I expected to boot with the screen already locked.



What can I do to execute this rule at boot time? Is it possible?










share|improve this question





















  • Try sudo udevadm control --reload-rules && udevadm trigger and if that works incorporate it into boot after appropriate sleep of 10 seconds or so.
    – WinEunuuchs2Unix
    Apr 3 at 0:46












up vote
1
down vote

favorite
3









up vote
1
down vote

favorite
3






3





I have a udev rule to execute a simple command when a USB device is plugged (any device).



The rule is:



ACTION=="add", SUBSYSTEM=="usb", RUN+="/bin/sh -c 'xhost +local:pi; sudo -u pi xscreensaver-command -lock'"


This works quite well and the screen is blocked when I plug something into any of the USB ports.



But this isn't working when I already boot with the device plugged in. I expected to boot with the screen already locked.



What can I do to execute this rule at boot time? Is it possible?










share|improve this question













I have a udev rule to execute a simple command when a USB device is plugged (any device).



The rule is:



ACTION=="add", SUBSYSTEM=="usb", RUN+="/bin/sh -c 'xhost +local:pi; sudo -u pi xscreensaver-command -lock'"


This works quite well and the screen is blocked when I plug something into any of the USB ports.



But this isn't working when I already boot with the device plugged in. I expected to boot with the screen already locked.



What can I do to execute this rule at boot time? Is it possible?







boot usb udev






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 15 at 14:20









Bruno A

85




85











  • Try sudo udevadm control --reload-rules && udevadm trigger and if that works incorporate it into boot after appropriate sleep of 10 seconds or so.
    – WinEunuuchs2Unix
    Apr 3 at 0:46
















  • Try sudo udevadm control --reload-rules && udevadm trigger and if that works incorporate it into boot after appropriate sleep of 10 seconds or so.
    – WinEunuuchs2Unix
    Apr 3 at 0:46















Try sudo udevadm control --reload-rules && udevadm trigger and if that works incorporate it into boot after appropriate sleep of 10 seconds or so.
– WinEunuuchs2Unix
Apr 3 at 0:46




Try sudo udevadm control --reload-rules && udevadm trigger and if that works incorporate it into boot after appropriate sleep of 10 seconds or so.
– WinEunuuchs2Unix
Apr 3 at 0:46










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










X server starts late, so your script run in vain before it's up. It could be worthy to create a python script as daemon which watch for devices using pyudev.






share|improve this answer
















  • 1




    Thanks @user.dz, that was the answer. I used a Python script to do the task and it worked.
    – Bruno A
    Apr 3 at 10:41











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
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',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1015207%2fudev-rule-at-boot-time%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










X server starts late, so your script run in vain before it's up. It could be worthy to create a python script as daemon which watch for devices using pyudev.






share|improve this answer
















  • 1




    Thanks @user.dz, that was the answer. I used a Python script to do the task and it worked.
    – Bruno A
    Apr 3 at 10:41















up vote
0
down vote



accepted










X server starts late, so your script run in vain before it's up. It could be worthy to create a python script as daemon which watch for devices using pyudev.






share|improve this answer
















  • 1




    Thanks @user.dz, that was the answer. I used a Python script to do the task and it worked.
    – Bruno A
    Apr 3 at 10:41













up vote
0
down vote



accepted







up vote
0
down vote



accepted






X server starts late, so your script run in vain before it's up. It could be worthy to create a python script as daemon which watch for devices using pyudev.






share|improve this answer












X server starts late, so your script run in vain before it's up. It could be worthy to create a python script as daemon which watch for devices using pyudev.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 3 at 0:34









user.dz

33.7k1187168




33.7k1187168







  • 1




    Thanks @user.dz, that was the answer. I used a Python script to do the task and it worked.
    – Bruno A
    Apr 3 at 10:41













  • 1




    Thanks @user.dz, that was the answer. I used a Python script to do the task and it worked.
    – Bruno A
    Apr 3 at 10:41








1




1




Thanks @user.dz, that was the answer. I used a Python script to do the task and it worked.
– Bruno A
Apr 3 at 10:41





Thanks @user.dz, that was the answer. I used a Python script to do the task and it worked.
– Bruno A
Apr 3 at 10:41


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1015207%2fudev-rule-at-boot-time%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Which professions warranted travel in Medieval times?

How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

Trouble downloading packages list due to a “Hash sum mismatch” error