Sunday, November 15, 2015

Google Drive on Slackware Linux

On Windows and also (so I'm told) MacOS X, Google provides a nice Google Drive shell extension that lets you browse your cloud-stored files and automatically keeps your local filesystem in sync with the cloud. At work, where I use Windows, it's become a really nice part of my workflow. But Google doesn't provide any such client for Linux, which I use at home.

Recently I went looking for a third-party Google Drive client for Linux. It was both harder than it really needs to be and not nearly as bad as it could have been to get it working.

I run Slackware 14.1, so my first stop is searching slackbuilds.org, but I don't find anything good there. There's grive and InSync. Grive requires you to manually sync the files, so I'm not interested. InSync looks promising but after installing it I can't get it to work.

Then a general web search gives me a few results, and I come across the charmingly named google-drive-ocamlfuse. I am initially wary of an application whose name manages to include both the language it was written in and an implementation detail, a sign that the author might care too much about details that are irrelevant to most end users. But it seems that a number of people have used it successfully so I am willing to give it a shot.

I am initially surprised to learn that I don't have OCaml installed. I used to really like that language, but I guess it's been about 15 years since I did anything with OCaml. Now that I think about it, I do remember dumping OCaml after meeting her more attractive and intelligent younger sister Haskell. I'm definitely going to need my ex's help now though, so I look her up in slackbuilds.org, installing using sbopkg.

Now, how do people install stuff with OCaml these days? It turns out that like almost any decent language these days, OCaml now has a nifty command line client to download, compile, and install any open source OCaml software along with its dependencies. OCaml's is called opam (or OPAM if you're feeling shouty). But, there's no opam Slackbuild. (Note to self: make an opam Slackbuild). However, they make it ridiculeasy to get opam by providing prebuilt binaries.
  1. Download a prebuilt binary. I chose opam-1.2.2-x86_64-Linux.
  2. chmod +x that bad boy
  3. ./opam-1.2.2-x86_64-Linux init
  4. eval `./opam-1.2.2-x86_64-Linux config env`
  5. ./opam-1.2.2-x86_64-Linux install google-drive-ocamlfuse
I do it this way instead of renaming it to opam and putting it in my path because I do intend to make a Slackbuild that does a proper install later. Anyway, now I have google-drive-ocamlfuse. It ends up landing in ~/.opam/system/bin/google-drive-ocamlfuse so I make a link from there to ~/bin/google-drive-ocamlfuse, which is in my path.

I'm happy to find that google-drive-ocamlfuse has good and accurate documentation. I run
google-drive-ocamlfuse with no arguments and it opens Firefox so I can tell Google to allow the application to access my Google drive account. Run "google-drive-ocamlfuse ~/google-drive" to mount my Drive. I poke around and... what the heck? My Google Docs/Sheets have turned into OpenOffice documents. I try opening a few, and sure enough, they open in Calc or Writer. They're still unchanged in Google Drive, but they're being converted on my local filesystem. Back to the documentation.

Here's where it gets annoying. What I want is to click on a Google Doc and have it open in a web browser so that I can collaborate in real time with others. I don't want to locally edit some copy of the document, that's not the point. Now, I do store OpenOffice documents in my Google Drive as well. But when I store a Google Doc or Sheet in my Drive, I want it to remain a Google Doc or Sheet.

But it's just a temporary setback. google-drive-ocamlfuse can be configured to work just the way I want. It just didn't come that way out of the box. The documentation tells me that I just have to edit ~/.gdfuse/default/config, change spreadsheet_format, document_format, etc to "desktop". Now after unmounting, clearing the cache, and mounting again I see default-icon desktop links that do indeed open the docs in a web browser when I click on them in KDE.

But those icons! I can't tell whether a .desktop file is a spreadsheet, a presentation, or a document. So I also have to edit the config file to manually add my own icons. This is the first point at which I resent how much work I'm putting into this task. I poke around on my hard drive and find KDE's icons for Microsoft Office documents. Those will do. The config file is also awkward to read and edit because it's an unordered mess. I sort it alphabetically so I can read it a little better. Much better. Here it is:

 client_id=
 client_secret=
 conflict_resolution=server
 curl_debug_off=false
 debug=false
 delete_forever_in_trash_folder=false
 docs_file_extension=true
 document_format=desktop
 document_icon=/usr/share/icons/oxygen/48x48/mimetypes/application-msword.png
 download_docs=true
 drawing_format=desktop
 drawing_icon=/usr/share/icons/oxygen/48x48/mimetypes/application-vnd.oasis.opendocument.image.png
 force_docs_export=false
 form_format=desktop
 form_icon=/usr/share/icons/oxygen/48x48/actions/view-form.png
 keep_duplicates=false
 large_file_threshold_mb=16
 map_format=desktop
 map_icon=/usr/share/icons/oxygen/48x48/mimetypes/application-x-marble.png
 max_cache_size_mb=512
 metadata_cache_time=60
 new_revision=true
 presentation_format=desktop
 presentation_icon=/usr/share/icons/oxygen/48x48/mimetypes/application-vnd.ms-powerpoint.png
 read_only=false
 spreadsheet_format=desktop
 spreadsheet_icon=/usr/share/icons/oxygen/48x48/mimetypes/application-vnd.ms-excel.png
 sqlite3_busy_timeout=500
 stream_large_files=false
 umask=0o022
 verification_code=

Feel free to replace with your own favorite icons. I am absolutely too lazy to look around for the appropriate Google icons.

No comments:

Post a Comment