1

I have a file .xscreensaver & the code/script as below

sudo cp -R .xscreensaver /home/amg/

How can I make the code/script autorun when I insert a USB?

adrian
  • 27
  • 1
    Making anything autorun from external media is a very bad idea. That's why even in Windows such feature was disabled many years ago. – ChanganAuto Oct 05 '22 at 03:15
  • 1
    You've provided no OS/product/release details; as having scripts auto-run can vary on desktop/release being used as many DE/setups disable it by default for security reasons. eg. I have Ubuntu setups here that don't even mount a USB by default on insertion, so expecting them to autorun before a mount is performed makes no sense. – guiverc Oct 05 '22 at 03:16
  • See this answer. Just understand that doing so can cause security issues if you ever insert a USB that contains malicious code. Also, in addition to the instructions, you may need to go to your file manager preferences and disable the option to "ask before running" to get rid of the popup prompt. – mchid Oct 05 '22 at 04:29
  • In the comments, they mention that on Linux Mint, the option is under "file management preferences" (whatever that is) but I believe they may be talking about how nautilus has an option to "ask before running" or something similar. Please let us know if the answer doesn't work and why. – mchid Oct 05 '22 at 04:35
  • 1
    There's also this similar question. In this scenario, the command or the code is executed when a certain USB device is inserted. The code that is executed is not on the device but you tell Ubuntu to execute the code automatically when a specified device is inserted. – mchid Oct 05 '22 at 04:44
  • So you would need to specify the vendor id and the product id of your specific USB device (you can obtain that when the device is plugged in and you run lsusb). Then, when you insert the particular USB device, Ubuntu will recognize it and this will trigger a script on your Ubuntu computer to run. Just ignore the "out" or unplug portion of the answer. – mchid Oct 05 '22 at 04:50
  • @mchid I think that the second question you link to ("this similar question") is more in line with OP's needs than the first, so I'll vote to close as duplicate ot that one. It has an excellent answer. – Jos Oct 05 '22 at 08:42

0 Answers0