#!/bin/bash
set -e
readonly LOCAL_DESKTOP_FILE_DIR=~/.local/share/applications
mkdir -p "${LOCAL_DESKTOP_FILE_DIR}"
readonly DESKTOP_FILE_NAME=cipd-chrome.desktop
readonly CIPD_CHROME_DESKTOP_FILE="${LOCAL_DESKTOP_FILE_DIR}/${DESKTOP_FILE_NAME}"
cat << EOF > "${CIPD_CHROME_DESKTOP_FILE}"
[Desktop Entry]
Version=1.0
Name=Google Chrome
GenericName=Web Browser
Comment=Access the Internet
Exec=${CHROME_EXECUTABLE} %U
StartupNotify=true
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/file;
EOF
export DESKTOP_SESSION=gnome
xdg-mime default "${DESKTOP_FILE_NAME}" inode/directory
xdg-settings set default-web-browser "${DESKTOP_FILE_NAME}"