On Mon, 13 Apr 2015, David Wright wrote:

> [I'm hoping this isn't a duplicate post, but my first
> attempt was rejected by bendel.debian.org as forged.]
> 
> Quoting Patrick Bartek (nemomm...@gmail.com):
> > On Sun, 12 Apr 2015, bri...@aracnet.com wrote:
> > > i'll second the use of openbox.  i use it with fbpanel.
> > >
> > > i too believe that gnome just pulls in way too much "stuff".
> > >
> > > the most inconvenient thing about not using gnome is not having a
> way
> > > to handle USS mass storage devices.
> >
> > I wrote a generic udev rule for that.  Of course, there are also
> > mounting utilities that do the same thing.  But I opted for the
> > light-on-resources rule instead.
> 
> Care to share it?

Well, sort of . . .   The rule I'm running now is too specific to my
system to be of general use, but below is what I started with.  Found it
while researching how to write rules.  Don't have the author's name.
Sorry.

The rule mounts and unmounts flash drives -- just plug and unplug -- and
cards (any type using an external card or multi-card reader.  The
caveat is: you must plug the card in first, then plug the reader in.
Unmount by unplugging reader with the card still in it, then remove the
card. Doesn't work with internal multi-card readers.  Probably not with
single internal readers either.  For that you need a daemon like
udisks-daemon set to poll each card slot of the reader.  

Good luck.

B

================================ >8 ================================

# /etc/udev/rules.d/10-my-media-automount.rules
 

# start at sdb to ignore the system hard drive
KERNEL!="sd[b-z]*", GOTO="my_media_automount_end"
ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="my_media_automount_end"

# import some useful filesystem info as variables
IMPORT{program}="/sbin/blkid -o udev -p %N"
 
# get the label if present, otherwise assign one based on device/partition
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
 
# create the dir in /media and symlink it to /mnt
ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'"

# create a symbolic link to /media/{usb_folder} on desktop
ACTION=="add", RUN+="/bin/ln -s '/media/%E{dir_name}' 
'/home/aardvark/Desktop/%E{dir_name}'"
 
# global mount options
ACTION=="add", ENV{mount_options}="relatime"

# filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat)
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", 
ENV{mount_options}="$env{mount_options},gid=100,dmask=000,fmask=111,utf8"
 

# automount ntfs filesystems using ntfs-3g driver
ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o 
%E{mount_options} /dev/%k '/media/%E{dir_name}'"

# automount all other filesystems
ACTION=="add", ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o 
%E{mount_options} /dev/%k '/media/%E{dir_name}'"
 
# remove the symbolic link to ~/{usb_folder}
ACTION=="remove", RUN+="/bin/rm -f '/home/aardvark/Desktop/%E{dir_name}'"

# clean up after device removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l 
'/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'"
 
# exit
LABEL="my_media_automount_end"

#Note: Edit line 17 and 30 to reflect your Desktop path. In other words,
# change /home/aardvark/Desktop to/home/{your_user_name}/Desktop. The reason
# that I didn’t use a relative path is because there is a myth that such 
configs do not go well with relative paths.

====================================== >8 =============================

Here's a work-in-progress showing how polling works that fell by the
wayside. It will mount a CD or DVD, but not unmount it.  Hadn't gotten
to the unmounting part yet.

========================== >8 ================================

# /etc/udev/rules.d/12-trial-dvd-automount.rules

# udisks-daemon must be running and polling /dev/sr0 for this to work
 

# Consider only internal DVD sr0
KERNEL!="sr0", GOTO="end"
#ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="end"

# import some useful filesystem info as variables
IMPORT{program}="/sbin/blkid -o udev -p %N"
 
# Check FS type, get the label if present, otherwise assign one
ENV{ID_FS_TYPE}!="iso9660", GOTO="end"
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="optical-%k"
 
# create the dir in /media
#ACTION=="add"
RUN+="/bin/mkdir -p '/media/%E{dir_name}'"

# Mount CD/DVD
RUN+="/bin/mount -t iso9660 /dev/%k '/media/%E{dir_name}'"

# Exit Rule
LABEL="end"

========================== >8 =======================


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: https://lists.debian.org/20150413181004.4200c...@debian7.boseck208.net

Reply via email to