I have written the following simple scripts that will mount and unmount a MTP device connected via USB after installing the appropriate pet package that Tempestuous posted above.
I use custom actions in Thunar to setup right click menu entries that will mount the device or unmount the device. After mounting the script takes me right to the directory that the device is mounted to. Also I changed the directory to /mnt/MTPdevice (just my preference. If you like /root/MTP better you can change that easily in the script.
Read the comments for instructions.
Mount Script
Code: Select all
#!/bin/bash
# Put this script in the /root/my-applications/bin directory and make it executable
# Change to mnt directory
cd /mnt
# Mount any detectable MTP device at /mnt/MTPdevice
go-mtpfs "MTPdevice" &
# Start your favorite file manager in the directory where the MTP device is mounted. You can comment out this line if you would rather navigate to this directory in the file manager window that is already open.
thunar /mnt/MTPdevice
# If you use Thunar for file management you can configure a custom action (Edit->Configure Custom Actions) for a right click menu option on the /mnt/MTPdevice directory that will issue the command fusermount -u MTPdevice. This will give you a convenient right click option to unmount your device prior to disconnecting it from USB. I haven't used ROX in quite a long time, but there is likely a similar option for ROX users.
# Just an aside, if you do not have an MTP device connected when you call this script the file manager you called above will simply open with nothing mounted at the /mnt/MTPdevice directory. If you later connect an MTP device simply run this script again.
# I only have one MTP device and don't know what this would do if two or more were connected via USB when the script is executed.
Unmount Script
Code: Select all
#!/bin/bash
# Put this script in the /root/my-applications/bin directory and make it executable
# changes directory to the mount point for the MTP device
cd /mnt
# unmounts the MTP device
fusermount -u MTPdevice
# In Thunar make a custom right click action that will execute this script, so that you can unmount your MTP device at any time from the right click menu in Thunar.
# Edit->Configure Custom Actions THen on the command line enter this script unmountMTP.sh it should find it if you have it in the /root/my-applications/bin directory.
# A similar setup should be available in other filemanager such as ROX, though I don't use them, so I cannot advise on how to set them up.
If anybody has more than one MTP device I would love to know how this setup handles a situation where more than one MTP device is connected via USB when the script is run. Please test and report your results here. If anybody using ROX or other file managers can provide helpful hints for running these scripts from a right click menu within a file manager other than Thunar or some other quick and easy (gui) way of starting the scripts I am sure that would help many folks out, as well. I realize most Puppy users probably are not using Thunar.
I experimented with running the script prior to launching the filemanager, and this also worked, but I couldn't figure out how to get the file manager to open in a directory other than /mnt (or whatever the parent directory to the directory that the MTP device is mounted to, in my case /mnt). That would have been my preference over starting the script from a right click menu in the filemanager, but I couldn't live with the file manager always opening to /mnt even if I click a drive icon for the CD drive for example. Obviously I could set it to use thunar /mnt/sr0, but then it would always open to the directory. I could pass in a variable easily enough and use the variable to set the directory to open thunar to, but I couldn't figure out how to get the appropriate variable to pass into the script. Bottom line here is that I am obviously not quite satisfied with this solution, so there might be some improvements in the future, if somebody doesn't get to it before me.
**EDIT**
I borrowed a second Nexus 7 from my wife (no easy task prying it from her fingers mind you), then connected both MTP devices to USB ports and ran the scripts to mount them using gomtpfs. The results were kind of unpredictable. Neither device mounted to the mount point and the Pup Camera application kept popping up despite the fact the both devices were still clearly set to use MTP rather than PTP. No matter what I tried neither device would mount until the other was disconnected from the USB port. So I think that is a limitation of the gomtpfs library. The gomtpfs library is still more stable than libmtp, which I have tried in a couple of other distros. It didn't seem to matter if I was using Arch, Lubuntu or whatever, when using libmtp to mount my Nexus 7, I ran into occasional permission denied errors when trying to transfer files to or from the device, regardless of whether or not I had the appropriate permissions. It seemed a bit random when I would get the errors, but it didn't seem to matter which distro I used. It did however, work most of the time and sometimes I could try transferring the same file later and it would work fine. I don't have this issue with gomtpfs, so I am more than happy to have the limitation of only being able to mount one MTP device at a time.