keyd icon indicating copy to clipboard operation
keyd copied to clipboard

Using Amazon Bluetooth Remote to Emulate Apple TV Remote

Open sl33nyc opened this issue 6 months ago • 2 comments

I'm interested in using keyd to emulate the AppleTV (ATV) remote using an Amazon Bluetooth remote. Previously, I wrote a Python script to listen to libinput events + pyatv. That combination worked reasonably well except the Amazon remote's power button would put the entire system to sleep. I never figured that issue out...

Anyway, I thought that I'd try keyd as a cleaner abstraction. pyatv comes with a script, so I thought using the keyd action, command(atvremote ...) work be roughly similar to my Python script. However, the lag between keypress and ATV response was painfully slow.

What are somethings that I can tune to make this a better experience? I read keyd's man page, and it wasn't obvious to me what is available to change for this problem. Any suggestions?

sl33nyc avatar Jun 10 '25 13:06 sl33nyc

atvremote is a Python script, I would guess. The lag you experience is probably Python startup time, nothing that keyd can do all that much about. In any case, through keyd the script would be run as root, which is also not ideal.

I actually think listening to key events in Python and calling the pyatv library from there, as you were already doing, is the clean solution here. Was the only problem the power button putting the system to sleep?

nsbgn avatar Jun 11 '25 11:06 nsbgn

The lag you experience is probably Python startup time, nothing that keyd can do all that much about.

Perhaps I should run a long-lived Python daemon and have keyd call it.

Was the only problem the power button putting the system to sleep?

Yes, I believe that I modified /etc/systemd/logind.conf to disable the default behavior of inferring power off when the power button is pressed. Despite that and mapping the power button to sending the atvremote command for "power off", the power button press would sometimes still turn off the entire system. (It always seem to happen more when my 7yo would be watching TV!)

sl33nyc avatar Jun 11 '25 12:06 sl33nyc