- Code: Select all
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{serial}=="5743415A4131323437343733", RUN+="/home/emil/.exhddbakcup.sh"
The backup script is quite simple:
- Code: Select all
#!/bin/bash
{
touch /home/emil/thisworks.txt
su emil alt-notify-send "Backup message" "USB Backup device detected"
sleep 150
R=$(cat /home/emil/.backupperform)
if [ "$R" = "1" ]; then
su emil alt-notify-send "Backup Message" "It has been a while since the last backup, beginning backup."
nice -n 17 ionice -c2 -n6 /usr/bin/backintime --backup-job >/dev/null 2>&1
echo '0' > /home/emil/.backupperfom
su emil alt-notify-send "Backup Message" "Your backup has completed"
fi
} &
alt-notify-send is a script which i found on the internet, and it basically allows to send message to other users through notify, here is the code:
- Code: Select all
#!/bin/sh
user=`whoami`
pids=`pgrep -u $user gnome-panel`
title=$1
text=$2
timeout=$3
if [ -z "$title" ]; then
echo You need to give me a title >&2
exit 1
fi
if [ -z "$text" ]; then
text=$title
fi
if [ -z "$timeout" ]; then
timeout=60000
fi
for pid in $pids; do
# find DBUS session bus for this session
DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS \
/proc/$pid/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//'`
# use it
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
notify-send "$title" "$text"
done
After a few hours of debugging I couldn´t get this to work. If I execute the script from terminal everything is fine. When I look at udevadm it show that the script has been execute, but I neither see any message nor the file thisworks.txt is created.
Do you have some ideas?


