Category: linux

Adjusting the screen DPI in Ubuntu

My laptop has a screen resolution of 1280×800 (it’s a 16:10 ratio widescreen). Sometimes it seems that the screen is a little crowded. Fortunately on most operating systems there’s a solution – adjust the screen DPI to get more pixels per inch.

The simplest way to do this in Gnome (the default window manager for Ubuntu) is to go into the following:

  1. System, Preferences, Appearance
  2. Click on the Fonts tab
  3. Click on the Details button in the bottom right
  4. Adjust the “Resolution” value.
The default value is 96 – I find that 84 is a good number for me, but even down at 70 the text is still very readable.

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!

LCA2010 – a first timers overview

Well, LCA2010 drew to a close here in Wellington yesterday with the final event being the Penguin Dinner just after Brisbane was announced as the next host city for LCA2011.  The preceding week has been a great chance for geeks to meet, hack, discuss, debate, fix, help, recruit, teach and share with other geeks.  A wide range of geekery was represented, from Linux kernel hackers, to source control experts (notably representatives from the GitHub and Ubuntu Launchpad projects), to documentation lovers (yes, they exist, I saw some!) all the way down (or up?) to hardware hackers soldering together Arduino/Pebble kits and developing technology to win the Lunar X Prize (hello, Lunar Numbat).

For me, the highlights of this week have been:

  • Seeing HTML5 support for the Video tag, and in particular seeing realtime video processing with Javascript (example here)
  • An overview of Drupal 7 by Webchick including writing a sample “Pirate Module”
  • Various presentations by Paul Fenwick, including a piece of social genius, a proposed Facebook application called “AntiSocial” (keep an eye on his blog for more info)
  • The LCA2010 Hackoff organised by the Wellington Perlmongers group – our team did well, answering 3 out of the 6 questions (with the solution to #4 arriving minutes after the contest has closed)
  • The Pengiun dinner, where some* Epic Beer was consumed (Epic were a sponsor of LCA2010) and a whopping $33,000 dollars was raised for the Lifeflight Trust at the charity auction (winning prize was a trip for four on the rescue helicopter with some good old fashioned winching on 8mm steel cable)
  • An overview by  Patrick Brennan from Albany Senior High School (a new school) where he spoke about the massive savings they made by choosing to go completely open-source for their new school.  It was a delight to see the passion that the entire board has for the philosophy of free software.
  • Following and contributing to the vibe of the conference in realtime with Twitter via the lca2010 hashtag

Everything worked very smoothly with the conference venue being more than adequate and with power and internet access never being an issue, although there were a few times where I had to charge my iPod from my laptop battery.  Each session was streamed live and the archived videos will be available at a later stage once they’ve been processed and made available online.

Also, being able to stay with Adam and Amy was a great advantage with their apartment being only about three blocks from the Wellington Convention Centre and right on Courtenay Place.

Finally, a heartfelt thanks to Andrew and Susanne for organising the conference, and to the hordes of crew, support people, volunteers, ghosts and incidentals who made the event such a pleasure to attend.

* Ok, way too much :)

FogBugz “Active Project” notification tool

At Turboweb we’ve recently subscribed to a 5-user on-demand license for an awesome case tracking system called FogBugz.  For us it means that we have controlled workflow of cases (bugs, features, enquiries etc.) along with awesome estimation reporting and time tracking.  FogBugz was built with development teams in mind and it’s a very nice tool.

Anyway, one of the things it has is a nice API which you can use to interrogate the product (read and write) and this got me thinking about how I could use the API to remind me what I should currently be working on.  Thus was created the “FogBugz Notification Tool”.

This script does the following:

  1. Connects to your FogBugz installation
  2. Runs a query to see what things have been worked on today
  3. If there are any items that don’t have an end date, then it’s the case that’s currently being worked on
  4. Get the details of the case
  5. Use notify-send to pop up a notification bubble showing case number, title, estimated time and time remaining.

FogBugz Active Case Notification

I have found this most effective if I put it in my crontab to run every 5 minutes.

Requirements:

  • Ubuntu Linux (or any version of Linux that supports the “notify-send” command)
  • PHP5 CLI (simply because this script is written with PHP)
  • The “libnotify-bin” package (this provides the “notify-send” command, try “sudo apt-get install libnotify-bin”)

The script requires a little configuration for your circumstances, but this is easily done by editing the defined constants in the script:

	// Adjust these defines to suit your installation
	define( 'FBBASEURL', 'https://mywebsite.fogbugz.com/' );
	define( 'FBUSERNAME', 'my@email.address.com' );
	define( 'FBPASSWORD', 'mypassword' );

And to add it to your crontab, simply add this line (note the */5 means every time the current number of minutes in the hour is evenly divisible by 5)

*/5 * * * * DISPLAY=:0.0 /usr/bin/php /home/bob/fogbugz-notify.php

Of course, adjust the path appropriately.

Ubuntu and Lightning – not working, application seems buggy?

I’ve switched over to running Ubuntu 8.10 full time at work now.  The only things I miss are TortoiseSVN and the application integration with the desktop (Thunderbird/W32 for example lets you drag attachments onto the desktop).  Oh, and I miss TimeSnapper (classic – free download) too, but will get off my chuff and work out an alternative using Xwd.

Anyway, at work we use the Lightning calendar plugin for Thunderbird, with the Google Calendar provider in order to collaborate on a calendar.  For the most part this works well as when not in the office you can fall back to Google Calendar.

I went down the path of installing Lightning into Thunderbird (download the XPI, browse to it etc…) but after the installation Lightning seemed broken.  The UI was mostly there but it looked buggy and nothing worked.  After hunting around for a reason, I came across this thread that suggested that the problem was that the libstdc++5 package had to be installed.

I was skeptical, but after reading half a dozen “me too” posts where the problem had been fixed I got stuck in.

  1. Uninstall the Lightning plugin from Thunderbird
  2. Open a terminal, and run this command: sudo aptitude install libstdc++5
  3. Reinstall Lightning from the XPI you downloaded

Then things came to life nicely.  I was disappointed that the state of Lightning without libstdc++5 appeared to be a buggy application rather than a specific error.

WordPress Themes