0

Hi I wanted to write a script that ran whenever any device was plugged in. If found How to detect an USB device? for usb ports. And How can I run a script when the power supply is plugged-in or -out? for powersupply, for powersupply however only featured if it was plugged in and then contounsly preformed an action. I need a script to run once whenever something is plugged in. Is there anyway to do this?

Jip Helsen
  • 101
  • 2
  • Watch `sudo journalctl --follow` as you connect your devices. There's a system, called `udev` that notices when device events happen. Read `man udev`, and `man -k udev`. – waltinator Jul 30 '23 at 22:53
  • @waltinator thx! If you where to write an answer with an example script, I will approve and upvote. If not thx for the usefull tip! – Jip Helsen Jul 31 '23 at 07:14
  • Sorry, writing `udev` rules (not scripts) for a remote system, with unknown hardware, is not something that's easy. I won't. It's up to you to learn about `udev`, look at `udev` on your system, search for `udev` tutorials on the web, ... Don't fall victim to UTBLT! (Using Tool Before Learning Tool). – waltinator Jul 31 '23 at 15:13
  • Yeah thx, true that. It is easy to falling in to thinking learning something is just a trivial step in accomplishing your goal. I will have a look at it when I have the time, but in retrospective do not need to check all the inputs, yielding this question rather useless. But thx some great dev wisdom I all to often forget :)! – Jip Helsen Jul 31 '23 at 15:18

0 Answers0