<a href=”tel:123456”>…</a>) verlinkte Telefonnummern aus dem Browser (Firefox) auf dem Notebook im Büro oder zu Hause auf dem Yealink IP-Telefon anrufenHier mal ein Beispiel, wie solche „Telefonnummern-Verknüpfungen“ eingebaut werden.
Smartphones lesen diese i.d.R. korrekt aus und ermöglichen so, direkt aus der Website heraus die Nummern anzurufen.
<html>
<head>
<title>Telefon-Test mit tel-Link</title>
<meta name="format-detection" content="telephone=no">
<style>
a[href^="tel:"] {
color: #008800;
text-decoration: none;
}
a[href^="tel:"]:hover {
color: #000088;
}
a[href^="tel:"]:before {
content: "\260e";
margin-right: 0.5em;
}
</style>
</head>
<body>
Ruf mich an <a href="tel:+49-30-123456789">(030) 123 45 67 89</a>
</body>
</html>
Zuerst sagt man dem System / Browser, wie den der MIME-Type x-scheme-handler/tel behandlet werden soll.
Dazu fügt man in der Datei ~/.local/share/applications/mimeapps.list folgendes hinzu:
[Added Associations] x-scheme-handler/tel=yealink.desktop
Den Desktop-Shortcut yealink.desktop muss man dann noch mit Leben erfüllen. Man legt ihn am besten auch einfach nach ~/.local/share/applications/yealink.desktop.
[Desktop Entry] Exec=yealink-dial.pl %u Terminal=false Type=Application
Hier wird einfach ein kleines Perl-Skript aufgerufen (yealink-dial.pl) dem die URL als Variable %u übergeben wird (also das ''tel:+49-123-4567890').
Da ich sowohl zu Hause (im Home Office) als auch im Büro IP-Telefone von Yealink nutze, die eigentlich sehr schön sind und angesteuert werden können (über entsprechend dokumentierte URLs am Telefon), soll das Skript also folgendes können:
Außerdem soll es:
#!/usr/bin/perl
# load modules
use Desktop::Notify; # DEB: apt install libdesktop-notify-perl
# defined ip phones
my $have_phone = 0;
my $iptel;
my %ipphone = (
# im Home Office: Yealink #1
'192.168.x.' => { 'ip' => '192.168.x.x',
'user' => 'username',
'pass' => 'password',
'desc' => 'Home Office T28P' },
# im Buero: Yealink #1
'192.168.x.' => { 'ip' => '192.168.x.x',
'user' => 'username',
'pass' => 'password',
'desc' => 'Office T46G' },
);
# get telephone number string from cli
my $telstr = shift;
my ($g, $tel) = split(/:/, $telstr);
# get my ip address
my $my_ip = get_ipaddr();
# select a ipphone
foreach my $k ( keys %ipphone )
{
if ( $my_ip =~ /$k/ )
{
$have_phone = 1;
$iptel = $k;
}
}
# prepare the number to dial (remove non numeric parts)
my $num = $tel;
$num =~ s/[^\+0-9]//gi;
$num =~ s/^00/\%2B/gi;
$num =~ s/^\+/\%2B/gi;
# dial if ip phone found
if ( $have_phone )
{
# phone's ip
my $ip = $ipphone{$iptel}{'ip'};
# build dial-url
my $url = 'http://' . $ip . '/servlet?number=' . $num . '&outgoing_uri=';
# notify user on desktop
desktop_notify("Wähle die Nummer $tel\n
vom IP-Telefon $ipphone{$iptel}{'desc'} ($ip) ...",
$ipphone{$iptel}{'desc'}, 'phone');
# dial url by retrieving url from phone
system("/usr/bin/wget -O /dev/null \\
--http-user=\"$ipphone{$iptel}{'user'}\" \\
--http-password=\"$ipphone{$iptel}{'pass'}\" \\
'$url'");
}
else
{
# well, can't dial without phone
desktop_notify("Kann $tel nicht anrufen.\nKein IP-Telefon gefunden ...",
"Yealink-Wähler", 'dialog-error');
}
sub get_ipaddr {
##############################################################################
# get ip address
##############################################################################
# get network ip addr
my ($ip);
my $ipaddr = `ip addr | grep "inet "`;
chomp($ipaddr);
foreach my $i ( split(/\n/, $ipaddr) )
{
$i =~ s/^\s+//gi;
$i =~ /inet\ ([^\s+]+)/gi;
$ip = (split(/\//, $1))[0];
if ( $ip !~ /127\.0\.0/ )
{
return $ip;
}
}
}
sub desktop_notify {
###############################################################################
# send notification about dial process to desktop via dbus
###############################################################################
my $n_text = shift;
my $n_title = shift;
my $n_icon = shift;
my $dbus_timeout = 10000; # 10 seconds
my $dbus_icon = 'dialog-information';
$dbus_icon = $n_icon if ( (defined $n_icon) && (length($n_icon) > 0));
my $dbus_title = 'Wähle auf dem Yealink ...';
$dbus_title = $n_title if ( (defined $n_title) && (length($n_title) > 0));
my $dbus_text = $n_text;
# open a connection to the notification daemon
my $notify = Desktop::Notify->new(
app_name => 'YealinkNotify',
app_icon => $dbus_icon,
);
# create a notification to display
my $notification = $notify->create(summary => $dbus_title,
body => $dbus_text,
timeout => $dbus_timeout);
# display the notification
$notification->show();
}