
Remote control phone app
The problem
When I watch TV, I typically hook my laptop up to the TV to use YouTube or Prime or another "unofficial" streaming service. The issue that I faced with this is that to have any sort of control over play/pause or changing episodes or putting something else on I had to get up, go to my laptop and do it from there. And this sparked my idea for my next mini project, LyteRemote.
The idea
Python is good at many things, two of which is automating inputs on a computer and creating webservers. So my idea was simple, I have a ReactNative app that calls a Python webserver who's endpoints are hooked up to Pyautogui functions to control the media on my TV.
Building the app
This is a small project so building it was incredibly simple. I vibecoded a frontend in ReactNative that looks like a TV remote (there was no chance I was designing that UI myself), then I built a simple rest API with 3 endpoints:
-
play/pause
-
mute
-
move mouse
The play/pause and mute endpoints are pretty self explanatory, pyautogui has built in function calls for both of those and the endpoints simply call those functions. The move mouse however is a little more interesting. Essentially, on the frontend we have a Panresponder instance linked to a touchpad UI component that acts as a laptop trackpad, which effectively takes multiple touches and converts them into one input, in this case we are using it specifically to get the deltas between where you're finger starts and where it ends. This delta is then sent to the server (really this should be done with webhooks, however this project was about laziness and it was much easier to just make a rest endpoint for this). When the server receives the deltas we apply some acceleration to the delta to make a smoot movement from the starting point to the ending point instead of just teleporting the mouse there and then use pyautogui's moveRel to move the mouse. On the frontend as well, if the deltas are too small, we register that as a click allowing the user to click the mouse simply by tapping the trackpad.
For actually using this, I went with the laziest implementation possible:
- the user starts the webserver on the laptop and it gives a local IP to connect to
- the user starts the app via expo on any machine they want and then connect and use it within the Expo Go app
- upon opening the app a dialog box prompts the user to enter the IP for connecting to the webserver
Next steps
This was just a quick and dirty experiment to test if this idea was any good just for me to use, and it actually worked quite well, but as a result there is 0 polish. The first obvious step would be to use webhooks for the mouse movements. Then I have some ideas for streamlining the connection process, like having the app actually be a website that gets hosted on the laptop and you just go to that website in your local network, but I have to experiment to find the best solution for that. And obviously, if I don't go with the website, it would be good to get the app on the actual app store instead of just using Expo, but I cannot be bothered to pay 160 something dollars for an Apple developer account right now, but I should soon because I have multiple apps that I want to start releasing.
Conclusion
This is one of my favorite projects that I have done because it's shit simple, janky, creative and had me spend an hour solving the smallest inconvenience in my life. The frontend Github is linked here, and you can find the webserver under my Automation project also on my Github, that's where I store all of my laziness enabling Python scripts, which I will write about soon. I will post an update whenever I decide to go back and polish this project off but for now it works for me