XBindKeys – Fixing broken shift+tab+(key) shortcut in Xubuntu

xbindkeys-config window

For some reason, hotkey / application shortcut support for a keyboard combination such as Ctrl+Shift+(key) was broken back in Xubuntu 8.10 (and still is broken in 9.10…).

Needless to say, this issue is really annoying me as I used to assign keys like Ctrl+Shift+# (I have an British keyboard) for controlling Play/Pause in Banshee to enable one-handed operation.

Anyhow, I came across this application called "XBindKeys" on linux.com the other day, and now, with the help of XBindKeys, I can now use those hotkey combinations!

To install:

aptitude install xbindkeys xbindkeys-config

Then run xbindkeys-config to setup your hotkeys via a GUI.

XBindKeys is capabile of more things (such as extending hotkeys support for mouse buttons) – please see XBindKeys’ homepage for more information.

Convert emails from Outlook MSG to Thunderbird EML format using MSGConvert

Outlook MSG to Thunderbird EML conversion picture

Recently, I’ve had the need to convert a bunch of outlook MSG files to a format that Thunderbird can read (EML).

There are various ways of doing this according to this article on kb.mozillazine.org, but I have chosen the MSGConvert method so I can script the conversion process.

To use MSGConvert, you’ll need the MSGConvert script along with its Perl dependencies (you’ll need to compile one if you are using Ubuntu/Xubuntu).



## Install all dependencies for "Email::Outlook::Message" - "Email-Outlook-Message-0.909"
aptitude install 
libio-string-perl    # Needed to pass "make test"

## Compile "Email::Outlook::Message"
wget http://search.cpan.org/CPAN/authors/id/M/MV/MVZ/Email-Outlook-Message-0.909.tar.gz    # From http://search.cpan.org/~mvz/Email-Outlook-Message-0.909/lib/Email/Outlook/Message.pm
tar -zxf "Email-Outlook-Message"*".tar.gz"
cd "Email-Outlook-Message"*
perl Makefile.PL
make test
sudo make install

## Note: To uninstall
# cd "Email-Outlook-Message"*
# sudo make uninstall
# aptitude purge .....

## Install dependency "Email::LocalDelivery"
aptitude install libemail-localdelivery-perl

## Install msgconvert.pl
wget 'http://www.matijs.net/software/msgconv/msgconvert.pl' -O msgconvert.pl
sudo mv msgconvert.pl /usr/bin

MSGConvert usage

Once installed, you can convert a single message by doing:

msgconvert.pl some_message.msg

# Please note the script chucks out a file with a .mime extension, it's an easy fix:
mv some_message.msg.mime some_message.eml


Alright, let’s automate it a little bit. Here is what I used to convert a bunch of msg files to eml:



