:: Re: [DNG] gvfs depends on libsystem…
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Steve Litt
Date:  
À: dng
Sujet: Re: [DNG] gvfs depends on libsystemd0
On Sun, 9 Apr 2017 22:39:28 +0000
Daniel Abrecht <dng@???> wrote:

> On 04/09/2017 08:01 PM, Steve Litt wrote:
> > On Sun, 09 Apr 2017 08:24:15 +0200
> > Joachim Fahrner <jf@???> wrote:
> >> without gvfs PCmanFM does not mount external usb drives
> >
> > Somewhere back in the archives I submitted a shellscript to
> > automatically mount thumb drives without a file manager.
>
> I think automatically mounting thumb drives is very different from
> mounting them when I klick on them in my file manager. Things like
> automatically mounting removable medias or even auto starting
> applications, I don't want that. What if I want to rescue a faulty
> thumb drives for example, automatically mounting it would could
> damage it even further. I think that Linux doesn't do or change things
> on it's own like Windows used to be a big strength of it.
>
> Daniel Abrecht


Mounting them only on user demand would be even easier. Here's my
choosethumb.sh, which assists me to ask to mount a thumb drive:


=====================================================================

#!/bin/sh

# Copyright (C) 2017 by Steve Litt
# Licensed with the Expat license:
# http://directory.fsf.org/wiki/License:Expat

mountsfile=/tmp/mounts.tmp
mountdir=$HOME/media

usage(){
echo
echo 'USAGE: choosethumb.sh [-m|-u]'
echo ' for mount and umount respectively'
echo ' must have sudo rights to mount/umount'
echo
exit 9
}

listdevs(){
readlink /dev/disk/by-id/*-part* | \
awk -F/ '{print $NF}' | sort -u
}

listthumbs(){
readlink /dev/disk/by-id/usb-*:?-part* | \
awk -F/ '{print $NF}' | sort -u
}

handledevs(){
  while read thisdev; do
    if grep $thisdev $mountsfile > /dev/null; then
      echo `grep $thisdev $mountsfile`
    else
      echo $thisdev '   unmounted'
    fi
  done
}


orgdir=`pwd`
cd $HOME

mount | grep ^/dev/sd | \
sed -e 's+^/dev/++' -e 's+type.*++' > \
$mountsfile


if test "$#" != "1"; then
  usage
elif test "$1" = "-m"; then
  mychoice=`listthumbs  | handledevs | sort -u | \
    dmenu -l 20 -fn 10x20`
  resultt=$?
  myfcn=m
elif test "$1" = "-u"; then
  mychoice=`listthumbs  | handledevs | \
    grep -v "unmounted" | sort -u | \
    dmenu -l 20 -fn 10x20`
  resultt=$?
  myfcn=u
else
  usage
fi


if test "$resultt" = "0"; then
  trimchoice=`echo $mychoice | cut -f 1 -d " "`
  if test "$myfcn" = "m"; then
    mkdir -p $mountdir/$trimchoice
    if sudo mount /dev/$trimchoice $mountdir/$trimchoice; then
      echo "Mounted /dev/$trimchoice on $mountdir/$trimchoice"
    else
      echo "Mount FAILED: /dev/$trimchoice on "
      echo "$mountdir/$trimchoice"
      exit 2
    fi
  elif test "$myfcn" = "u"; then
    if sudo umount /dev/$trimchoice; then
      echo -n "UnMounted /dev/$trimchoice away "
      echo "from $mountdir/$trimchoice"
    else
      echo "Failed to unmount /dev/$trimchoice"
      echo "Check what is using it and try again."
      exit 3
    fi
  else
    echo "Internal argument error, call programmer, aborting."
    exit 5
  fi
else
  if test "$myfcn" = "m"; then
    echo 'User declined to mount.'
  else
    echo 'User declined to unmount.'
  fi
  exit 1
fi
cd $ORGDIR
exit 0



=====================================================================

Modify to suit your taste.

SteveT

Steve Litt 
April 2017 featured book: Troubleshooting Techniques
     of the Successful Technologist
http://www.troubleshooters.com/techniques