Sync Linux with Google Drive
Automatically download and sync files from your Google Drive account using a simple utility paired with cron.
Get your Google Docs offline using the open source Chromium browser, allowing you to view your files even when there’s no internet connection
Stream your Google Music from outside the browser, complete with desktop notifications, hardware media keys and other desktop integration options
Share files to your Google Drive from Linux and also get desktop access to your Google Music collection
We’re becoming an increasingly clouddependent world, thanks to the convenience of having our files to hand wherever there’s internet access. From computers to smartphones to tablets, all our devices can be connected to our online documents and storage. One of the best services for achieving this is Google Drive, Google’s free service tied into its Google Docs. Unfortunately, while the integration of Drive with Android phones is fantastic, there’s currently no official Linux client for syncing with the cloud service. While you can at least edit documents from a browser, you can’t do any desktop syncing so that your files are the same across your entire ecosystem. In this tutorial, we’ll show you how to set up your own syncing system on Linux that checks for changes at intervals you specify, to save bandwidth. We’ll also throw in a way to stream music through the new Google Music service via a desktop app – one you can also control with media keys.
Get Grive
We’ll use Grive, a command-line Google Drive tool, to accomplish syncing for our purposes. First, download the git repository with: $ git clone git://github.com/Grive/ grive.git Once that’s downloaded, cd to the newly created grive directory.
Grive libraries
Before we start to compile Grive, we need to make sure we have the correct libraries and dependencies installed on the system. Grive requires: • libgcrypt11-dev • libjson0-dev • libcurl4-openssl-dev • libexpat1-dev • libboost-filesystem-dev • libboost-program-options-dev • binutils-dev Install these onto your system, as well as build- essential if you don’t have it, before proceeding .
Grive build
Set up the build environment for Grive by typing into the terminal: $ cmake . The full stop needs to be there. It will work through quickly and configure the build files. However, sometimes you may need to perform it as root.
Grive make
Now it’s time to actually compile Grive, of course with the magic:
$ make This will take a while as it compiles the package for use. Dependencies should be covered, but be prepared to install some more if the build fails for some reason.
Move executable
You’ll need to move the Grive executable to the folder you’ll be using for the file syncing, so create a Google Drive folder if you haven’t and move it there with cp. Running the executable syncs everything in the folder where it lies, so you don’t want to sync the Git files.
First sync
Move to your Google Drive folder in the terminal using cp, and execute Grive for the first time like so: $ ./grive -a This will do some initial setup, then give a link to follow. Click on the link or copy and paste the URL.
Grive permissions
Make sure you’re logged into your Google account before clicking the link, and then grant permission for Grive to access Drive. Copy the code it gives and paste it into the terminal; it will continue with the first sync, uploading the Grive executable first before downloading directories and files.
Future Grive
To perform a sync in general, all you need to do is open a terminal and execute Grive from the Google Drive directory with simply: $ ./grive For the moment, you will have to run this every time you finish making changes to the directory or files.
By Cron
We can make it so that syncing occurs automatically using cron and crontab to set up a cron job. To open crontab use: $ crontab -e You may need to be superuser to do this. If it’s already set up, you’ll be ready to go, otherwise follow the instructions.
Cron start
If this is your first time using cron and crontab, all you need to do is select a text editor to use. It will recommend one from your installed editors, which you can just press Return to use, or alternatively select from the numbered list.
Cron syntax
If you’ve never used cron before, the syntax to create a cron job is quite simple and arranged as so: Minute, Hour, Date, Month, Day, command. The date is the month date, while day is the actual day of the week. You can put an asterisk wherever you want to ignore a field.
Cron job
In our example, we want cron to run Grive every ten minutes. We’ll write it like this: */10 * * * * * cd /home/user/ GoogleDrive/ && grive The first part makes sure the cronjob is activated every ten minutes. If you want to save some bandwidth, you can change the number.
Save cron
Once you’re happy with your cron job, make sure to save crontab using Ctrl+O, then Ctrl+X to quit. This will immediately start executing Grive every ten minutes, which will then sync your files up to Google Drive, and then down from Drive.
Google Docs
Documents won’t be synced with Grive, but what is downloaded on other systems are just links to the documents anyway. Chromium can access these docs offline once set up properly by first installing the Drive app from the Chromium Store. Right-click on the app and you can also add it to your desktop or menus.
Offline Docs
To make the docs offline, click on More in the left column of the Drive interface. Go to Offline Docs, where it will ask you if you want to keep your docs offline. Click the button and your documents will automatically be downloaded for you. Every time you turn on Chromium, it will sync any changes and at the very least it will allow you to view the documents offline. However, like with the documents in a Drive folder, you’ll need an internet connection to edit them.
Google Music
Google Music lets you store your local music files on the cloud – up to 20,000 tracks – while also allowing you to stream your Google Play music without taking up any online storage space. Go to play.google.com/music and make sure you’re signed in with your Google account.
Music Manager
Click on Upload Music, and download the Music Manager. There’s a selection of binaries for different distros you can get, which can then be installed using your package manager. After it’s installed, launch the app to get started setting it up, linking your Google account in the process.
Upload music
Select the folders you want to upload and it will start uploading what it needs. If you have a track that is available on Google Play, the Manager will skip it and instead use that. You can set it to scan your library every now and then and upload new tracks.
Nuvola Player
You can play Google Music from the browser. However, you need to keep a tab or window of that open, and it doesn’t integrate well with hardware media keys. Nuvola is an open source player that streams online music, such as Google Music, and integrates well with the desktop.
Install Nuvola
Sync with Google Drive Get desktop access to your Google Drive in Linux Head over to the Nuvola website at nuvolaplayer.fenryxo.cz and download either a binary package or the source. Install the packages using your preferred package manager, or by compiling from source. For Debian and Ubuntu, there’s a PPA you can add which will allow you to update the software.
Set up Nuvola
Launching Nuvola will take you to a service selection screen, allowing you to choose between Google Music and other services like Rdio, Pandora and Grooveshark. Click on Google Music, then ‘Use this service’ and log into your Google account. You’ll get the same interface as the web, only now with external controls.
Hardware keys
There are two steps to make sure your hardware media keys are working. First of all, in Nuvola, go to Services in the toolbar, then Preferences. In the Extensions tab, make sure Media Keys is selected. If they don’t start to work immediately, make sure your desktop environment’s support for them is also turned on.
Other extensions
The Extensions tab also allows you to integrate Nuvola a bit more with your desktop. This includes track notifications, a tray icon you can control Nuvola with, a dock manager that can be used with Linux docks to also control Nuvola from, and an MPRIS interface.
Google desktop
With all this set up, you have full desktop access to your work, music and other files on your Google Drive. Even without official tools, it’s surprisingly easy and hassle free to get the entire suite set up, and can increase productivity with the right mindset. Experiment with ways to make it work for you.
No comments:
Post a Comment