From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toni Mirabete i =?iso-8859-1?q?Ter=E9s?= Date: Wed, 21 Sep 2005 00:56:01 +0000 Subject: Re: When I plug my pendrive, script runs twice Message-Id: <200509210302.24218.amirabet@xtec.net> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Boundary-00=_gELMDOe/FXO8xAw" List-Id: References: <200509200352.56616.amirabet@xtec.net> In-Reply-To: <200509200352.56616.amirabet@xtec.net> To: linux-hotplug@vger.kernel.org --Boundary-00=_gELMDOe/FXO8xAw Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks for your help. My scripts had one error and run for usb device and usb interface, but I thought that it was cause of two events seen when I make udevmonitor (UEVENT and UDEV). I send you the files of the scripts, maybe that they interest anybody. They serve to show icons for the pendrive and connected scanners on the users desks with X sessions on the local machine. I know KDE can make this, but I prefer make this myself because I can control names and others things. Still there is an error on disconnecting the scanner. It does not work. It has to be an error in the file catix.rules. I will look if I can find it. Toni Mirabete A Dimarts, 20 de Setembre de 2005 14:55, Greg KH va escriure: > On Tue, Sep 20, 2005 at 02:26:52AM -0700, Greg KH wrote: > > On Tue, Sep 20, 2005 at 03:52:56AM +0200, Toni Mirabete i Ter?s wrote: > > > When I start udevmonitor, I see UEVENT and UDEV with the same device > > > inserted. > > > > Are you sure? It's probably the usb device, and then the usb interface > > being created, right? Care to post your actual events? > > Sorry, I was wrong here, the UEVENT and UDEV events are the same thing, > they aren't two different events, that's just a debugging tool to show > how udev is working. Thanks to Kay for pointing this out. > > greg k-h > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. > Download it for free - -and be entered to win a 42" plasma tv or your very > own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net > Linux-hotplug-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel --Boundary-00=_gELMDOe/FXO8xAw Content-Type: text/plain; charset="iso-8859-1"; name="catix.rules" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="catix.rules" # Regles per poder tenir dispositius usb situats a l'escriptori autom=E0tic= ament a la CATix=20 # Pendrive o mem=F2ria usb ACTION=3D"add" , KERNEL=3D"[us][bd][a-z]*", RUN+=3D"/etc/udev/scripts/catix= usb.sh %k add" ACTION=3D"remove" , KERNEL=3D"[us][bd][a-z]*", RUN+=3D"/etc/udev/scripts/ca= tixusb.sh %k remove" # Esc=E0nner ACTION=3D"add" , SYSFS{product}=3D=3D"*[Ss][Cc][Aa][Nn]*" , ENV{MY_REMOVE}= =3D"/etc/udev/scripts/catixusb.sh remove %b", RUN+=3D"/etc/udev/scripts/cat= ixescanner.sh add %b" ACTION=3D"remove" , ENV{MY_REMOVE}!=3D"", RUN+=3D"$env{MY_REMOVE}" #ACTION=3D"remove" , SYSFS{product}=3D=3D"*[Ss][Cc][Aa][Nn]*" , RUN+=3D"/et= c/udev/scripts/catixescanner.sh remove %b" # Aix=F2 tamb=E9 funciona i ho deixo per curi=F3s # ACTION=3D=3D"add", KERNEL=3D=3D"[us][bd][a-z]*", ENV{MY_REMOVE}=3D"/etc/u= dev/scripts/catixusb.sh %k remove", RUN+=3D"/etc/udev/scripts/catixusb.sh %= k add" # ACTION=3D=3D"remove", ENV{MY_REMOVE}!=3D"", RUN+=3D"$env{MY_REMOVE}" --Boundary-00=_gELMDOe/FXO8xAw Content-Type: application/x-shellscript; name="catixescanner.sh" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="catixescanner.sh" #!/bin/bash # # # CATix Actualitzaci=F3 dels escriptoris en afegir o treure un esc=E0nner u= tilitzant les regles catix.rules # (C)2005 Antoni Mirabete i Ter=E9s - InterIntra s.l. # Correu electr=F2nic: # Sota llic=E8ncia GPL 2.0 # # $1 cont=E9 el dispositiu afegit o tret # $2 =E9s add o remove segons el cas # Quins usuaris tenen oberta una interf=EDcie kde o gnome en aquesta m=E0qu= ina usuaris=3D"$(top -b -n 1 | grep "kdeinit" |cut -d " " -f 3) $(top -b -n 1 = | grep "gnome-session" |cut -d " " -f 3)" case $1 in add) if [ "$(cat /sys/devices/pci*/*/*/$2/product | grep -i "scan" )" ] ; then= =20 for usuari in $usuaris ; do echo "[Desktop Entry] Comment=3D Comment[ca]=3D Exec=3Dkooka GenericName=3D GenericName[ca]=3D Icon=3Dscanner MimeType=3D Name=3DEsc=E0nner Name[ca]=3DEsc=E0nner Path=3D StartupNotify=3Dtrue Terminal=3Dfalse TerminalOptions=3D Type=3DApplication X-DCOP-ServiceType=3D X-KDE-SubstituteUID=3Dfalse X-KDE-Username=3D" > /home/$usuari/Desktop/Kooka chown $usuari:$usuari /home/$usuari/Desktop/Kooka done sleep 1 for usuari in $usuaris ; do dcop --user $usuari kdesktop KDesktopIface rearrangeIcons done fi ;; remove) for usuari in $usuaris ; do if [ -f /home/$usuari/Desktop/Kooka ] ; then rm /home/$usuari/Desktop/K= ooka ; fi done sleep 1 for usuari in $usuaris ; do dcop --user $usuari kdesktop KDesktopIface rearrangeIcons done ;; esac exit 0 =20 --Boundary-00=_gELMDOe/FXO8xAw Content-Type: application/x-shellscript; name="catixusb.sh" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="catixusb.sh" #!/bin/bash # # # CATix Actualitzaci=F3 del fitxer /etc/fstab i dels escriptoris en afegir = o treure un dispositiu de mem=F2ria USB utilitzant directori /dev (udev) ut= ilitzant les regles catix.rules # (C)2005 Antoni Mirabete i Ter=E9s - InterIntra s.l. # Correu electr=F2nic: # Sota llic=E8ncia GPL 2.0 # # $1 cont=E9 el dispositiu afegit o tret # $2 =E9s add o remove segons el cas # Quins usuaris tenen oberta una interf=EDcie kde o gnome en aquesta m=E0qu= ina usuaris=3D"$(top -b -n 1 | grep "kdeinit" |cut -d " " -f 3) $(top -b -n 1 = | grep "gnome-session" |cut -d " " -f 3)" case $2 in add) if [ -d /sys/block/$1 ] && [ -z "$(ls -l /sys/block/$1 | grep $1)" ] ||= test ! -d /sys/block/$1 ; then=20 for usuari in $usuaris ; do echo "[Desktop Entry] Type=3DFSDevice Dev=3D/dev/$1 MountPoint=3D/mnt/$1 =46SType=3Dauto ReadOnly=3Dfalse Icon=3Dusbpendrive_mount UnmountIcon=3Dusbpendrive_unmount Name=3DPenDrive Partition [$1] Name[ca]=3DMem=F2ria USB [$1] Name[es]=3DPartici=F3n de memoria usb [$1] " > /home/$usuari/Desktop/$1 chown $usuari:$usuari /home/$usuari/Desktop/$1 done # L'usuari i grup ser=E0: uidgid=3D"uid=3D$usuari,gid=3D$usuari" # Creem el directori per muntar-lo si no existeix mkdir -p /mnt/$1 case "$(TIPUS=3D"$(blkid /dev/$1)" ; TIPUS=3D"${TIPUS##* TYPE=3D}" ; TI= PUS=3D"${TIPUS%% *}" ; echo $TIPUS )" in *ext3*) echo "/dev/$1 /mnt/$1 ext3 noauto,users,exec 0 = 0" >> /etc/fstab ;; *ext2*) echo "/dev/$1 /mnt/$1 ext2 noauto,users,exec 0 = 0" >> /etc/fstab ;; *reiserfs*) echo "/dev/$1 /mnt/$1 reiserfs noauto,users,exec 0 = 0" >> /etc/fstab ;; *jfs*) echo "/dev/$1 /mnt/$1 jfs noauto,users,exec 0 = 0" >> /etc/fstab ;; *xfs*) echo "/dev/$1 /mnt/$1 xfs noauto,users,exec 0 = 0" >> /etc/fstab ;; *msdos*) echo "/dev/$1 /mnt/$1 msdos noauto,users,exec,umask= =3D000,$uidgid 0 0" >> etc/fstab ;; *vfat*) echo "/dev/$1 /mnt/$1 vfat noauto,users,exec,umask= =3D000,$uidgid 0 0" >> /etc/fstab ;; *ntfs*) echo "/dev/$1 /mnt/$1 ntfs noauto,users,exec,umask= =3D000,$uidgid 0 0" >> /etc/fstab ;; esac sleep 1 for usuari in $usuaris ; do dcop --user $usuari kdesktop KDesktopIface rearrangeIcons done fi ;; remove) if [ -n "$(cat /etc/fstab | grep "$1")" ] ; then cat /etc/fstab | grep -v "$1" > /etc/fstab for usuari in $usuaris ; do if [ -f /home/$usuari/Desktop/$1 ] ; then rm /home/$usuari/Desktop/$1 = ; fi done sleep 1 for usuari in $usuaris ; do dcop --user $usuari kdesktop KDesktopIface rearrangeIcons done fi ;; esac exit 0 =20 --Boundary-00=_gELMDOe/FXO8xAw-- ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel