Skip to content

Instantly share code, notes, and snippets.

@OrangeTide
Created February 18, 2024 17:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OrangeTide/73ee12738a43d3e99e5ddb66ced2bb2b to your computer and use it in GitHub Desktop.
Save OrangeTide/73ee12738a43d3e99e5ddb66ced2bb2b to your computer and use it in GitHub Desktop.
Use GMail as default email client on Linux / Ubuntu / Raspbian / Arch
#!/bin/sh
# Installation for using GMail as your preferred application
# This is for handling mime type: x-scheme-handler/mailto
#
# Place this script in your $PATH, and mark as executable
#
# Install the .desktop file:
# cp gmail-mailto.desktop ~/.local/share/applications/
#
# Check your current handler:
# xdg-mime query default x-scheme-handler/mailto
#
# Set your handler:
# xdg-mime default gmail-mailto.desktop x-scheme-handler/mailto
#
# Write a test email to a friend:
# xdg-email jon@rm-f.net
#
# open a new window (try fallbacks if others don't work)
URL="https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://'`"
xdg-open $URL || sensible-browser $URL || x-www-browser $URL || gnome-open $URL
# A more direct route:
# firefox "https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://'`"
[Desktop Entry]
Version=1.0
Name=Mailto Gmail
GenericName=Web E-mail client
Exec=gmail-mailto %u
Icon=gmail
Categories=Network;Email;
Keywords=mail;gui;gmail;pop;imap;smtp
Comment=Launches Gmail in your browser
Terminal=false
Type=Application
StartupNotify=true
MimeType=x-scheme-handler/mailto;
X-Info=Gmail Mailto
# TODO:
# Actions=GetMail;ComposeMail;SendFile;
#
# [Desktop Action GetMail]
# Exec=gmail-mailto --receive-all
# Name=Get Mail
#
# [Desktop Action ComposeMail]
# Exec=gmail-mailto --compose
# Name=Email...
#
# [Desktop Action SendFile]
# Exec=gmail-mailto --compose --attach %f
# Name=Send file...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment