Writings

Texting from my Linux laptop

· 2 min read

I'm on my laptop all day, and I'm the kind of person who puts their phone down somewhere and then forgets where it is. I don't like switching between my phone and my laptop while I'm working, but I still want to be able to text.

Mac users get their messages right on the laptop. I wanted that on Linux with an iPhone, couldn't find anything that did it, so I set it up myself.

how it works

iMessage is Apple-only, but iPhones already share messages and contacts with car stereos over Bluetooth. They use two standard profiles for it, MAP for messages and PBAP for contacts.

BlueZ, the Bluetooth stack on Linux, supports both through its obexd service. Once the phone is paired, turn on Show Notifications and Sync Contacts for the laptop in the iPhone's Bluetooth settings, and the laptop gets your messages the way a car would.

imsg

BlueZ does the hard part. I wrote imsg, a small Python tool on top of it, so I can read and send messages from the terminal with contact names instead of numbers.

sh
im alex hello from my laptop   # any part of a contact's name
imsg list                      # recent messages
imsg watch                     # notifications for new messages

Before anything sends, it shows who it's going to and asks me to confirm. imsg watch runs in the background as a user service. New messages show up as desktop notifications with a Reply button, which opens a small terminal prompt. If my phone goes out of range, it keeps retrying until it's back.

the annoying parts

I couldn't find any of this written down for iPhones, so most of it was trial and error.

Messages need an empty sender card at the start. Without it, the iPhone drops them and never says why. Recipients go in the phone-number field even when they're email addresses, because iOS cuts the first few characters off the email field. The iPhone also only allows one messaging connection at a time, so the background watcher holds it and every other command sends through the watcher.

what it can't do

Only plain text works. Group chats, photos, reactions and read receipts don't come through. The phone picks whether a message goes as an iMessage or an SMS, and it has to be within Bluetooth range. I mostly use it for quick replies while I'm working, and for that I haven't needed more.

turns out it already existed

After spending half a day on all this, I found out other people had already built it. BlueFerry and Tether do the same kind of thing, with more features. Try them if you want something ready to use.

I also wrote about building iOS apps from Linux.

book a chat