Jacob Mulquin

Wifey Laptop Controller

In which I overengineer solutions to non-technical problems

✍️ Jacob Mulquin
📅 30/10/2022

I have a terrible habit of needing some sort of light and sound playing as I go to sleep. If it's silent and/or too dark my brain just won't shut-off. It has been a habit I've had for many years and I fear it's far too entrenched for me to stop anytime soon.

Thankfully my lovely wife accepts this about me and is OK with me running a small Xubuntu laptop on my bedside table.

Annoyingly for her, I also have a habit of falling asleep relatively quickly. Usually after about 20 minutes the deep echoes of my snores fill the room. The pre-existing solution to this is for her to whack me awake and I shut the lid. I don't like doing this, she doesn't like doing this. Nobody likes this.

So what should I do, develop healthy sleep hygeine perhaps? A good idea, but not today.

What I do instead is develop a small web-app that she controls with her phone, and dip my toes into some Ruby.

Originally my plan was to make the web server in Ruby myself, but then I noticed Sinatra exists, so I did the lazy thing instead.

An hour or so of hacking and tinkering, I had a simple Ruby script that runs system commands to manipulate the laptop. It's quite impressive how easy it is to do things with Ruby/Sinatra.

A basic user interface allowing my wife to manipulate the laptop

As the laptop runs on my bedside, the brightness is set to lowest setting at all times. Sometimes even this feels too bright so I decided to implement "fake brightness" buttons using Redshift. One thing about the program that is frustrating is that it's really keen on the idea of you giving it a geographic location so it can automagically work out optimal screen temperature and brightness. If you want to use it as a one-shot change, things get a bit more complicated. I couldn't figure out how to get the brightness value after setting it with a one-shot command. To workaround it, I make use of two files in the /tmp/ directory.

I'll probably add some other features to it down the track, a few I can think of:

All in all, a fun little project. You can find the source code on Github at mulquin/wifey-laptop-controller. This should work with any Ubuntu flavour, but it may even work with other Debian based systems.