if (( $(echo "$1"|grep -icE "^-[-]?(help|h)$")==1 || $#==0 )); then
	Wrapper script for msgconvert.pl.
	msgconvert.pl throws out the converted eml files in current directory and with the wrong extension...
	I suppose I ^could^ just edit msgconvert.pl...  Meh...

	$(basename "$0") msgFile1.msg [msgFile2.msg] [msgFile3.msg]...

	$(basename "$0") messages/message1.msg messages/message2.msg messages/message3.msg
	find "emails/2009" -iname "*.msg" -print0|xargs -0 $(basename "$0")
	exit 0

## Convert each message specified
for message in "$@"; do
	# Test to ensure it has a .msg extension (I ^could^ do a "hd|grep" test or add a "file" magicfile I suppose...  Again, meh...)
	if (( $(echo "$message"|grep -icE ".msg$")== 1 )) && [ -f "$message" ]; then
		# Convert - we can only do this one at a time
		echo "INFO: Converting: "$message""
		"$MSGCONVERT" "$message"
		if (( $? != 0 )); then echo "EXCEPTION: Encountered problem(s) at "$message"."; fi
		# Move the converted message to its original directory, changing extension at the same time
		#echo "DEBUG: mv "$(basename "$message".mime)"" ""$(echo "$message"|sed -e 's/.msg$/.eml/i')""
		mv "$(basename "$message").mime" "$(echo "$message"|sed -e 's/.msg$/.eml/i')"

Happy converting!

MPlayer resume script (v2-alpha)

MPlayer logo

A while back I attempted to write a wrapper script for mplayer to resume a file. Unfortunately, that script was rather limiting where:

  • File name must be first entry
  • You have to manually specify the "-profile" parameter
  • You cannot specify a global profile (i.e. the profile you specify only applies to the last file)

Now I have a new script that resolves the above issues! Unfortunately, there are some new issues with the new script:

  • It’s slow at generating command for many files
  • Extension-less file won’t work…
  • Per-file manual profile definition is not yet implemented – though automatic RegExp profile definition is working :-P !
  • This script is very much in the alpha stage and more testing is needed – so use at your own risk!

Sounds cryptic? It’ll be clearer after I’ve shown you some examples.

As with the previous script, an example usage (we’ll assume we’re trying to resume a file called "mediaFile.avi" at timecode 300, and the script is named "mp"):

echo 300 > mediaFile.avi.txt
mp mediaFile.avi

Also as with the previous script, you’ll probably want to enable the "statusline" display by adding "msglevel=statusline=9" into your mplayer config file (at "~/.mplayer/config" | "/etc/mplayer/config"), and ensure "quiet=0".

Now, to use a profile for all files (at the moment, it doesn’t matter where you place "-profile" and "-ss" – they just get applied to every file…):

mp -profile hd file1.avi "file 2.avi"

However, the real magic of the v2 script comes into play when you have multiple files, matching multiple profile switching definitions, with different resume files! For example:

$ ls -d *.avi*
2x03 SomeEpisode.mkv
2x03 SomeEpisode.mkv.txt

$ less mp
	# [PF name]	[RegExp]
	"hd"	"(/|^)[0-9]{,2}x[0-9]{,2} .*.mkv$"
	# ---- Generic profiles ----
	".mts"	".mts$"

$ mp file1.mts "2x03 SomeEpisode.mkv" file2.avi

The script will now use the ".mts" profile for the mts file, the "hd" profile for the .mkv file, the "global" profile for the .avi file, whilst picking the values out of the resume files and resume at the point specified in the .txt files!
(Just in case you’re wondering, the "global" profile is defined in the "$defaultProfile" variable in script.)

Anyway, you can get the script here.

Of course, if anyone’s interested in improving it, they’re more than welcome to do so! Just don’t forget to email me a copy!

MPlayer resume script

MPlayer logo

I might as well share this – below are 2 scripts I’ve written for MPlayer to resume playback at a position saved in a text file.
(Note the scripts below also attempt to load the "global" profile – I use it for chaining profiles – i.e. I have other profiles that includes "global".)

It works by appending the "-ss" parameter to mplayer when a resume file, in the format "[mediaFileName.ext].txt" is detected.

An example usage (we’ll assume we’re trying to resume a file called "mediaFile.avi" at timecode 300, and the script is named "mp"):

echo 300>mediaFile.avi.txt
mp mediaFile.avi

You’ll probably want to enable the "statusline" display by adding "msglevel=statusline=9" into your mplayer config file (at "%ProgramFiles%/MPlayer/mplayer/config" | "~/.mplayer/config" | "/etc/mplayer/config"), and ensure "quiet=0".

Windows installation:
0 – Get a copy of "grep" and "head" somewhere – such as UnxUtils.
1 – Save script as mp.bat (or something simple to type)
2 – Put into a directory in your %PATH% env. variable.
3 – Play files using the "mp" command, and create resume file as specified in example above.

@echo off

set mplayerbin=%ProgramFiles%MPlayermplayer.exe
set cli=

FOR /F "usebackq delims==" %%c IN (`echo %*^|grep -c -i " -profile "`) DO set count=%%c
if !count! == 0 (
	set cli="!mplayerbin!" -profile global %*
) else (
	set cli="!mplayerbin!" %*

REM Resume stuff - this'd only work if filename is specified as first argument.
FOR /F "usebackq delims==" %%c IN (`echo %*^|grep -c -i "-ss"`) DO set count=%%c
set resumeFile=%1.txt
if exist "!resumeFile!" (
	if !count! == 0 (
		FOR /F "usebackq delims==" %%c IN (`head -n 1 "!resumeFile!"`) DO set pos=%%c
		set cli=!cli! -ss !pos!

echo ^>^>^>^> !cli!


Linux installation:
1 – Save script as mp (or something simple to type)
2 – Put into a directory in your $PATH env. variable.
2 – chmod +x mp
3 – Play files using the "mp" command, and create resume file as specified in example above.


# Script to launch mplayer and resume if [filename.ext].txt exists
# TODO - Integrate the new parser into the old windows script below


# Unfortunately, something simple like: for i in $*; do echo $i; done
# doesn't work with spaces (even when it's escaped) - it'd separate parameters out by space...
# This also assumes the first argument with a space is the filename
while ((i < argc)); do
	# escape spaces - can't use <code>echo $1|grep " "</code> or it'll display the params...
	if [ "$(echo $1|grep -cE "[ ()$]")" == 1 ]; then	# Any others?
	shift; ((i++))

# Old windows port of the script below
count=$(echo $cli|grep -c -i " -profile ")
if [ $count == 0 ]; then
	cli="$mplayerbin -profile global $cli"
	cli="$mplayerbin $cli"

# Resume stuff - this'd only work if filename is specified as first argument.
count=$(echo $cli|grep -c -i "-ss")
# -f ensures the file (not directory) exist
if [ -f "$resumeFile" ]  && [ $count == 0 ]; then
	pos=$(head -n 1 "$resumeFile")
	cli="$cli -ss $pos"
echo >>>> $cli
eval $cli

There is however a bug in the Windows version due to the use of delayed expansion – if you have a file with an exclamation mark, you’d need to escape it with "^^" (e.g. "^^!").

Also, it’d be a good idea to specify the filename as the first parameter – I haven’t done any extension check to figure out which parameter the filename is at.

You can find more information about the command-line parameters for MPlayer at:

Update: 2008-07-10 @ 03:54
I’ve made a new version – v2-alpha. The new post is here

XP SP3 is out!

Software recommendation: Visual Task Tips

Visual Task Tips icon - click to go to author's website.
Here’s a utility I’m sure you’ll like – it’s called Visual Task Tips.
This application runs in XP / Vista and provides a preview for each window "task" on the taskbar:
Before and after
Version 3 adds the essential preview delay customization – now you can make the preview appear immediately!

Upgrading Xubuntu 7.04 to 7.10 (CD-ROM execution error)

Just in case if you see the following error when you run the Xubuntu upgrade:
$ sudo /media/cdrom/cdromupgrade &
sudo: unable to execute /media/cdrom/cdromupgrade: Permission denied
You’ll need to unmount and re-mount the CD as executable (-oexec):
$ umount /media/cdrom0
$ sudo mount -oexec /dev/cdrom /media/cdrom0/
Now… let’s hope the rest of my upgrade goes smoothly – with my (lack of) Linux knowledge, it’s gonna be a long night if it doesn’t…
(Oh, and by the way, you’re supposed to run the upgrade when you’re logged in normally – I was under the impression that you have to boot from the alternate CD for some reason…  But I guess if you’ve found this page, you’ve already got that part right…)