Disable suspend while using vpn on Ubuntu

My PC is set up to save power quite aggressively, by suspending after only 5 minutes of inactivity. This is fine most of the time, when the PC is periodically used by the family to quickly read email or check into facebook. But this causes me problems when working from home.

I use OpenVPN to connect to the office and run screen sessions and the occasional X11-forwarded GUI, and the suspend operation causes OpenVPN to be disconnected once I resume. This means that every time I have a coffee break, or try to whiteboard something, I get back to the computer and have to re-establish the ssh session, resume the screen session and restart any X11 apps I might have been using. It's at this point that I remember to change the power saving options to disable the suspend, but then I forget to re-enable it once I've finished working for the day.

To fix this without me having to remember to do anything special, we can automatically prevent the suspend (or hibernation) of the PC when the openvpn client is running.

As root, create a new file called /usr/lib/pm-utils/sleep.d/000vpn-disable-sleep, give it the contents shown below and make it executable.

sudo vim /usr/lib/pm-utils/sleep.d/000vpn-disable-sleep
# Prevent machine from suspending or hibernating when openvpn is running.
case "$1" in
    /bin/pidof openvpn && exit 1
exit 0
sudo chmod +x /usr/lib/pm-utils/sleep.d/000vpn-disable-sleep

Works for me on Ubuntu 14.04 LTS. YMMV.

Ubuntu 14.04 on MacBookPro6,2

Ubuntu 14.04 works very well on my MacBookPro6,2. To check what version of mac you have:

sudo dmidecode -s system-product-name


I noticed it was running hot, then realised this might be because no fans were running. This can be easily fixed on 14.04 by just installing macfanctld:

sudo apt-get install macfanctld

Before that command had even finished running the fans span up and started to cool things down.

Function keys

By default the function keys do the "screen dim", "screen brighten" actions, and you have to use the fn key to get F1, F2 etc. I prefer to reverse this. Doing so requires pommed which again is included in standard 14.04 apt-repository:

sudo apt-get install pommed

Then a quick edit of the /etc/pommed.conf file to change fnmode from the default value of 1 to 2. After saving the changes to this file, apply them with a quick:

sudo service pommed restart

Screen goes black when on battery

Again edit /etc/pommed.conf to change …

    on_batt = 6


    on_batt = 0

…to disable this.

Now faster than 84% of sites

It's official: according to Google Webmaster Tools, this site is now “faster than 84% of sites”:

Graph of site performance for daybarr.com

Can you tell when I made the switch from using Drupal to Django? ;)

Here's my Pingdom graph for the same period:

Graph of site performance for daybarr.com

Pingdom also show the same marked improvement around the end of August.

Hopefully there'll be another improvement to report on soon - I upgraded Django to v1.3 a couple of days ago (absolutely painless) and finally got around to setting up memcached today (a little more painful due to a bug in the pylibmc library that causes mod_wsgi to hang). Time will tell how the caching affects things, but in the meantime, here's a “live” report from Pingdom for the last month:

Response time for daybarr.com: Last 30 days