Run custom scripts upon USB device plug-in

Technical issues/questions of an intermediate or advanced nature.
Testuser
Samurai
Samurai
Posts: 137
Joined: 26 May 2021, 15:11
Distribution: Porteus-v5.0-64-LXDE

Run custom scripts upon USB device plug-in

Post#1 by Testuser » 29 Sep 2022, 20:26

Hi :)

How can i run a script when I plug any USB device.

Since I am using LXDE, mount and unmouting does not show notification like in Caja filemanager of MATE.

Added a rule in /etc/udev/rules.d/custom.rule like

ACTION=="add", KERNEL=="sd?", SUBSYSTEMS=="usb", RUN+="/bin/sh -c /usr/share/mx-usb-unmounter"


But below URL says this will not work since udev is creating this process.

https://askdev.io/questions/248884/how- ... ce-plug-in

It can work with "at now" command and how to install it in porteus.

thanks :)

Testuser
Samurai
Samurai
Posts: 137
Joined: 26 May 2021, 15:11
Distribution: Porteus-v5.0-64-LXDE

Run custom scripts upon USB device plug-in

Post#2 by Testuser » 10 Oct 2022, 18:36

Found the way we have to add -u guest and DISPLAY=:0

ACTION=="remove", ENV{ID_PART_TABLE_TYPE}!="", ENV{DEVTYPE}=="partition", RUN+="/usr/bin/sudo -u guest DISPLAY=:0 /usr/bin/Usb-Poweroff.sh"
:celebrate3:

Post Reply