Re: Okay, I give up… how to connect my (Android) phone properly (MTP)?
Johnny Rosenberg
gurus.knugum at gmail.com
Tue Aug 4 13:57:30 UTC 2015
2015-08-04 15:34 GMT+02:00 Petter Adsen <petter at synth.no>:
> On Tue, 4 Aug 2015 15:08:22 +0200
> Johnny Rosenberg <gurus.knugum at gmail.com> wrote:
>
> > 2015-08-04 14:58 GMT+02:00 Petter Adsen <petter at synth.no>:
> >
> > > On Tue, 4 Aug 2015 14:33:09 +0200
> > > Johnny Rosenberg <gurus.knugum at gmail.com> wrote:
> > >
> > > > 2015-08-04 13:30 GMT+02:00 Petter Adsen <petter at synth.no>:
> > > > > I take this to mean that you replace DEVICE with the device node
> and
> > > > > LOCATION with where you want to mount it, but I might be wrong.
> > > > >
> > > >
> > > > Yes, that should be what it means, but it didn't work. The line I
> tried
> > > was:
> > > > gvfs-mount -d /dev/bus/usb/001/013 ${HOME}/Desktop/MyPhone
> > > > but it mounted it at the usual place without any kind of error
> message
> > > (the
> > > > few times it mounted it at all).
> > >
> > > OK, that is surprising. Bug, maybe? I really don't know, and the man
> > > page is exceptionally unhelpful. It doesn't seem possible to interact
> > > with gvfs file systems in a sane way, you are instructed to use
> > > gvfs-copy, gvfs-rm etc, so you might be out of luck here. Try to file a
> > > bug against gvfs-bin and see what the developers have to say. Either
> > > things do not work as expected, or the man page is at best misleading.
> > >
> > > Petter
> > >
> >
> > Or maybe the mtp thing makes things a bit crazy?
> >
> > You don't happen to know where I file such a bug report, do you?
>
> 'ubuntu-bug gvfs-bin'
>
Oh, that simple? I didn't know that!
>
> Alternatively, upstream. I would guess that is bugs.gnome.org or
> something similar. The homepage address from the package is:
>
> https://wiki.gnome.org/Projects/gvfs
>
> I do not know if Canonical has added any patches to gvfs, which is why
> I suggested Launchpad first, but upstream is probably a better place to
> get an actual answer that might tell you something.
>
Thanks for all that info. I'll file a bug one way or the other.
Anyway, here's my new workaround. There are still an issue with it, but at
least it works:
First the udev rule, placed in a file called
/etc/udev/rules.d/10-local.rules:
ATTR{product}=="Nexus 6", ATTR{serial}=="<SerialNumberOfMyPhone>",
SYMLINK+="Nexus_6", RUN+="/usr/local/bin/CreateLinkToPhone.sh"
Now the script, translated to English:
#!/bin/bash
# Create a link to the connected phone in the Media directory.
# Variables
————————————————————————————————————————————————————————————————————
# Calculate User and XDG_Runtime_Dir by searching for the phone.
Path="/run/user/"
XDG_Runtime_Dir=$(find "$Path" -maxdepth 1 -type d -regex "${Path}[0-9]+")
UserID=$(basename "${XDG_Runtime_Dir}")
User=$(getent passwd "${UserID}" | cut -d ':' -f1)
# Now just assign the right strings to all the other variables.
Media="/media/${User}"
LinkName="${Media}/${ID_MODEL}"
Target="${XDG_Runtime_Dir}/gvfs/mtp:host=%5Busb%3A${BUSNUM}%2C${DEVNUM}%5D"
LogFile="/var/log/CreateLinkToPhone"
# Main
—————————————————————————————————————————————————————————————————————————
[[ -L ${LinkName} ]] && rm -f "${LinkName}"
if [[ ${ACTION} == "add" ]]; then
ln -s "${Target}" "${LinkName}"
fi
# For the log file:
printf "%s\n Event: %s\n Link name: %s\n" \
"$(date +'%F %T')" \
"${ACTION^}" \
"${LinkName}" >> "${LogFile}"
printf "Target folder: %s\n User: %s (%s – %s)\n\n" \
"${Target}" \
$(getent passwd "${User}" | cut -d ':' -f 5 | cut -d ',' -f 1) \
"${UserID}" \
"${User}" >> "${LogFile}"
# End of script
————————————————————————————————————————————————————————————————
My log file currently looks like this (translated to English and replaced
some names and stuff), after a few times plugging and unplugging the phone:
2015-08-04 15:23:15
Event: Add
Link name: /media/MyUserName/Nexus_6
Target folder: /run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C015%5D
User: MyName (1000 – MyUserName)
2015-08-04 15:27:10
Event: Add
Link name: /media/MyUserName/Nexus_6
Target folder: /run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C016%5D
User: MyName (1000 – MyUserName)
2015-08-04 15:29:50
Event: Add
Link name: /media/MyUserName/Nexus_6
Target folder: /run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C017%5D
User: MyName (1000 – MyUserName)
2015-08-04 15:31:42
Event: Add
Link name: /media/MyUserName/Nexus_6
Target folder: /run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C018%5D
User: MyName (1000 – MyUserName)
Now I just wonder why the script doesn't run when I unplug the phone.
Shouldn't it? If not, what is the ACTION environment variable for if the
value is always ”add”…?
> Petter
>
> --
> "I'm ionized"
> "Are you sure?"
> "I'm positive."
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20150804/34f1d02f/attachment.html>
More information about the ubuntu-users
mailing list