Enabling UK Freeview TV in Totem (2.22 or above)

23 June, 2008

This guide assumes that you have a DVB TV tuner that is supported in Linux. Check here to see if your card is supported.

First, visit the freeview site to find your nearest transmitter. Type in your postcode and the transmitter is listed in the panel on the right.

You’ll need to make sure ubuntu-restricted-extras and dvb-utils are installed:

sudo apt-get install ubuntu-restricted-extras dvb-utils

Finally, type the command below to scan your nearest transmitter for channels. Ensure you replace “uk-Oxford” with “uk-” and the location of the transmitter that the freeview website listed:

scan /usr/share/doc/dvb-utils/examples/scan/dvb-t/uk-Oxford > ~/.gstreamer-0.10/dvb-channels.conf

If this process does not complete, try a different transmitter location.

Start Totem, and you should be able to select Movie -> “Watch TV on ‘DVB Adapter 0′” in the top menu to start watching TV. The channels will be listed in your playlist panel.

An alternative to using Totem is a Gnome TV application called “MeTV”, which is more geared for TV viewing. The trade-off is that it is less integrated with the Ubuntu desktop, and some people may also find the mouse-only interface frustrating. I recommend you try both and pick the one that suits you.


Relocating your existing F-Spot photo store (e.g. ~/Photos to ~/Pictures)

30 January, 2008

This howto allows you to move your entire photo store to a different location, and instruct F-Spot to use this new path without re-importing photos and risking data loss:

QUIT F-SPOT FIRST!!!

1. Move the photo store where you want it to be (if you haven’t done so already!)

2. Back-up your F-Spot database

cp ~/.gnome2/f-spot/photos.db ~/.gnome2/f-spot/photos-backup.db

3. Install and start sqlite

sudo apt-get install sqlite3
sqlite3 ~/.gnome2/f-spot/photos.db

5. Perform an update command against the “photos” table. Make sure you set the paths to match your own

update photos set directory_path = '/NEW/PATH' || substr(directory_path,length('/OLD/PATH/'),length(directory_path)) where directory_path like '/OLD/PATH/%';

Example:

update photos set directory_path = '/home/sean/Pictures/photos' || substr(directory_path,length('/home/sean/Photos/'),length(directory_path)) where directory_path like '/home/sean/Photos/%';

6. Quit sqlite

.quit

From here on, assuming these steps worked, you should be able to start F-Spot and all your photos are still found!

***
If something went wrong, you can revert to the old database by moving the photos back where they were, and running this command:

mv ~/.gnome2/f-spot/photos-backup.db ~/.gnome2/f-spot/photos.db
***

NOTE: F-Spot appears to rebuild it’s thumbnail cache when you start it the first time after doing this, you will notice that all the photos have no images. Leave it for a few minutes and you should find all the photos will eventually flood back into existence.

Thanks to http://nozell.com/blog/2006/07/02/moving-photos-around-behind-f-spots-back/ and http://www.itjungle.com/fhg/fhg040506-story02.html for pointers.


Using update-alternatives with Subversion and Apache

3 September, 2007

One of the complications I have had with Apache and Subversion is working out the best way of switching between branches and making them visible in Apache. At first, I was checking out a branch, deleting and replacing it in the same location so that Apache could pick up the branch I wanted. This was really slow and could be problematic if some of a directory was not committed for whatever reason.

My original solution to this was to maintain virtual hosts for every branch, using a separate port for each one. However, this meant that I then had to keep an index of which branch was on which port, and updating all of this each time I created/checked out a branch was a big overhead.

I have now found a neat solution using the Debian/Ubuntu program update-alternatives. This program is very easy to configure, and scales well for what I am trying to do. It also allows me to put all branches for a website project on a single port. These instructions assume you already have a working Subversion repository and have a basic understanding of how to use Subversion and Apache in Debian/Ubuntu:

1. Create a Subversion workspace for your projects, if you do not already have one. NOT “/var/www”, we will be using that for something else. Use something like “/home/myself/workspace”.

2. Check-out your trunk/branches in this workspace directory, try to keep each project contained in a sub-directory for clarity:

