8

I want to mount/unmount my google drive using google-drive-ocamlfusewith a key binding without having to open a terminal. How can I set this up?

dessert
  • 39,982

2 Answers2

13

Short answer:

Mounting

/bin/bash -c "google-drive-ocamlfuse ~/path/to/foldershowinggoogledrive"

where path/to/foldershowinggoogledrive is the path relative to your homedir.

e.g. /home/you/googledrive -> ~/googledrive

No need for sudo!

Unmounting

Similarly, to unmount, if you use ~, you should use in a shortcut:

/bin/bash -c "fusermount -u ~/relative/mountpount"

Or if you use absolute path:

fusermount -u /absolute/path/to/mountpoint

Why /bin/bash -c?

You could use

google-drive-ocamlfuse /absolute/path/to/folder

but since you are using ~, you need the expansion handled by bash.

Binding commands has been explained within How to bind custom commands to keyboard shortcuts?: System Settings -> Keyboard -> Custom Shortcuts -> + button


EDIT

Just noticed ODrive which works substantially different. ODrive actually downloads the files and synchronizes with Google Drive, similar to how the Windows version of Google Drive works.

enter image description here

The big advantage -at least to my experience- is the immediate response to editing & saving, while the previously mentioned solutions have a huge delay on the work process during saving.

Jacob Vlijm
  • 83,767
2

Gnome online accounts can do this for you. It may be already installed but if not you can find it in the software center or download it for your Ubuntu version and architecture here. Now you can connect your google account to gnome through Settings->Online Accounts. If Online Accounts isn't present in the list log out and back in again.

Choose Google from the list of Online Accounts and sign in with your credentials.

Gnome will request permissions to Access which you'll have to accept. If you are asked for your keyring password (usually your login password) provide it.

Click on the Google Account.

Flip the files switch on and then close the Window.

Open Nautilus and you should see a networked drive option that matches your google account on the left pane. Click on that and enjoy access to your google drive!

Sources:

https://www.maketecheasier.com/mount-google-drive-ubuntu/

Testing

Elder Geek
  • 36,023
  • 25
  • 98
  • 183
  • Both options are not optimal if it comes to read/write speed. OP's option reads/writes slow, but still substantially faster than this one. – Jacob Vlijm Feb 11 '19 at 23:02
  • "Click on the Google Account Flip the files switch on and close the Window." Consider rewriting this sentence a bit. I found it a little unclear. There's a flip switch ? or is it called Google Account Flip menu ? Otherwise, +1 – Sergiy Kolodyazhnyy Feb 12 '19 at 01:28
  • @SergiyKolodyazhnyy apologies for the run on sentence. Corrected. – Elder Geek Feb 12 '19 at 13:06