Redshift – visual help for night owl programmers

If you’re a night owl like me the first thing you do when you crank up your laptop at night is to bust down the brightness down to minimum to save yourself some eyestrain. After coming across a page showing The Best Of Linux Software I saw mention of a program called redshift. Redshift makes your screen redder by adjusting the gamma curves, and thus making your screen easier to see.

bob@bob-laptop:~$ sudo apt-get install redshift libnotify-bin

(libnotify is not required to run redshift, but is used by the script below).

The ocular science behind this is straightforward – to quote Wikipedia:

In biological night vision, molecules of rhodopsin in the rods of the eye undergo a change in shape as they absorb light. Rhodopsin is the chemical that allows night-vision, and is extremely sensitive to light. Exposed to a spectrum of light, the pigment immediately bleaches, and it takes about 30 minutes to regenerate fully, but most of the adaptation occurs within the first five or ten minutes in the dark. Rhodopsin in the human rods is less sensitive to the longer red wavelengths of light, so many people use red light to help preserve night vision as it only slowly depletes the eye’s rhodopsin stores in the rods and instead is viewed by the cones.

Anyway, the utility is simple enough to use, but requires that it be launched from the command line. I don’t mind that at all, but I don’t want the hassle of having to do that. Instead what I ended up doing was writing a wrapper script for redshift that I placed on my Gnome panel which would effectively toggle redshift on and off when I click the icon. Here’s the script:

#!/bin/bash
# Redshift toggle script
# @author: Bob Brown, gurubob@gmail.com
# @blog: http://www.guru.net.nz/
# 
# Required packages: redshift libnotify-bin
 
# Lat/Long for Dunedin, New Zealand
LAT=-45.8
LONG=170.5
NOTIFYIMAGE=/usr/share/icons/Humanity/actions/22/object-inverse.svg
 
RUNNING=$( ps aux|grep redshift|grep -v grep|grep -v redshift.sh|wc -l )
if [ $RUNNING -gt 0 ]; then
	notify-send -i $NOTIFYIMAGE "Stopping Redshift" "Redshift is shutting down"
	killall redshift
else
	notify-send -i $NOTIFYIMAGE "Starting Redshift" "Redshift has been started with your location as per $0"
	/usr/bin/redshift -l $LAT:$LONG &
fi

You can see the script is straightforward and requires a little configuration – redshift requires your latitude and longitude as it adjusts the redshift of your screen based on the time of day, swinging between maximum redness at midnight and no redness during daylight hours (the website claims this, but I have not yet seen it as I’ve been running redshift for about an hour so far and it’s 12:13am). You can use this interactive map to find your latitude and longitude.

The shift to red is dramatic at first, especially going from the cool blue-white of maximum screen output but after a few minutes I find myself hardly noticing it at all. It will be interesting to see whether redshift finds a permanent place on my laptop.

By the way, there is a GTK front-end for redshift too and it works just as well. It allows you to toggle the application by right clicking the red lightbulb icon in the notification area of the gnome panel. Simply install it like so:

bob@bob-laptop:~$ sudo apt-get install gtk-redshift

and then place it into your startup applications in Gnome:

  1. System, Preferences, Startup Applications
  2. Click Add
  3. Enter “Redshift” for the name
  4. Enter /usr/bin/gtk-redshift -l YOURLAT:YOURLONG for the command (my command is /usr/bin/gtk-redshift -l -45:170, roughly)
  5. Click Add
    1. Presumably now redshift will start when you log in.

Wubi – the Windows Ubuntu Installer

So you’ve heard about Ubuntu and you’ve been interested but when you found out that it (can) completely replace your current operating system you thought better of it.  After all, the last thing you want to happen when you try a piece of new software is for you to lose everything.

Enter Wubi.  Wubi is a small installer program (about 1MB) that will install Ubuntu on your Windows computer (Mac and Linux versions are coming) that will install the whole operating system into a “container file” on your existing Windows hard drive. What this means for you is that there’s virtually no risk installing Ubuntu as if you don’t like it or if you want to go back to how things were you simply remove the Wubi application through the Windows control panel.

How it works:

  1. Wubi asks you where you want to install Ubuntu and how much disk space you want to give it
  2. Wubi then downloads an Ubuntu 10.04 ISO file
  3. The ISO file is unpacked into the container file along with grub (the boot loader that comes with Ubuntu)
  4. The Windows startup options are modified to include booting into Ubuntu as an option.
  5. Your PC restarts and the installation completes.

The performance of Ubuntu running in a container file is good – there will be overheads far greater than running native file systems like ext4 directly on the disk but as a no-risk introduction to Ubuntu for the Windows user, this is a great start.