$ mkdir ~/workspace/myproject; cd ~/workspace/myproject
$ svn co /path/to/repo/trunk
$ svn co /path/to/repo/branches/testing
$ svn co /path/to/repo/branches/1.x-release

2. You should now have a project directory containing the project trunk, and some of your branches:

~
| -workspace
|- myproject
| – trunk
| – testing
| – 1.x-release

3. Install each project branch into update alternatives, using “/var/www” as the target for the alias. Note the numbers at the end, they represent the priority of each entry (how far up the list they are); incrementing them by 10 leaves you space to include entries further up the list more easily:

$ sudo update-alternatives --install /var/www/myproject myproject /home/myself/workspace/myproject/trunk 10
$ sudo update-alternatives --install /var/www/myproject myproject /home/myself/workspace/myproject/testing 20
$ sudo update-alternatives --install /var/www/myproject myproject /home/myself/workspace/myproject/1.x-release 30
$ sudo update-alternatives --config myproject

There are 2 alternatives which provide `myproject’.

Selection Alternative
———————————————–
* 1 /home/myself/workspace/myproject/trunk
+ 2 /home/myself/workspace/myproject/testing
+ 3 /home/myself/workspace/myproject/1.x-release

Press enter to keep the default[*], or type selection number:

— PRESS ENTER AT THIS POINT FOR NOW —

4. Hopefully you should be starting to see the advantages of this approach. At any time, you can type “sudo update-alternatives –config myproject” and you will be able to select which project branch will be provided to Apache.

5. Configure Apache to look at /var/www/myproject. That’s it.

When you want to add a new branch, you need to check it out as described above, and use the “update-alternatives –install” command to include it in the list.


Walk-through: Setting up GP2XSDK in Linux

10 March, 2007

This walkthrough was tested in a clean install of Ubuntu Fiesty, though there should be no reason for it not to work on most flavours of Linux. The intention is to run you through a no-frills install of the official SDK, configuring the environment to use it, and finally test compiling some demo code. There is plenty of scope for improvement, such as moving the SDK directory out of the filesystem root, but this will get you up and running quickly so you can start experimenting.

Final point: I performed my installation in a virtual machine. This is completely personal preference, but I recommend it as you will be keeping the GP2X development environment separate from your main system, if things go wrong and you want to start afresh, you can just delete the image and create a new one. There are no uninstall scripts for the SDK and it copies files to the root of your filesystem, which some can find messy. Again, this is a preference thing.

Onto the walk-through!

1. Install dependancies for SDK

~$ sudo aptitude install subversion build-essential

2. Ensure /bin/sh symlink points to /bin/bash

The SDK install scripts expect /bin/sh to be pointing to the /bin/bash shell, but Debian-based distro’s often point to /bin/dash instead – check this with:

~$ ls -l /bin/sh

If the output looks like “/bin/sh -> /bin/dash” you will need to do the following:

~$ sudo mv /bin/sh /bin/sh-original

~$ sudo ln -s /bin/bash /bin/sh

3. Get the SDK

Download at: http://dev.gp2x.com/sdk/gp2xsdk_linux.tar.gz and extract the archive.

(Contact me if this link is bad)

4. Run the install script

~$ cd gp2xsdk_linux

~$ sudo ./buildgp2xtools.sh

5. Go make a cup of tea, this will take a while…

6. Once complete, revert /bin/sh to original (skip this step if you didn’t need to do step (2))

~$ sudo rm /bin/sh

~$ sudo mv /bin/sh-original /bin/sh

7. Copy the SDL libraries into /gp2xsdk

~$ sudo tar –directory=/gp2xsdk/ -zxf gp2x-library.tar.gz

8. Create a user account to develop for GP2X on (you will need to “su gp2xdev” before you start coding for GP2X)

This ensures your normal account still allows you to use the normal GNU toolchain for your system

~$ sudo adduser gp2xdev

I advise you continue to use a secure password for this account, this ensures that any privileges you give it do not compromise the system. Next, we will switch to the GP2X development account, and configure the PATH environment variable to use the SDK toolchain:

~$ su gp2xdev

~$ echo “export PATH=/gp2xsdk/Tools/arm-gp2x-linux/bin:\$PATH” >> ~/.bashrc

9. Exit the account and switch to it again, this will apply the new PATH

~$ exit

~$ su gp2xdev

10. You should now be using the SDK toolchain

Test by typing “g++ –version”, The first line should read “g++ (GCC) 3.4.6″.

11. Download the demo code from:

http://wiki.gp2x.org/wiki/Source_code_to_a_Demo_Program

12. You will also need an 8 bit bitmap image

Create an bitmap image that is 320×240 pixels in size (this will fill the screen) with a 256 colour index.

Save it under the name “image.bmp”.

13. To compile the demo, navigate into the directory containing demo.c and use this command:

~$ gcc demo.c -I/gp2xsdk/include/SDL -L/gp2xsdk/lib -lSDL -o demo.gpe

14. Copy the files onto an SD card

Copy the bitmap image onto the ROOT of your SD card (ensure it is named “image.bmp”, as this is what is defined in the example code)

Copy the compiled “demo.gpe” program anywhere on your SD card

15. Fire up your GP2X, navigate the menu to Games->SD Memory Card, then find and run your “demo” program.

If all goes well you should see the image appear on the screen. Press any button to exit back to the menu.

N.B. If instead the program hangs, you have probably not placed the bitmap image in the right place or named it correctly.

Good luck!


Extending Nautilus

9 March, 2007

I was getting tired of having to switch to command-line every time I was using the Nautilus file manager and wanted to do something that required superuser permissions. It was becoming a real limitation for me, but instead of just switching to another file manager (which usually means less seamless integration with the desktop environment) I looked into how I could extend Nautilus to do what I wanted it to do.

I came across the site http://g-scripts.sourceforge.net, which provides scripts that Nautilus can offer in it’s right-click menu. This is an amazing feature that really hasn’t been talked about nearly enough. You can essentially download or make a shell script that performs any actions on the directory that Nautilus has open, or files or directories that you have selected. You can get Nautilus to do anything from mounting an ISO, to changing the file permissions of a batch of files in a directory at once.

The script that helped me was http://g-scripts.sourceforge.net/nautilus-scripts/ Execute/Misc/root-nautilus-here. This script allowed me to right-click inside a directory window, and select an option I called “Open Root Window”, this requested my password, and opened a new Nautilus window in my current directory with superuser privileges. Exactly what I needed.

To add a script to Nautilus, you need to copy the script and paste it into a file inside the /home/[yourname]/.gnome2/nautilus-scripts/ directory. The name you give the file will become the name in the right-click menu, so make it a readable one. You can also put the scripts into sub-directories, which is useful if you end up with a lot of them. Once you have done that, you need to make it executable for your user. This could be done using the Right-click->Properties->Permissions in Nautilus, or via the command-line (chmod 700 ~/.gnome2/nautilus-scripts/[scriptname]).

That should be it! Right-click on a file and you should see your script appear in the “Scripts” sub-menu that appears.

If you decide to make any scripts, look to the G-Scripts site to help you get started. Often you can just tweak the scripts offered by the site to do what you want. Remember the script will be invisible, so use ” zenity –info –text=”debug text” ” commands throughout your script to debug it until everything works properly.


Minty Ubuntu

4 March, 2007

I recently came across a new Ubuntu-derived distribution called Linux Mint at http://linuxmint.com. It’s designed to be fully compatible with Ubuntu (which I guess means you can use the Ubuntu repo’s alongside the Mint ones) but focuses on a faster release cycle and providing more bleeding-edge software. It also takes a more liberal stance on the free-software policies enforced in the Ubuntu community, including proprietary software and drivers “if a proprietary component has no suitable open source alternative and is needed to produce an elegant desktop” (see website).

I’m interested to see how this distribution pans out. I feel it’s unlikely to cause a storm, such a fast release cycle is impractical for most purposes, while Ubuntu has a strong community base and evolving in a steady but flexible rate, making it a safe yet exciting distribution suitable for most desktop environments. Bearing that in mind, Linux Mint might be very useful for providing to the current void that will eventually be filled with Grumpy Groundhog (https://wiki.ubuntu.com/UbuntuDownUnder/ BOFs/GrumpyGroundhog), as the quick release cycle would make testing of the latest applications easier. It may also provide an indication of the implications in providing proprietary software into Ubuntu, currently a subject of much importance and disagreement in the Ubuntu community.

The minty theme looks neat too, I look forward to trying it out and seeing what it can do ;)

*** Congratulations to the newly-weds Marvin and Stacy! ***


Tips for general use of the command-line

28 February, 2007

I don’t claim to be a veteran command-line user, I still need to crack open the books when I want to write anything but a very basic script. However, like most Linux users, I often need to fire up a terminal to do something – whether it’s the desktop that has failed me, or that I just want that bit of extra speed. Here are some tips I’ve accumulated over my short time in the command-line. They are open to suggestions and opinions, I’m fairly open-minded about the whole thing (a clear indication that I haven’t been doing it for long!).

Never use apt-get, always use aptitude

Aimed at Debian/Ubuntu users. This is a hard habit to kick, but aptitude is much more user-oriented, the commands are nearly identical to apt-get, and most importantly it resolves dependencies more effectively both during installation and on removal of software. I started forcing myself by creating an alias in my session, sounds unproductive but it definitely helped me to remember which program I should be using.

Add the following line into your ~/.bash_aliases file: “alias apt-get=aptitude”.

Use Vim

At first glance, Vim (Vi-Improved) looks like the most clunky unproductive text editor ever devised, and to start with it is. However, if you persevere with it, the rewards are huge. The functionality behind Vim rivals most GUI text editors, and if you take time to learn the standard control keys (such as h,j,k,l for moving the cursor), you find it becomes much faster to use. Plus it starts instantly, like Windows Notepad on steroids.

Oh, and Emacs is nice too ;) Though I feel Vi gets you further in the command-line, and it can be found everywhere.

Less is More

Whenever somebody instructs you to read a file using “more”, or pipe stdout to “more” for easier reading, replace all occurrences of “more” with “less”. Less gives you much more control over page operations, including the ability to scroll back up a page, and search the output for a string. The commands are an identical sub-set to Vim, so well worth learning.

Get screen

Not an essential, but extremely useful at times. Screen is a small program that allows you to essentially split a single terminal into a number of virtual ones. At first (apart from a splash-screen) it looks like it hasn’t done anything. However, run a program then press “Ctrl-a” followed by “c” and you have a brand new terminal to work on, no need to push the program into the background! Press “Ctrl-a” followed by “n” to cycle between the 2 virtual terminals at will. There is much more to screen, check out the manual. Excellent for when you’re running a PuTTY session!

Learn regex

If you want to do anything sophisticated with the command-line, chances are you’ll sometimes need to use regular expressions. This I agree messes with the head a bit, but mastering regex will allow you to use grep, sed, and countless other programs more effectively. A bit of a hypocritical tip, considering I’m still learning regex properly myself, but still a perfectly valid one in my opinion.


God, not another one!

27 February, 2007

Here’s my new blog, hopefully I’ll start putting some interesting stuff in it soon.

My attempts at installing Xen on Ubuntu have been fruitless so far. Hopefully I will hear from the Ubuntu Xen team soon to clear up the issues I’m having with missing files in the kernel headers, but until then I’ll stick with the safer VMWare server. Been taking a look at KVM (a kernel-level virtualisation module that has been signed off recently by Linus), it looks very new and theres not a whole lot of documentation behind it yet, but sounds very promising.

I decided to give SymphonyOS another try today, a bit of a disappointment as far as I’m concerned, I was expecting it to have got much further since the last time I tried it out. Not sure if I’m just not giving it enough of a chance. I’m thinking if I get chance I might attempt to try out a new distro each week and give it a review here, but maybe I’m jumping ahead of myself here ;)

Finally, here are some  screenshots of my new desktop! I’ve recently changed to a dark theme, hopefully it will help me focus in the later hours ;)

Desktop screenshot 1   Desktop screenshot 2   Desktop screenshot 3