Hello together,
I'm lost with this issue. Referring to
this thread I've written an udev-rule which recognizes the plugin of an USB-memory-stick and calls a script which mounts the device. So far so good.
Here's the script:
Code:
#!/bin/bash
# USB-Stick mounten
sleep 5
device=`dmesg | grep -e sd.: | tail -n 1 | sed -n 's/.*sd.:\s\+\?\(.*\)/\1/i p'`
name=`dmesg | grep -i product: | tail -n 1 | sed -n 's/.*product:\s\+\(.*\)/\1/i p' | sed -n 's/\ /_/g p'`
if [ ! -d /media/$name ]; then
mkdir /media/$name
fi
mount /dev/$device /media/$name
#for LINE in $(find /proc/ -maxdepth 2 -name environ -exec grep -z "^DBUS_SESSION_BUS_ADDRESS" {} \; | sort -uz | tr '\0' '\n')
#do
# eval $LINE
#done
#username=`who | head -n 1 | cut -d " " -f 1`
#su $username -c notify-send "USB-Speicherstick eingehängt auf /media/$name"
echo "USB-Speicherstick eingehaengt auf /media/$name" | wall
Additionally I want to receive a message about
where the device is mounted.
I've tried the "notify-send" command which works when I call the script on the commandline (as root as well as a normal user). The problem is that the message is not shown when the script is called from udev. I searched the internet and found that the problem is with dbus. What I have understood is that the script, when called from udev
doesn't know where to display the message. The reason is that the script needs additional information about a (some?) variables from dbus. There are solutions explained in several places in the internet, but I did not understand one of them.
Does anyone know which variable (information from dbus) the notify-send command needs
and which way I can provide this information to the command. There's no manpage vor notify-send and the helptext for the command doesn't provide as much information. As you can see in the script I've tried out various ideas. using "su -c username" doesn't work, and I did not understand what to do with DBUS_SESSION_BUS_ADDRESS.
I've also found udev-notify at slackbuilds.org, but could not find out if an how this tool could help me.
Markus