As far as I know, the only thing that DOESN’T work in Ubuntu installed using this method is the hibernate support. Attempting to hibernating your Ubuntu desktop environment simply results in the screen being locked requiring your password to continue (presumably the hibernation failed).

Check out this YouTube video of Shawn Powers from Linux Journal installing Wubi (4:24s).

Happy Ubuntuing!

Using the Grid plugin in Compiz

Recently I’ve been introduced to the Grid plugin in Compiz – this is a fantastic little plugin that snaps your windows to predefined positions on the screen. After using it for the last couple of weeks I can’t imagine going back to not using it.

To get access to it you will need to install the compiz settings manager, and load Compiz’s “Fusion Plugins Extra”:

sudo apt-get install \
    compizconfig-settings-manager \
    compiz-fusion-plugins-extra

Once you’ve done this simply enable it:

  1. System, Preferences, CompizConfig Settings Manager
  2. In the Filter box in the top left, type in “grid”
  3. Tick the box to enable it and click “Close” (bottom left)

Now try using Ctrl-Alt and numbers on your keypad. CA-9 will snap a window into the top right corner (press it a few more times to get different sizes) and CA-8 will make it snap to the top half of the screen (the number is the position on the screen, you’ll get the gist of it).

Check out this demo video:

Happy Ubuntuing!

Cc and Bcc field size in Gmail

The Cc and Bcc field sizes in Gmail are too small to work with if you’re sending to more than about 20 email addresses. The following bookmarklet will increase their height when used:

javascript:(function(){var%20e=window.frames[3].document.getElementsByTagName('textarea');%20for(i=0;i<e.length;i++){%20if(e[i].name=='cc'%20or%20e[i].name=='bcc')%20{%20e[i].style.height='150px';%20}%20};})();

To install (in Firefox).

  1. Right click on your Bookmarks toolbar and choose “New Bookmark”
  2. Enter a name for the Bookmark, e.g. “Big Cc Field”
  3. Into the location, paste the above code
  4. Save the bookmark

Now when at Gmail and you can see the Cc or Bcc fields you can click the new Bookmark link to make them bigger.

To find out more about Bookmarklets, check out the Bookmarklet page on Wikipedia.

Mosgiel Centenary Celebrations – 1985.

I recalled an event I participated in back in 1985 which was the Mosgiel 100 year centenary parade. As a pupil of one of the local primary schools (Reid Park Primary) we were primed with dress of the era and a song that was nowhere near as bad as some radio jingles. We got to ride on a float down the main street, oh what joy!

“I’m a hundred year old kid – don’t you see,
I’m proud to see the end of our first century.
From 1885 through ’til 1985,
We’ll still be century children at our next centenary.”

Author unknown, can you help?

Walk To Work Day

Today was Walk To Work Day in Dunedin, an initiative spearheaded by Living Streets Aotearoa with the support of Sport Otago and the DCC. I decided to make the trip as the amount of excercise I get thanks to the extreme convenience of my scotter is minimal. I left home at 7:20 this morning and arrived in the Octagon at about 8:30 where a few stands were laid out for registration. The registration process was rewarded with a $7 voucher redeemable at Barakah, MASH, The Ra Bar, Alibi or The Craic. I chose MASH and a nice looking breakfast bap which was delicious, but unfortunately my order was forgotten in the rush of breakfast time cafe operations. After a reminder it turned up with an apology.

They say New Zealand is a small place and indeed it is – I ran into community advocates Frank Buddingh and Nina Arron from Lawrence who were on the registration stands. A familiar face was very much a welcome sight. I first ran into Frank and Nina some time ago when Frank was looking for an alternative provider for the Buddingtree Consultancy website.

For me the nicest thing (other than the fantastic weather!) about walking into town was it was a chance for me to “sit down” and listen to some podcasts. Listening to Leo Laporte, Jono Bacon and Randal Schwartz interview Jamie Cameron about Webmin on the FLOSS weekly podcast was a delight, especially as in my dark days I had a fair use for Webmin, so much so that I bought Jamie’s “Using Webmin” book.

Now that I have my walking method sussed all I need to do is load up my iPod and get an early night and a good sleep beforehand – unfortunately the early night and good sleep was thwarted last night by some jQuery and AJAX goodness and also by Zoe night-babbling, then Linus who woke up crying because “Ada ate my pie in a dream!” and then some more Zoe babbling. Things had quietened down by about 4am anyway.

Check out the local Channel Nine TV coverage at http://www.ch9.co.nz/node/14223

WordPress Themes