From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Pitt Date: Wed, 08 Dec 2010 15:04:36 +0000 Subject: Re: can i use udev rules to send a dbus signal Message-Id: <20101208150436.GH2431@piware.de> List-Id: References: <4CFF3C7A.4010608@gmail.com> In-Reply-To: <4CFF3C7A.4010608@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org Hello shaoning, shaoning [2010-12-08 16:06 +0800]: > ACTION="add", ENV{ID_FS_TYPE}="ntfs", > ENV{mount_options}="relatime,utf8,gid0,umask2", RUN+="/bin/mkdir > -p /media/%E{dir_name}", RUN+="/bin/mount -t ntfs-3g -o > $env{mount_options} /dev/%k /media/%E{dir_name}", > RUN+="/usr/bin/nautilus --no-desktop /media/%E{dir_name}", > RUN+="/bin/dbus-send --session --type=signal / > com.zhou.dbustest.sayhelloworld" This isn't going to work like this. udev rules are executed as root, so this tries to start nautilus and dbus-send as root, neither of which makes sense. root doesn't have a session d-bus running, so the dbus-send will just shout into the void. udev isn't meant to run stuff for users, that needs to happen in the user's session. It's possible to use su, read xauth cookies etc. to pick the first X.org session and run stuff there, but all these are horrible, horrible hacks. If you are already using GNOME components, what's wrong with using udisks and running nautilus as the automount daemon? If you can't do that in your setup, you could also use a lightweight automount daemon like [1]. Martin [1] http://www.piware.de/2010/09/simple-udisks-based-automount-daemon/ -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)