I’m really appreciating my new desk phone particularly now that I’m having to use a telephone much much more than I’ve done the past years. I got myself a Voyager Focus UC headset and have paired that to the phone and to the computer, and have been able to remove some of the cable clutter which occupied my desk. Dialing a number from the command line is one of the features I’m appreciating most on the phone.

I noticed a couple of days ago while searching for somebody in the address book that there are little blue “phone” icons, and my interest was piqued: could I have it so that if I clicked one of those, the Grandstream would dial a number?

screenshot of an address book entry on macOS

As is often the case, something which could be simple is complicated by the fact that Apple have changed things over the course of time. Be that as it may, this blog has the nitty-gritty, and I pasted the following small AppleScript together:

on open location this_URL

    set arg to text of this_URL
    set cmd to "/Users/jpm/take/bin/run-tel-uri.sh " & quoted form of this_URL
    do shell script cmd

end open location

I saved that as run-tel-uri.app and patched its Info.plist in a text editor:

--- run-tel-uri.app/Contents/Info.plist.orig	2020-03-23 11:42:20.000000000 +0100
+++ run-tel-uri.app/Contents/Info.plist	2020-03-23 11:46:22.000000000 +0100
@@ -2,6 +2,17 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>CFBundleURLTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleURLName</key>
+			<string>Telephone helper</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>web</string>
+			</array>
+		</dict>
+	</array>
 	<key>CFBundleAllowMixedLocalizations</key>
 	<true/>
 	<key>CFBundleDevelopmentRegion</key>

Finally, I set the preferred dialing app to my new run-tel-uri.app using SwiftDefaultApps, a preference pane which replaces RCDefaultApp which no longer works on newer macOS releases.

changing preferred app for a URI using SwiftDefaultApps

In case you are wondering, I tried using something like Platypus to “appify” my script directly but that didn’t work. Possibly becasue I didn’t know about the Plist trick above…

macos and phone :: 23 Mar 2020 :: e-mail