udev rule at boot time

Clash Royale CLAN TAG#URR8PPP up vote
1
down vote
favorite
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
add a comment |Â
up vote
1
down vote
favorite
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
Trysudo udevadm control --reload-rules && udevadm triggerand if that works incorporate it into boot after appropriate sleep of 10 seconds or so.
â WinEunuuchs2Unix
Apr 3 at 0:46
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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
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
boot usb udev
asked Mar 15 at 14:20
Bruno A
85
85
Trysudo udevadm control --reload-rules && udevadm triggerand if that works incorporate it into boot after appropriate sleep of 10 seconds or so.
â WinEunuuchs2Unix
Apr 3 at 0:46
add a comment |Â
Trysudo udevadm control --reload-rules && udevadm triggerand 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
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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.
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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
Try
sudo udevadm control --reload-rules && udevadm triggerand if that works incorporate it into boot after appropriate sleep of 10 seconds or so.â WinEunuuchs2Unix
Apr 3 at 0:46