Forum › Forums › General › Tips and Tricks › GUI to mount and unmount android devices
- This topic has 44 replies, 9 voices, and was last updated May 27-12:58 pm by PPC.
-
AuthorPosts
-
May 16, 2020 at 8:35 am #35987Forum Admin
SamK
::A few random musings in no particular order.
…users can unmount the android device as they would any other drive…
If the user is not presented with a simple way to unmount the ‘phone, there is an increased risk of just unplugging the cable. That leaves antiX with an unclean mountpoint. In that condition the ‘phone cannot be mounted again until the previous mount is cleared correctly. Not all file managers can handle unmounting mounts done by jmtpfs straight out of the box e.g. SpaceFM can, ROX-Filer and Midnight Commander cannot.
I never thought the mount point folder would bloat the user’s Home…
Only to a minor degree. Because it is used only when the ‘phone is connected I thought it polite to create it on on demand and remove it when unmounting. Not a requirement just user friendly.
…easily inserted on the toolbar (using IceWM’s Toolbar Icon Manager)…
If this is intended to be the primary way of launching it effectively makes it useful only in IceWM. Consider making the primary way being available in all window managers to widen appeal by having a common way in them all.
I also never thought of checking if the android device is pre MTP…
There might be little point in doing this now ‘phones that do not support MTP are handled OK in antiX-19. Time passes and the number of those ‘phones get fewer each year. It might be worth saying the script works with antiX-19 and greater.
It partly uses SpaceFM to display the main warning…
This seems to indicate a dependency on SpaceFM, even if it is not the default file manager. There is probably better value to be obtained by making it totally independent of all file managers.
May 19, 2020 at 2:36 am #36081MemberPPC
::Hi,
There’s the link to the last version of the script. It now automatically tries to mount android devices, if there is a mounted android device, it tries to unmount it.
@ Thanks for all the input!
-I tried to use SpaceFM to display the menus/warnings because, in certain aspects, its easier and much more intuitive to use than YAD (that I used for the GUI’s for all my previous scripts). Since SpaceFM already comes, out of the box with the full antiX version, I thought it would be cool to use it. But you are right, it’s an extra dependency. I solved that and the script now only uses YAD (uglier looking ‘windows’).
-I also agree with what you said about about pre-MTP devices, no need to complicate my script with that…
– about my comment on adding the script’s icon to IceWM’s toolbar- that was a side remark, something that users could do if why want to, the main point is having a .desktop file for the script, so it shows up on the menus of all desktops! Users can then do with it what they want- for example – put a link to it on the desktop for convenient access…
– Now about the, in my opinion, more relevant situations:
– Unmounting the android device – my first stab at the script did include a main window with both a mount and an unmount buttons- but it was an extra step, when trying to access my device, so I went with Moddit’s opinion and got rid of it. To be honest was also something that I didn’t use because my default file manager is SpaceFM and it’s faster to select the mount point on the top left of it’s window and click “unmount” ( I don’t use ROX, I have no idea how to unmount it there).
I took an alternative approach to the mount and unmount process- the user runs the script. If an android device is found and seems mounted, try to unmount it. If an android device is found but not mounted, try to mount it… Easy and fast!
– this connects to the mount point on the home folder… If there’s need, I’ll gladly add a command to the “unmounter” to also the delete mount point folder part…To do / call for collaboration/help :
– Do a loop when searching for android devices, so users don’t have to close the script, plug the android device and then re-run the script… (I don’t need this my self, but would make the script more usable and professional looking)
I tried bash “do done” loops, they work, but then, I don’t know why, the script fails, not mounting correctly the android device – I gave up on understanding why…
I also tried using a “function” for the “search android devices” initial part of the script. It’s the most elegant solution. Basically the function re-runs itself when the user presses “Retry”. Once again, when a device is detects, I have the same problem as above… It’s a bit too much for my meek bashing/ googling skillsP.
May 19, 2020 at 5:51 am #36094Member
sybok
::Hi,
I ran a quick ‘shellcheck’ of the script.
No obvious error found, only minor improvements suggested.
I have few suggestions to slightly improve it but do not know how to get them to you.
I have it already written but do not know where/how to post it without the need of registering.
Any suggestions?May 19, 2020 at 5:56 am #36095Forum Admin
rokytnji
::Any suggestions?
pastebin
Just post the link it gives you to your guest text file in your next post.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsMay 19, 2020 at 6:35 am #36097Member
sybok
::Pastebin: Oh, it’s that simple! Did not use it before.
Here it is:
https://pastebin.com/Kx86sSJvJust collecting all occurences of ‘./*.txt’ files into global variables (better coding practice), clearing them via ‘:>’ instead of removing and syntactic sugar on top of that.
COMMENT:
I have missed to include the ‘mount_display’ function into ‘main’. 🙁- This reply was modified 2 years, 11 months ago by sybok. Reason: Comment on code error in pastebin link
May 19, 2020 at 6:55 am #36099Member
sybok
::With the split into functions, the code may be easier to read.
The code in the search for device loop could be in the ‘main’ functionnot_connected=true ... main(){ <create directory, clear files, some other stuff> check_mounted while "$not_connected"; do check_connected # This function must newly change the global variable '$not_connected' to 'false' if device found sleep <reasonable sleep time> done <mount, check, other stuff> } # mainNot sure why did the previous attempts fail and whether this is destined to do the same (I have no android device to test it with).
Does not handle multiple devices, though (probably using sub-folders in the directory ‘$dir’ and storing device ‘/dev/sd*’ and sub-folder in a BASH array).
- This reply was modified 2 years, 11 months ago by sybok.
- This reply was modified 2 years, 11 months ago by sybok. Reason: Commenting on the previous loop attempts
May 19, 2020 at 8:24 am #36103MemberPPC
::@sybok- the script, split into functions looks much better, thanks, mate!
Also, I toyed with the idea of using a function to recheck if an android device USB cable was plugged in, without success. Basically the ” android device not detected” screen had 2 buttons, something like “Exit” and ” Retry”…
when I’m at home I may try to patch that into your perfectly organized script and see if it works now (since I had no idea why it didn’t work before…)
If you can, please, solve the little problem from your original pastebin, and also, don forget to credit to yourself for adapting the script, ok?
Ideally if your idea to recheck for plugged in devices pans out, put that in, also!!!… and it’s 100% done!The script’s interface still looks a bit crude (I usually take care of that after the really important stuff is fully done), but almost 100% of the functionality to easily access (by that I mean, for newbies, just point and click) an android device on antiX is already available…
Since it’s just about 2 kb, maybe anticapitalista may want to throw that into the next antix-goodies update ( with a desktop file so it comes up in the menus)… I can already see the outrage, about antiX getting too bloated out of the box… I’m not really aware if there are that many users that need to connect their android devices to their computers, since probably most people are using cloud services for that…
But, hey, antiX is all about allowing people with even older hardware make the most of it, even if they don’t have access to wi-fi or broadband… And basically our phones are now our photographic cameras, video cameras and even reading devices, so it’s probably nice to have a easy way to sync and back up everything up.P.
May 19, 2020 at 9:22 am #36105Member
sybok
::Hi,
small update available at https://pastebin.com/vb1EDMke
It includes the while-loop checking for devices that can be mounted.
Search for ‘TODO’ in the code for incomplete things.
There is still a room for improvement.PS: In case I do not respond, please send me private message if anything needed from me (will be on leave next week and need to finish some work prior to that).
May 19, 2020 at 9:39 am #36106MemberPPC
::@sybok:
I have a (as always, ugly) fix for the errors that come up when trying to check for yad and jmtpfs: something along this lines:if ! [ -x "$(command -v yad)" ]; then echo 'Error: command is not available' >&2 else echo 'command available' fi ## testing - jmtpfs if ! [ -x "$(command -v jmtpfs)" ]; then echo 'Error: command is not available' >&2 else echo 'command available' fiLater I’ll try to work on the loop for trying to detect a plugged in device…
As is, the script is fully usable!!! But yeah, there«s always room for improvement!EDIT: OK, I simply added 2, more elegant lines, to your original script, to check for yad and jmtpfs:
## testing - yad [[ -x "$(command -v yad)" ]] && exit 1 ## testing - jmtpfs [[ -x "$(command -v jmtpfs)" ]] && exit 1EDIT 2: Oops! while testing, I found a bug. At least when using Spacefm, the script always opens 2 tabs, showing the mount point! I still have not catched what causes this…
EDIT 3: Got it!: It was a bug in the final check!: Is should read like this (the yad part and all that come after that should remain unchanged”:
#recheck if device contents are displayed, if not, warn user and exit and unmount device to avoid errors sleep 1 && echo " last check if device can be mounted. If not, unmount it to avoid any errors" if [ "$(ls -A "$dir")" ] ; then echo Device seens properly mounted else echo "Please check if you have ALLOW access to your files, in your android device,\n in order to procced!" && yad ...P.
- This reply was modified 2 years, 11 months ago by PPC.
- This reply was modified 2 years, 11 months ago by PPC.
- This reply was modified 2 years, 11 months ago by PPC.
May 19, 2020 at 1:20 pm #36113Forum Admin
rokytnji
::Created a directory called Phone in my home directory
just installed jmtpfs and added to personal menu and a button to the menubar, command as below. mounts diverse phones and tablets.
prog “MountPhone” /usr/share/icons/papirus-antix/48×48/devices/pda.png jmtpfs /home/”myusrname”/Phone
Seems less effort to me
Not looking good here
harry@biker:~ $ cd Phone harry@biker:~/Phone $ ls -l ls: cannot open directory '.': Input/output error harry@biker:~/Phone $ cd harry@biker:~ $ ls -l ls: cannot access 'Phone': Input/output error total 48 drwxr-xr-x 9 harry harry 4096 Jan 30 2017 Claws_Themes drwxr-xr-x 2 harry harry 4096 Oct 30 2019 Desktop drwxr-xr-x 8 harry harry 4096 Feb 28 16:25 Documents drwxr-xr-x 2 harry harry 4096 May 17 09:28 Downloads drwxr-xr-x 5 harry harry 4096 Apr 14 15:16 Games drwxr-xr-x 2 harry harry 4096 Oct 29 2019 Live-usb-storage drwx------ 5 harry harry 4096 Feb 4 10:14 mozilla.bk drwxr-xr-x 2 harry harry 4096 Oct 30 2019 Music d????????? ? ? ? ? ? Phone drwxr-xr-x 9 harry harry 4096 May 17 10:08 Pictures drwxr-xr-x 2 harry harry 4096 May 1 09:13 Public drwxr-xr-x 2 harry harry 4096 May 16 09:36 Screeny drwxr-xr-x 2 harry harry 4096 Oct 30 2019 Videos harry@biker:~ $Opening rox file manager as root and try to delete it. Permission denied. Only ran it once with a borrowed Phone Samsung Galaxy. Only difference. I put my launcher in menu instead of personal. On screen phone prompt asked for permission, as usual, when launchung jmtpfs. Phone folder was made as user in rox file manager. In case you are wondering.
My feedback on that post.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsMay 19, 2020 at 1:37 pm #36116Forum Admin
rokytnji
::Keeps getting better
harry@biker:~ $ su Password: root@biker:/home/harry# srm -rfll Phone Error: File Phone - Permission denied root@biker:/home/harry# root@biker:/home/harry# shred -v -n 25 -u -z Phone shred: Phone: failed to open for writing: Is a directory root@biker:/home/harry# rm --dir Phone rm: cannot remove 'Phone': Is a directory root@biker:/home/harry# rm -d Phone rm: cannot remove 'Phone': Is a directory root@biker:/home/harry# rm -R -d Phone rm: cannot remove 'Phone': Is a directory- This reply was modified 2 years, 11 months ago by rokytnji.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsMay 19, 2020 at 1:38 pm #36117MemberPPC
::@roky: try
fusermount -u ~/Phoneand then try to delete the folder.
If all else fails, try to delete it as rootP.
May 19, 2020 at 1:44 pm #36119Forum Admin
rokytnji
::You da man PPC. Took no chances and deleted Phone folder as root rox file manager right click delete.
Sure was a weird end result.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsMay 19, 2020 at 3:42 pm #36120MemberModdIt
::Hallo roky,
we all family (and users) figured out our way of phone mounting in September last year, it has worked perfectly since then, sorry my memory is sometimes a bit rusty.
Folder permissions on my box are as below.drwxr-x— 2 moddit moddit 4096 Sep 25 2019 Phone
May 19, 2020 at 4:14 pm #36121Forum Admin
rokytnji
::No biggy here moddit. Breaking record temps here over the 100F range and thunderstorms throwing hail and tornado’s.
So I was indoors and bored. Looked at my dogs. And Said, ” Hold My Beer ”
Had a dude stop over. So I said to him. ” Hand me your phone”
The rest is history.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problems -
AuthorPosts
- You must be logged in to reply to this topic.