Skip to content

Instantly share code, notes, and snippets.

@pejobo
Last active June 17, 2020 12:03
Show Gist options
  • Select an option

  • Save pejobo/8f5d0a78543d324381365b77e9ec3b6f to your computer and use it in GitHub Desktop.

Select an option

Save pejobo/8f5d0a78543d324381365b77e9ec3b6f to your computer and use it in GitHub Desktop.
start phone call from browser on linux, either with scriptlet or by simply clicking on href="tel:<number>" links embedded in websites
<?xml version="1.0" encoding="UTF-8"?>
<!-- place in ~/.local/share/mime/packages/ -->
<!-- and update the mime database with `update-mime-database .local/share/mime/` -->
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="x-scheme-handler/tel">
<comment>telephone mime type</comment>
</mime-type>
</mime-info>
[Desktop Entry]
# place in ~/.local/share/applications/
Version=1.0
Name=Dial phone number
# replace with absolute path
Exec=~/phone.sh "%U"
Terminal=false
Type=Application
MimeType=x-scheme-handler/tel;x-scheme-handler/sip;
#!/usr/bin/env bash
#
# see https://help.gnome.org/admin/system-admin-guide/stable/mime-types-custom-user.html.en
# 1. create file ~/.local/share/mime/packages/phone-x-tel.xml for mime type "x-scheme-handler/tel"
# 2. create file ~/.local/share/applications/phone.desktop
# 3. issue shell command: update-mime-database ~/.local/share/mime
# 4. issue shell command: update-desktop-database ~/.local/share/applications
# 5. create s sciptlet if you want to call any number on a web page by selecting it with mouse
#
number=$1
if [[ $number == tel:* ]]; then
number=`echo "$1" | cut -d: -f2`
fi
number=`echo "$number" | sed -r 's/%20//g' | sed -r 's/[^0-9+]//g'`
if [[ $number == 0* ]]; then
number=+49${number:1}
fi
if ! zenity --name=Anrufen --question --title "Anrufen" --text "Telefonanruf starten?" --ok-label "$number anrufen" --cancel-label "Abbrechen" ; then
exit 0
fi
# replace with the command for your phone client
/usr/bin/linphone -c $number
javascript:q = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); if (q!=null) location="tel:" + q.replace(/[^0-9+]/g, ""); void 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment