Hello,
I've created an udev-rule
Code:
SUBSYSTEMS=="usb", KERNEL=="sd?1", SYMLINK+="usbstick", RUN+="/usr/local/bin/mount-usb.sh
which executes the following script:
Code:
#!/bin/bash
# USB-Stick mounten
device=`dmesg | tail -n 15 | grep -e sd.: | sed -n 's/.*sd.:\s\+\?\(.*\)/\1/i p'`
name=`dmesg | tail -n 15 | grep -i product: | 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
notify-send "USB-Speicherstick eingehängt auf /media/$name"
but the "notify-send" command only works when I execute the script manually as root. Why?
Also it seems that the script is too complicated. Is there another way to get the name of the device-node and the product-name of the device?
I want to unmount the device as a normal user. How can I do this?
Also I want to delete the directory in /media after unmounting the device, how can I do this? I consider to write a script which cleans /media when the system starts.
How did you solve this issues?
BTW: I don't use KDE or XFCE.
Markus