Solving Sleep Problems with Lua
by Matt on Apr.18, 2009, under learning, linux, programming, ubuntu
I’ve discovered recently that I don’t sleep well if I sit on the internet too late at night. Here is my solution.
I’d been intending to learn Lua for a little while now, so this entire project was written in lua, with some bash scripts to call stuff. Essentially what it does, is every minute it checks the time. If the hour is greater than or equal too that set in /etc/bedtimer then it uses iptables to close all the ports I use that go out to the internet. This allows me to continue using my local network stuff (except ssh) if I had things like coursework to do. The server part continues to run every minute after that, incase I try and override it (bad me). There is also a gnome bit that is loaded when I log in. This part simply uses the ubuntu notify-send thing to warn me when I have 15 minutes before the net shuts off, and when it shuts off.
The bit that does all the work is loaded at boot using an initscript. I have yet to reboot and test this, as it’s my first initscript, but it looks ok
Hopefully this will force me to actually stop wasting time on the net in the evenings and actually go read a book or do something to wind down at the end of the day.
The files can be found here. There is a shell script to install it all, but it’s rubbish and may not work on your machine! BE WARNED!
February 11th, 2010 on 1:47 pm
It is impossible to travel faster than the speed of light, and certainly not desirable, as one’s hat keeps blowing off. – Woody Allen Born 1935