I'm been trying to get a rule to trigger when plugging in my camera(eos r) to further automate photo importing and the like, but I cant get the initial rule to trigger. I'm new to linux in general & am using Ubuntu 20.04.1 LTS.
lsusb yields this information
Bus 002 Device 003: ID 04a9:32da Canon, Inc. Canon Digital Camera
The rule /etc/udev/rules.d/91-camerabackup.rules
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="32da", RUN+="/home/thele/photo_backup.sh"
I've tried using chmod
chmod 0644 /etc/udev/rules.d/91-camerabackup.rules
I've tried various times to reboot or use udevadm control --reload-rules && udevadm trigger
The bash script resides in /home/thele/photo_backup.sh. Just executing bash /home/thele/photo_backup.sh
creates a folder.
echo "Do Folder Camera Stuff"
mkdir camshelltest
I assume that this is enough to test out whether the rule works. What else I am missing? Or is there any other way to approach this?
/home/thele/photo_backup.sh
have an appropriate shebang, and is it executable (i.e. can you run/home/thele/photo_backup.sh
without the explicitbash
command)?#!/bin/bash
to the top of the script and usedchmod +x photo_backup.sh
on it./home/thele/photo_backup.sh
runs without the explicit bash command, and creates a folder but the rule itself still does trigger when plugging the camera in again.mkdir camshelltest
will create a directory wherever the working directory of the rule is (likely the filesystem root,/
). Likewise, remember thatecho "Do Folder Camera Stuff"
won't have a terminal to echo the string to.mkdir $HOME/camshelltest
.