Launch gsheet (and other google docs) in web app mode

It has always bugged me that google docs shortcuts (.gsheet, gdoc etc) take over a tab in my chrome window whenever they’re clicked up. I had the same beef with gmail. I want email to load as an app, not a tab in my browser, so very early on I started doing this;

chrome.exe --app="http://mail.example.com"

This is great. I get an app on my Windows taskbar, not a tab hidden away in clusters of browsing sessions. Until today, the way to get this for google docs has eluded me. Unlike SkyDrive OneDrive where Excel, Word and friends are first-class citizens and share a file format between desktop MS-Office and the cloud (a significant advantage IMHO), gsheet files are simply links back to the cloud, and they look like this;

if ($args.Count -gt 0) {
 $url = Get-content $args[0] | out-string | ConvertFrom-Json | select url -expandProperty "url"
 $cmd = ($env:USERPROFILE)+'\AppData\Local\Google\Chrome\Application\chrome.exe --app=$url'
 invoke-expression $cmd
}

They’re executed in the Windows shell with googledrivesync.exe which (stupidly) just launches chrome¬†without the –app flag. So it should be easy enough but I wasn’t about to fire up VS2013 an find a home for a project structure just to do that. I knew powershell was the solution but I’ve never bothered to learn it. Today however, whilst simultaneously managing to avoid learning much above my zero knowledge of powershell, I managed to cobble this together;

<# example
powershell chromeApp.ps1 'myspreadsheet.gsheet'
#>

if ($args.Count -gt 0) {
 $url = Get-content $args[0] | out-string | ConvertFrom-Json | select url -expandProperty "url"
 $cmd = ($env:USERPROFILE)+'\AppData\Local\Google\Chrome\Application\chrome.exe --app=$url'
 invoke-expression $cmd
}

So I saved the file as chromeApp.ps1 to a folder in my path and then modified the shell registry entry for .gsheet with the following command;

reg add HKEY_CURRENT_USER\Software\Classes\GoogleDrive.gsheet\shell\open\command /f /ve /t REG_SZ /d "powershell chromeApp.ps1 '%1'"

 

And there we have it. Now when I click on .gsheet files in the shell I get a new, frameless window, not a browser tab. The above example just caters for .gsheet but it’s easy to add the other file formats of course.