Okay, I give up… how to connect my (Android) phone properly (MTP)?

Petter Adsen petter at synth.no
Mon Aug 3 09:20:54 UTC 2015


On Mon, 3 Aug 2015 11:05:44 +0200
Johnny Rosenberg <gurus.knugum at gmail.com> wrote:

> 2015-08-03 9:08 GMT+02:00 Petter Adsen <petter at synth.no>:
> 
> > On Sun, 2 Aug 2015 18:36:31 +0200
> > Johnny Rosenberg <gurus.knugum at gmail.com> wrote:
> > > So I did my own workaround. Now, since I'm not very good at this, I would
> > > just ask here to see if anybody have a better idea or if anyone can tell
> > me
> > > why I shouldn't do this and what I should do instead.
> > >
> > > So what I did, was a Bash script that looks for the phone every ten
> > > seconds. If it is found, a soft link to it is created at ${HOME}, called
> > ”
> > > Nexus” (yes, this script only works with Nexus phones and only for one
> > at a
> > > time, which is okay with me but maybe not so okay with others).
> >
> > The only idea I can come up with is to write a udev rule to mount the
> > phone (or create the link) when it is connected. Better than running
> > the script every ten seconds.
> >
> 
> Yes, that sounds a lot better, thank you!
> I'll do some searching and try to learn how to do that. If you have any
> handy links for this, I'll be grateful.
> 

Take a look at this:

http://askubuntu.com/questions/638452/udev-rule-is-executed-twice-because-android-smartphone-is-mounted-2-times

It's not exactly what you want, but browsing through it, it seems it
should give you enough of the info you need to achieve what you want if
you also read the answers. I've recently been playing with udev myself,
so I can probably dig up a few more generic links if you need them.

Use 'udevadm monitor' to get the codes you will need, and then get udev
to mount the phone when it sees the specific code you want.

A WARNING, though: do not run a script from udev that takes longer than
10 seconds to execute. AFAIK, there is a timeout there to prevent
scripts from hanging.

> By the way, my script runs perfectly now and it shows 0% CPU and 240 KiB
> memory, but I think your idea is better anyway. I'm just happy that I made
> something that actually works… :P

:-)

Good luck,

Petter

-- 
"I'm ionized"
"Are you sure?"
"I'm positive."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20150803/65147d66/attachment.sig>


More information about the ubuntu-users mailing list