If you are running anything other than a console job you may run into trouble. Probably due to the dbus communication and no display. I just saw that you are wanting to run office so follow this instead.
I found this method a while back for popping up a notification when plugging in a USB. It requires creating three files.
1. A udev rule
2. A dbus workaround script
3. Your main script to run
File 1: /etc/udev/rules.d/98-usb-run.rules
Code: Select all
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd[a-z]1", ATTRS{model}=="silicon-power ", RUN+="/home/guest/runguest.sh 'Important community announcement' 'Somebody just stuck something in your port!'"
File 2: /usr/local/bin/dbus-workaround.sh
Code: Select all
#!/bin/sh
user=guest
pids=`pgrep nm-applet`
title=$1
text=$2
timeout=$3
icon=$4
xhost local:guest
export DISPLAY=:0.0
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
#icon hack:
if [ -z $icon ]; then
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
notify-send -u low -t $timeout "$title" "$text"
else
DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
notify-send -u low -t $timeout -i "$icon" "$title" "$text"
fi
done
File 3: /home/guest/runguest.sh
Code: Select all
sudo -u guest /usr/local/bin/dbus-workaround.sh "$1" "$2" 6000
Using this I get a popup message through notify-send when I plug in. Just replace the bit about running notify-send with your GUI and you are good to go.
Again, on a serious note. Be aware of the HUUUGE security implications here.