Skip to content

Custom application to open .gdoc extensions

lmmx edited this page Dec 26, 2014 · 33 revisions

Make a parsing script: /usr/bin/gdocopen.sh

  • cut -d\" -f 4 is the URL, just pass it to google-chrome
google-chrome $(cut -d\" -f 4 "$@")
* Make it executable: `chmod +x /usr/bin/gdocopen.sh`

Make an application to call it:

  • /usr/share/applications/gdocopen.desktop
    [Desktop Entry]
    Name=gdocopen
    Exec=google-chrome $(cut -d\" -f 4 %U)
    Terminal=false
    Type=Application
    MimeType=application/vnd.google-apps.document;

Set as default

  • First check gdoc doesn't have an associated mime-type: grep 'gdoc' /etc/mime.types
  • Add it if not: sudo vim /etc/mime.types (as per this)
application/vnd.google-apps.document				gdoc
* Set the `.desktop` file (and associated script) as default application for the new MimeType: `xdg-mime default gdocopen.desktop "application/vnd.google-apps.document"`

If this doesn't change anything

  • Remove the line and from /etc/mime.types and do it through XML
  • sudo vim /usr/share/mime/application/vnd.google-apps.document.xml
<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/vnd.google-apps.document">
  <glob pattern="*.gdoc"/>
</mime-type>
  • Update the system: sudo update-mime-database /usr/share/mime

👎 👎 👎 👎 👎 👎 👎 👎 👎 👎 👎 doesn't bloody work

  • update-mime-database deletes the xml file every time and variations on Exec= commands fail
  • file --mime-type -b ./GoogleDrive/University/{FILE}.gdoc remains text/plain

Retry application rather than MimeType

  • sudo ln -s /usr/bin/gdocopen.sh /usr/bin/gdocopen
#!/bin/bash

gdocurl=$(cut -d\" -f 4 "$@")
google-chrome "$gdocurl"
  • This works in the terminal, but fails when selected as default application in Nautilus
  • Changing MimeType in the .desktop file associated with the Nautilus application to text/plain sorts it
Clone this wiki locally