* can i use udev rules to send a dbus signal
@ 2010-12-08 7:58 shaoning
2010-12-08 15:04 ` Martin Pitt
0 siblings, 1 reply; 2+ messages in thread
From: shaoning @ 2010-12-08 7:58 UTC (permalink / raw)
To: linux-hotplug
hi all
I met a problem . Does anybody help me ?
I wrote a udeve rules for ntfs filesystem mount , and i want to using
dbus-send to send a dbus signal .But it seems it can not work . When I
debuge, i saw /var/log/message said it send ok. But , in fact , it can
not work. Does anybody know this issue?
PS: When exec udev rules, it should be root , and i am using a normal
user to debug and see result.
[fan@fc13 rules.d]$ cat 10-media-by-label-auto-mount.rules |grep -v ^#
KERNEL!="sd[b-z][0-9]", GOTO="media_by_label_auto_mount_end"
IMPORT{program}="/sbin/blkid -o udev -p %N"
ENV{dir_name}="usb-%k"
ENV{DISPLAY}=":0.0"
ACTION="add", ENV{ID_FS_TYPE}="ntfs",
ENV{mount_options}="relatime,utf8,gid\x100,umask\02", 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"
ACTION="remove", RUN+="/bin/umount -l /media/%E{dir_name}",
RUN+="/bin/rmdir /media/%E{dir_name}"
LABEL="media_by_label_auto_mount_end"
[fan@fc13 rules.d]$
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: can i use udev rules to send a dbus signal
2010-12-08 7:58 can i use udev rules to send a dbus signal shaoning
@ 2010-12-08 15:04 ` Martin Pitt
0 siblings, 0 replies; 2+ messages in thread
From: Martin Pitt @ 2010-12-08 15:04 UTC (permalink / raw)
To: linux-hotplug
Hello shaoning,
shaoning [2010-12-08 16:06 +0800]:
> ACTION="add", ENV{ID_FS_TYPE}="ntfs",
> ENV{mount_options}="relatime,utf8,gid\x100,umask\02", 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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-08 15:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08 7:58 can i use udev rules to send a dbus signal shaoning
2010-12-08 15:04 ` Martin Pitt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).