AccessoriesAndroidGood and EVO

Creating an audio player dead man’s switch using a BT headset, Tasker, and AutoVoice

audio player dead man switch

Many people, me included, like falling asleep to some sort of audio, be it music, a podcast, an audio book, or something else. Tat is why any audio player app with respect for itself comes with a sleep timer, allowing you to set it to shut itself down after a certain amount of time. The problem with sleep timers is that they’re static. You have to guess a timer length that you think will work for your current level of sleepiness, but a lot of the time, it’s just a wild guess. A two hour sleep timer might shut off your audio book while you’re still awake and listening, or it might leave you trying to figure out where you fell asleep.

I just loaded some audio books onto my phone, and heading into a period of falling asleep to those, I got an idea to make a dead man’s switch. A dead man’s switch is essentially a switch that triggers when the person controlling it is no longer capable of preventing it from triggering, normally because he’s dead.

My first thought was to create something that I would have to squeeze in order to keep active, and that would then send a signal to my phone when I let it go from falling asleep. That’s actually simple enough to do; just take a Bluetooth headset, open it, and rewire one of the wires going to the battery through some sort of button that you need to hold down to give it power. Then, in Tasker, add a profile for that Bluetooth device being connected, and add you actions to the exit task. When you let go of the button, the battery is disconnected, disconnecting the headset, triggering the profile.

My problem with this however was that holding down a button for an extended period of time while trying to sleep sounded less than ideal. Then, I had another idea, and I went digging for something I created last year: a Tasker voice control bracelet. Back then it was the first prototype for a bracelet for controlling Tasker with voice, but I gave up on it due to there not being anything like AutoVoice back then, and eventually gave up on voice control altogether, instead favoring other controls methods. I was able to find the bracelet, and eventually also a charger.

Thebracelet is essentially a sock with a Bluetooth headset inside, with the charge port and control button sticking through. I added a bit of hot glue to the button to make it easier to press, and that was actually all I needed. I then set up a profile in Tasker, using AutoVoice’s Bluetooth button feature as the context. This allows you to trigger a task when a button is pressed on a Bluetooth headset. The task I added is as follows:

Music Play (short notification sound)
Wait, 10 minutes
Music Play (short notification sound)
Wait, 15 seconds
Music Play (short notification sound)
Wait, 15 seconds
Kill app (the audio book app) using root
Profile Status (Dead Man’s Switch), set Off

I also went into the settings for that app and changed the collision handling to abort the current task.

So, what does this do? When I’m listening to my audio book, I can turn on the bracelet and click the button once. This plays a confirmation sound, and then waits for 10 minutes. It then plays the sound again, waits 15 seconds, plays the sound once more, waits 15 more seconds, and then kills the audio book app, followed by it deactivating its own profile so it can’t re-trigger accidentally.

If I however click the headset button at any time during that 10.5 minute period, it will abort the task, restart it, and reset the timer. This way, as long as I keep pressing the headset button at least once every 10 minutes, the app will stay alive. When there’s 30 seconds left, it lets me know that the timer is about to expire, so that I don’t simply forget to press the button. If I fall asleep, I obviously stop pressing the button, and the app will be killed within 10 minutes. That way, when I start back up, I only have to back track a maximum of 10 minutes to find where I left off, which is far easier than with longer sleep timers.

I also have a second profile, which uses the Bluetooth Connected context for the bracelet. When it connects, it re-enables the profile, and when it disconnects, it kills the audio book app, stops the Dead Man’s Switch task, and deactivates the profile. If I didn’t have my smartwatch connected, however, I would just disable Bluetooth at the end of the profile, rather than disable the profile.

I’ve tried this setup up in practice, and it works great. I might experiment with setting the timer to 5 minutes, but honestly, it’s very easy to find where you left off when it’s within a 10 minute period. It’s also not an issue (for me at least) to have to press the button once every 10 minutes, and the bracelet doesn’t bother me.

While I am using a custom made bracelet, you only really need a cheap, off the shelf Bluetooth headset to this this yourself. The bracelet can be put around my hand so that the button is in a very natural place, and it has the added advantage of being soft and not being in the way or disappearing after I fall asleep, Other than that, you don’t need to break out the sowing kit to do this.

I also think this basic method has potential for other uses. It basically gives you the ability to attach wireless buttons to anything you want, and with the cost of Bluetooth headsets, it won’t cost an arm and a leg to do so. All thanks to AutoVoice.

tasker banner - for some reason we don't have an alt tag here

Pocketables does not accept targeted advertising, phony guest posts, paid reviews, etc. Help us keep this way with support on Patreon!
Become a patron at Patreon!

Andreas Ødegård

Andreas Ødegård is more interested in aftermarket (and user created) software and hardware than chasing the latest gadgets. His day job as a teacher keeps him interested in education tech and takes up most of his time.

Avatar of Andreas Ødegård