On linux, at present for me .gsheetx files are zero bytes, and so they are in no way clickable to open in a web browser. Is it possible for the files to contain the URL, whether in json format or any other format, such that I could get them to open in a browser?
Hi @kelsangrinzin,
My apologies on this, but there isn’t currently a way to facilitate this on Linux. I have raised it to the product team, though.
If the files did contain the URL, would you register a local file handler to read the file content and then launch the browser with that URL?
Thank you, Tony,
Yes, that’s exactly what I’ll do. And happily post the method here.
Regards,
Rinzin
Hi @kelsangrinzin,
That sounds like a solid approach. Looking forward to seeing how you implement it, could be really useful for others in the same situation.
Hi @kelsangrinzin and @michaeelphillips,
Please try out this Linux build. Google doc files will contain the URL when synced.
Thank you so much! This is really great.
Note that it seems necessary to unsync and then sync again to get the URL in the file.
I asked Anthropic Claude to do the work, and it produced this script, which seems to set everything up to work perfectly, at least on my Debian system. I’m not sure that the section for .gdrivex files is meaningful, but not harmful:
#!/bin/bash
# Installation script for Google Drive file handler
# Create the handler script
cat > ~/.local/bin/gdrive-open << 'EOF'
#!/bin/bash
# Google Drive file handler - opens URL from file in default browser
if [ -z "$1" ]; then
echo "Usage: gdrive-open <file>"
exit 1
fi
FILE="$1"
if [ ! -f "$FILE" ]; then
echo "Error: File not found: $FILE"
exit 1
fi
# Read the first line (URL) from the file
URL=$(head -n 1 "$FILE" | tr -d '\r\n')
if [ -z "$URL" ]; then
echo "Error: No URL found in file"
exit 1
fi
# Open in default browser
xdg-open "$URL" 2>/dev/null || \
sensible-browser "$URL" 2>/dev/null || \
gnome-open "$URL" 2>/dev/null || \
echo "Error: Could not open browser"
EOF
# Make the script executable
chmod +x ~/.local/bin/gdrive-open
# Create the desktop entry
mkdir -p ~/.local/share/applications
cat > ~/.local/share/applications/gdrive-handler.desktop << 'EOF'
[Desktop Entry]
Type=Application
Name=Google Drive File Handler
Exec=/home/$USER/.local/bin/gdrive-open %f
MimeType=application/x-gsheetx;application/x-gdocx;application/x-gslidex;application/x-gdrivex;
NoDisplay=true
EOF
# Fix the $USER variable in the desktop entry
sed -i "s|\$USER|$USER|g" ~/.local/share/applications/gdrive-handler.desktop
# Create MIME type definitions
mkdir -p ~/.local/share/mime/packages
cat > ~/.local/share/mime/packages/gdrive-types.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-gsheetx">
<comment>Google Sheets Link</comment>
<glob pattern="*.gsheetx"/>
</mime-type>
<mime-type type="application/x-gdocx">
<comment>Google Docs Link</comment>
<glob pattern="*.gdocx"/>
</mime-type>
<mime-type type="application/x-gslidex">
<comment>Google Slides Link</comment>
<glob pattern="*.gslidex"/>
</mime-type>
<mime-type type="application/x-gdrivex">
<comment>Google Drive Link</comment>
<glob pattern="*.gdrivex"/>
</mime-type>
</mime-info>
EOF
# Update MIME database
update-mime-database ~/.local/share/mime 2>/dev/null || echo "Note: Could not update MIME database automatically"
# Update desktop database
update-desktop-database ~/.local/share/applications 2>/dev/null || echo "Note: Could not update desktop database automatically"
# Set as default handler for these file typesfor ext in gsheetx gdocx gslidex gdrivex; do
xdg-mime default gdrive-handler.desktop application/x-$ext 2>/dev/null
done
echo "Installation complete!"
echo ""
echo "To create a test file, run:"
echo "
echo 'https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID' > test.gsheetx"
echo ""
echo "You may need to log out and log back in for changes to take full effect."
Great! Thanks @kelsangrinzin