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

Nils Kassube kassube at gmx.net
Fri Aug 7 12:06:51 UTC 2015


Johnny Rosenberg wrote:
> 2015-08-07 10:43 GMT+02:00 Nils Kassube <kassube at gmx.net>:
> > Johnny Rosenberg wrote:
> > > My script has another bug that will happen if there is more than
> > > one
> > > folder in ”/run/user”. That can happen and it happened when I
> > > switched user to my wife's account. For a moment there was a
> > > directory called ”112”, which is ”lightdm” and it messed up my log
> > > file a bit.
> > 
> > An easy way to find the (hopefully) correct path would be to use
> > "/run/user/$UID". As I understand it, your final path should be
> > "/run/user/$UID/gvfs/mtp:host=%5Busb%3A001%2C011%5D". If you even
> > want to avoid the $UID, you could even use
> > "/run/user/*/gvfs/mtp:host=%5Busb%3A001%2C011%5D".
> 
> No, the script is run from the system, so there is no UID or any
> environment variables at all except those related to Udev.

Silly me - of course there is no useful UID for a script run by udev. 
Thinking about it, you may have a problem if there are several users 
active at the same time. Then there should be several directories in 
/run/user and I don't think you have a way to decide for which user you 
should make the device available.

> The ”/run/user/*/gvfs…” thing is however something that I didn't think
> of. I'll experiment a bit with it.

Hmm, I think that idea wasn't useful either. After all the path does not 
yet exist, so the wildcard doesn't help here.


Nils





More information about the ubuntu-users mailing list