A Good Night’s Rest


I am not the only techie who struggles to get enough sleep. I’ve recently instituted a lifehack that is giving me some relief, and I want to share it. To my sleep-deprived sisters and brothers, this one’s for you.

Although I have no trouble falling asleep (quite the contrary), I am dogged by insomnia because I delay and delay going to bed. And—as you well know—that makes every other aspect of life more difficult.

So, c’mon, we owe this to ourselves. To fully be our true awesome selves, we need a full night of sleep.

Sleep hygiene

The key to transforming sleep from a battle to a balm is regular routine. Sleep hygiene, like dental hygiene, is a collection of healthy habits, a pattern that signals “sleepy time” to your brain. Same bed time, same nightly routine, a restful wind-down to the day.

“I stay up until I’m sleepy,” you protest. But here’s the thing: shining light into your eyes tells your suprachiasmatic nucleus, “It’s daytime! Stay awake. Stay awaaaaaake!” If you’re punting on the internet, you’re not going to get sleepy. Not at the right time, anyway.

I’ve read up a lot on good sleep habits and, previously, practiced them rigorously, to get debilitating daytime sleepiness under control. In college I underwent an all-night-and-all-day sleep study (ugh, it was awful); results were inconclusive but various pharmacological solutions were bandied about. And I thought: I don’t need to be medicated; I can beat this. For more than a decade, I have, but habits have been sloppy lately, with bedtime slipping later and later. Time to change that.

As important as flossing and folic acid, make sleep hygiene a habit. Close the laptop, perform your nightly ablutions, and get into bed.

Take willpower out of the equation

My sage friend Aneel gave me the most useful advice on sleep hygiene. Willpower, he says, is a resource you deplete. At the end of the day, you’re tapped out. Therefore, any decision that relies on willpower—the decision to go to bed, for example—is likely to be made… poorly.

The solution is to take the decision out of your hands. To wit, automate it. Schedule the computer to shut down.

Script those zees

(Outside the US, do people “catch some zeds”?) I need something taken care of without having to think about it? PowerShell!

I created a PowerShell script that warns me to wrap up my work, then sets the computer to sleep. I call that script from a Windows scheduled task.

Caveat emptor. To write this script, I picked up pieces of PowerShell and stuck them together with mud and spit. Please make a better version, put it in a gist, and link to it in the comments. Sleepy nerds will thank you.

Start the Task Scheduler, select Create Task, create a daily trigger a little before bedtime, and set the action to run your PowerShell script.

Create Task in Windows Task Scheduler

Create new Action, set action type to Run a Program, enter PowerShell as the command

It’s currently set later than I’d ultimately like, but if I made too drastic a change all at once, I’d just flout myself and restart the computer. So this is a compromise, a deal I’m making with myself for now. Incremental improvements.

I won’t tell you what time it was when I wrote that script. Heh.

Accessible Markup: Provide a pronunciation tip to screenreaders