Like many people I use calibre as my ebook viewer. Yet, this program is slowly becoming a living nightmare. First is the root exploit. Second is the way that calibre wants to take over every single file. Almost all my files were defaulting to being opened in calibre. Why on Earth would I want an openoffice document opened in calibre? The creators of calibre think I do.
This obviously required fixing.
The file /usr/local/share/applications/defaults.list looks like this:
[Default Applications] application/x-sony-bbeb=calibre-gui.desktop;calibre-lrfviewer.desktop;calibre-ebook-viewer.desktop application/x-ruby=calibre-gui.desktop;calibre-ebook-viewer.desktop text/rtf=calibre-gui.desktop;calibre-ebook-viewer.desktop application/pdf=calibre-gui.desktop;calibre-ebook-viewer.desktop application/x-cbz=calibre-gui.desktop;calibre-ebook-viewer.desktop application/x-mobipocket-ebook=calibre-gui.desktop;calibre-ebook-viewer.desktop application/x-cbr=calibre-gui.desktop;calibre-ebook-viewer.desktop text/fb2+xml=calibre-gui.desktop;calibre-ebook-viewer.desktop application/vnd.oasis.opendocument.text=calibre-gui.desktop;calibre-ebook-viewer.desktop application/epub+zip=calibre-gui.desktop;calibre-ebook-viewer.desktop text/plain=calibre-gui.desktop;calibre-ebook-viewer.desktop text/html=calibre-gui.desktop;calibre-ebook-viewer.desktop application/xhtml+xml=calibre-gui.desktop;calibre-ebook-viewer.desktop application/ereader=calibre-gui.desktop;calibre-ebook-viewer.desktop application/oebps-package+xml=calibre-gui.desktop;calibre-ebook-viewer.desktop
This is a nonsense. It has been setup to open plain text, html and pdfs in calibre. How totally stupid! It needs editing. This is better:
[Default Applications] application/x-sony-bbeb=calibre-gui.desktop;calibre-lrfviewer.desktop;calibre-ebook-viewer.desktop application/x-cbz=calibre-gui.desktop;calibre-ebook-viewer.desktop application/x-mobipocket-ebook=calibre-gui.desktop;calibre-ebook-viewer.desktop application/x-cbr=calibre-gui.desktop;calibre-ebook-viewer.desktop text/fb2+xml=calibre-gui.desktop;calibre-ebook-viewer.desktop application/epub+zip=calibre-gui.desktop;calibre-ebook-viewer.desktop application/ereader=calibre-gui.desktop;calibre-ebook-viewer.desktop application/oebps-package+xml=calibre-gui.desktop;calibre-ebook-viewer.desktop
Then run sudo update-desktop-database. That seems to fix it.
Posted: 8 December 2011 @ 14:42 GMT
An educational institution wrote to me recently asking me to finish my degree. I ordered the prospectus and looked through the courses that passed themselves off as computer science. Very little of it was science and rest was even less about computers. In fact, I can know more and get better information by reading the right books and blogs.
It was interesting to see that others have a similar take on computer science education:
When I started college, it was as a computer science major. I thought I would use college mostly as a convenient way to learn some programming languages and strategies so I could get a degree and a job in the field. But I arrived already burnt out and ended up switching out after a semester, for two very different reasons.
The first is the state of technology today. We don’t deal with the machine; we don’t even deal with abstractions on top of the machine. We deal with layers of abstractions, layers piled so high you can’t even see where they end.
The other reason, of course, is that technology education is bullshit. I can pinpoint exactly the moment of my burnout: it was when, as a sophomore in high school, I used the conditional operator in a program for my AP Computer Science class and got marked down...
The school that asked me to complete my degree wants more students. To get them, it has dumbed its courses so that they appeal to any half-wit on the Interwebs with a pulse. The question for me is whether it's worth my time and money.
Permalink | Leave a comment, tiger
Posted: 17 October 2011 @ 14:11 BST
Recently my favourite terminal emulator got deleted from my system, because of the continuing problems I am having due to the non-functioning of KDE.
I came across this interesting discussion on the best terminal emulators. Here are the favourites:
Permalink | Leave a comment, tiger
Posted: 8 August 2011 @ 11:45 BST
Here's a simple dictaphone :) you can use from the command line.
sudo aptitude install sox
To record:
rec my_really_important_thoughts.wav
To play back:
play my_really_important_thoughts.wav
Permalink | Leave a comment, tiger
Posted: 21 July 2011 @ 10:52 BST
Everyone should learn sed, especially me:
sed '/use Moose::Policy/ d; /use Moose;/ a \ use MooseX::FollowPBP; \ ' lib/interestingfile.pm
and even better:
find lib -name '*pm' -exec sed -i '/use Moose::Policy/ d; /use Moose;/ a \
use MooseX::FollowPBP; \
' '{}' \;
In relation to sed the -i switch means amend the file in place. The 'd' command is delete the line with the preceeding match and the 'a' command means append the following line after the preceeding match.
Permalink | Leave a comment, tiger
Posted: 20 July 2011 @ 20:34 BST
When I use rsync to copy a directory structure I often use the avz options. The a option is key as it tries to preserve everything. It is equivalent to -rlptgoD.
When you are copying to a usb mounted vfat file system a a lot of these are inappropriate, particular, l, p, g, o and D.
So, in future when trying to copy a directory structure to a vfat file system I'll try this instead:
rsync -rtvz /source/ /destination/
Permalink | Leave a comment, tiger
Posted: 27 June 2011 @ 13:08 BST
The great hal-ectomy is still causing me problems. I found that usb vfat disks were being mounted twice at two different mount points.
This fixed the problem:
sudo aptitude remove halevt
Permalink | Leave a comment, tiger
Posted: 25 April 2011 @ 17:14 BST
Some media players can't play protected m4a's. This script converts the m4a passed on the command line to an mp3 that can then be copied to your selected media player:
#!/usr/bin/bash
#
# copy and convert
#
# Transcode m4a file to mp3
#
# This script is heavily based on the original here:
# http://www.minigeek.org/2007/07/linux-m4a-to-mp3-conversion-script
#
# Naturally, changes are licensed under the GPL
#
orig=$1
temp_wav=`tempfile --directory ~/tmp --suffix=".wav"`
mp3=`echo "$orig"|sed -e 's/\.m4a/\.mp3/'`
temp_trackinfo=`tempfile --directory ~/tmp --suffix=".txt"`
# deal with track info
faad -i ${orig} 2>$temp_trackinfo
sed -i '23s/unknown: /title: /' $temp_trackinfo
sed -i '24s/unknown: /artist: /' $temp_trackinfo
year=`grep 'date: ' $temp_trackinfo|sed -e 's/date: //'`
sed -i 's/unknown: iTunes/iTunes: iTunes/' $temp_trackinfo
genrecount=`grep -c 'genre: ' $temp_trackinfo`
unknowncount=`grep -c 'unknown: ' $temp_trackinfo`
if [ "$genrecount" -eq 1 ] && [ "$unknowncount" -eq 2 ]; then
sed -i '25s/unknown: /composer: /' $temp_trackinfo
sed -i '26s/unknown: /album: /' $temp_trackinfo
genre=`grep 'genre: ' $temp_trackinfo|sed -e 's/genre: //'`
fi
if [ "$genrecount" -eq 1 ] && [ "$unknowncount" -eq 1 ]; then
sed -i '25s/unknown: /album: /' $temp_trackinfo
genre=`grep 'genre: ' $temp_trackinfo|sed -e 's/genre: //'`
fi
if [ "$genrecount" -eq 0 ] && [ "$unknowncount" -eq 3 ]; then
sed -i '25s/unknown: /composer: /' $temp_trackinfo
sed -i '26s/unknown: /album: /' $temp_trackinfo
sed -i '27s/unknown: /genre: /' $temp_trackinfo
genre='other'
fi
if [ "$genrecount" -eq 0 ] && [ "$unknowncount" -eq 2 ]; then
sed -i '25s/unknown: /album: /' $temp_trackinfo
sed -i '26s/unknown: /genre: /' $temp_trackinfo
genre='other'
fi
title=`grep 'title: ' $temp_trackinfo|sed -e 's/title: //'`
artist=`grep 'artist: ' $temp_trackinfo|sed -e 's/artist: //'`
album=`grep 'album: ' $temp_trackinfo|sed -e 's/album: //'`
track=`grep 'track: ' $temp_trackinfo|sed -e 's/track: //'`
## convert to wav
faad -o $temp_wav $orig
## convert to mp3
lame --alt-preset 192 --id3v2-only --tt "$title" --ta "$artist" --tl "$album" --tg "$genre" --tn "$track" --ty "$year" "$temp_wav" "$mp3"
## clean-up
rm $temp_wav
rm $temp_trackinfo
exit 0
Permalink | Leave a comment, tiger
Posted: 20 April 2011 @ 13:45 BST
I've just spent hours trying to get a nfsv4 mount working, and one of the chief problems was that the documentation is not quite complete.
/nfs4exports,
nice and descriptive.
/nfs4exports hostname(rw,sync,fsid=0,crossmnt)should do.
/nfs4exports/hotsexyillegallydownloadedmusic hostname(rw,sync,fsid=1,crossmnt)
/etc/fstab:
/old/nfs/shares /nfs4exports/hotsexyillegallydownloadedmusic none bind 0 0
unhide option to your /etc/exports file, so:
/nfs4exports/hotsexyillegallydownloadedmusic hostname(rw,sync,fsid=1,crossmnt,unhide)
The last step is really important otherwise you get a 'stale nfs file handle error'. Why doesn't any of the documentation include this?
Permalink | Leave a comment, tiger
Posted: 14 April 2011 @ 14:10 BST
Don't mess around with graphical burners that get get in the way of your workspace. Simpler to use the command line:
growisofs -dvd-compat -Z /dev/dvd=/path/to/image.iso
And then while it's happening you can get on with your real work.
Permalink | Leave a comment, tiger
Posted: 4 April 2011 @ 12:29 BST
Like this:
nmap 10.0.0.0/24
Depending on your network setup.
Permalink | Leave a comment, tiger
Posted: 1 April 2011 @ 06:52 BST
You are not the root user (and therefore do not have access to blkid), but you want to determine were a particular disk or partition is mounted. You know it is a particular disk, because you have the UUID, which is the quasi-unique identifier for the disk:
mount | grep `readlink -f /dev/disk/by-uuid/xxxxxxxxxxxxxxx` | cut -d ' ' -f 3
Replace the x's with the UUID.
Permalink | Leave a comment, tiger
Posted: 30 March 2011 @ 20:09 BST
Do this:
dpkg --search /etc/udev/rules.d/* | grep 'not found'
Get this:
dpkg: /etc/udev/rules.d/z60_hdparm.rules not found. dpkg: /etc/udev/rules.d/025_logitechmouse.rules not found. dpkg: /etc/udev/rules.d/030_ifplugd.rules not found. dpkg: /etc/udev/rules.d/60-libsane.rules not found. dpkg: /etc/udev/rules.d/90-local.rules not found.
Find out that orphaned udev rules are making your life difficult.
Grrr.
Posted: 25 March 2011 @ 10:25 GMT
You run Debian Sid. You're on the cutting edge. It's where you like to be.
Recently, you found that USB pen drives and hard disks weren't being mounted, or if they were, no user other than root was able to write to them.
You wonder why. HAL, that mainstay of Linux over the last few years, is gone. ivman still appears in the package list, but is not used. The trusty gnome-volume-manager too has disappeared.
You know it's all udev. It's shiny. It's new. It controls the /dev directory and almost all hardware events.
If it's udev that is making your usb disks mount read-only. why?
You turn on 'debug' level logging:
sudo udevadm control --log-priority=debug
More information is now reported to /var/log/syslog. You see lines containing
/lib/udev/rules.d/60-persistent-storage.rules and
/lib/udev/rules.d/usbmount.rules. You conclude that the udev rules
are in /lib/udev
You examine, in particular /lib/udev/rules.d/usbmount.rules which
calls the usbmount script to handle the mounting of usb devices. You
become concerned that the usbmount package is no longer maintained.
But you check the source code. You are relieved to find out that
usbmount is a simple script that even you could maintain. You continue to use it.
You read the usbmount documentation, and the configuration options. You realise that the problem is VFAT, an extremely limited and quite rubbish format, that doesn't deal with permissions properly and that, therefore, no one in their right mind should use. Unfortunately, pen drives always use VFAT. You remember the proper way to mount VFAT disks.
You make the following changes to /etc/usbmount/usbmount.conf.
You replace the line:
MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime"
With this one:
MOUNTOPTIONS="noexec,nodev,noatime,nodiratime"
And you add this line:
FS_MOUNTOPTIONS="-fstype=vfat,gid=plugdev,dmask=0007,fmask=0117"
Users in the plugdev group can now write to pen drives and other usb VFAT formatted hard drives. You make sure you are in the plugdev group.
Permalink | Leave a comment, tiger
Posted: 24 March 2011 @ 14:30 GMT
There's nothing like an iPod; sleek, beautiful, pleasing to the eye, and totally useless thanks to Apple's insistence on trying to stop you doing what you want with your devices. Are the iPod touch and iPhone two of the most useless devices ever to come from a tech company?
I had previously managed iPods using the excellent gtkpod, but the iPod touch is a different matter. Unlike other iPods which just mount as disks, the iPod touch doesn't. Apple in their infinite idiocy decided to encrypt the iPod touch like they do all iPhones. The iPod touch and the iPhone are very similar; essentially the iPod touch is sort of an iPhone without the 'Phone' bit. I guess that just makes it an 'i'.
Here's what I learned by getting an iPod touch working with Linux.

Before we start, I need to mention that you need the fuse ("Filesystem in Userspace") kernel modules. You also need the ifuse package, which provides a means of communicating with iPhone type devices.
sudo aptitude install ifuse
You will probably also need to make a mount point for the iPod touch or iPhone. Make it somewhere sensible, like under the /media/ directory.
sudo mkdir /media/iPod
You must, must, must make sure that the mount point is writable by the user going to administer the iPod touch. There are lots of ways to do this, but I did:
sudo chown me /media/iPod
Now, make sure that your user is in the 'fuse' group. If necessary do:
sudo adduser me fuse
Once done log out and log in again. Make sure the iPod touch or iPhone is connected to the computer and mount it:
ifuse /media/iPod/
You can then unmount it by doing:
sudo umount /media/iPod
If on the other hand you do:
ifuse --root /media/iPod/
You get access to the iPod's root directory. Once you do that, you might be amazed at the elegance of the BSD base of the iPod's operating system. It's such a pity Apple cripples it.
It's cool if all that works for you, unfortunately, it didn't work for me. Instead I got the following error:
Failed to start AFC service 'com.apple.afc2' on the device. This service enables access to the root filesystem of your device. Your device needs to be jailbroken and have this service installed. Note that PwnageTool installs it while blackra1n does not.
Although I could browse the iPod file system, I could neither play, copy nor save files. In essence the iPod was useless unless I jailbroke it.

WARNING: DOING ANY OF THE BELOW MAY VOID YOUR APPLE WARRANTY AND COULD DAMAGE YOUR IPOD OR IPHONE
Jailbreaking sounds so cool, unfortunately it is totally legal in the US and throughout the EU so that little frisson of excitement that I got with the thought I might perhaps be skirting around the edge of the law, was totally unjustified. On the plus side, jailbreaking iPhones and iPod touches really gets up the nose of Apple, which certainly gave me a mild sense of satisfaction. Have I mentioned how much I hate Apple?
Most jailbreaking, also known as 'privilege escalation' applications are for Macs and some for Windows. But they do exist for Linux. The one I used was Spirit Jailbreak, which is an amazingly cool piece of software. Binaries aren't available only the source code. So it needs compiling and you need to install relevant developer libraries:
sudo aptitude install libgpg-error-dev sudo aptitude install libimobiledevice-dev cd ~/src/ # or wherever you like to keep source files git clone https://github.com/posixninja/spirit-linux.git cd spirit-linux make
Once that is done we have the spirit binary, which you run like this:
./spirit
The jailbreak worked like a dream for me. After running spirit the Cydia icon appears on the iPod desktop. Cydia is the app store for apps that Apple don't approve of. So, any self-respecting geek needs it.
On the iPod, touch the Cydia icon and navigate around until you find 'MobileTerminal' which gives you a command line on the iPod. Install it. Then find 'OpenSSH', which provides ssh software, obviously, and install that too.
Also, use the Cydia appstore to install afc2add to install the afc service to the iPod. When this is installed touch the "REBOOT" button.
Now that you have jailbroken the iPod, you need to change both the root password and the password of the sole user. The name of the user is 'mobile'. The root password is always 'alpine'.
To do this, touch the Terminal icon (which appeared when you installed MobileTerminal). A command line will appear as will a keyboard. On the keyboard type 'su' and give the root password ('alpine' if you weren't paying attention). Now type 'passwd', and you will be prompted to enter the new password twice. Now, type passwd mobile and choose a new password for the user.
At this point, the iPod touch or the iPhone is properly jailbroken and has been promoted from useless piece of electronic crap to interesting computing device.

There was still a problem. gtkpod could copy music files across to the iPod touch, but it couldn't write to the iPod database, so the iPod couldn't see the music that was on its hard disk.
Starting with the 2007 generation of iPods, libgpod needs an additional configuration step to correctly modify the iPod content. libgpod needs to know the so-called iPod "firewire id", otherwise the iPod won't recognize what libgpod wrote to it and will behave as if it's empty.
The first step to fixing this was to get the 40-character unique identifier for the iPod. On your Linux computer do:
lsusb -v | grep -i iSerial
Something like this should appear:
iSerial 3 2fffccffda5c69bc16ea3fc1e53537259ff4a514
The first 16 digits of this is the FirewireGuid. On the iPod there should be a Device/SysInfo file. If not we create it:
cd /media/iPod/iTunes_Control mkdir Device echo "FirewireGuid: 2fffccffda5c69bc" > Device/SysInfo
After doing all that, when I restarted gtkpod, everything was be working.
Using these steps I was able to get gtkpod to read and write to the iPod and I can add and delete music from this originally defective-by-design piece of machinery.
A big thanks to the writer of Spirit Jailbreak, to the developers of gtkpod, of fuse and of everything on Linux that make it possible to conquer Apple's products.

TIPS:
Posted: 8 March 2011 @ 21:36 GMT
The 'locale' system on every Linux computer is a way of customising the way certain things work.
It determines how numbers and currencies should be displayed, sets the paper size for printing, and the formats for time and date, amongst other things. In short, the 'locale' is a way to ensure a computer respects certain practices in certain countries or language communities.
The 'locale' system forms part of glibc, the GNU C Library, which is at the base of many pieces of software.
Like everything in Linux, it is possible to change the 'locale' files to suit particular tastes or practices. You might want to do this if, for example, you don't like the way dates are displayed.
I found that the information out there about locales and how to change is fairly sparse. Here I've gathered what I've found.
On Debian systems and perhaps most other forms of Linux, the local files are in /usr/share/i18n/locales/. All locales are named in the following way: xx_YY, where xx is a two character name for a language and YY is the two character name for a country. So en_US, will be the locale for English in the US, en_GB the locale for English in Great Britain and cy_GB the locale for Welsh spoken in Great Britain.
Typing 'locale' at the command prompt will give you a list of certain environment variables and their locale settings. The environment variable LC_TIME determines how the time is displayed, whereas the environment variable LC_NUMERIC determines how numbers are displayed, for example, what characters to use for the decimal point and thousands seperator.
If you use the 'locale' command with the 'k' switch, say locale -k LC_NUMERIC, you will get a list of names and values for select keywords. For example, if your locale is en_GB, the decimal_point keyword will be set to '.', whereas if your locale is set to fr_FR, it will be set to ','.
Why I got interested in locales was because of the way that dates were being displayed in the cs_CZ locale.
How dates and times are displayed is determined by the LC_TIME environment variable. The settings can be determined by doing locale -k LC_TIME. The settings that interested me are as follows:
The best way to change a locale, at least on my system, is to create a custom locale, using a file name containing '@'. So, if you want to amend the en_GB locale you copy it to something like en_GB@custom, then edit it.
There are a few notes on what to do here. These are the steps I recommend:
Now, you can set the custom locale as your default or put it in your profile file on a per user basis, or just at the command line: export LC_TIME=en_GB.utf8@custom.
More information:
Permalink | Leave a comment, tiger
Posted: 2 February 2011 @ 15:05 GMT
First determine what type of audio is in the flv file:
ffmpeg -i input.flv
There should be a line containing something like this:
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16
Now extract the audio:
ffmpeg -i input.flv -acodec copy audio.aac
Change input.flv and audio.aac appropriately.
Permalink | Leave a comment, tiger
Posted: 27 January 2011 @ 09:32 GMT
ffmpeg -i video.avi -target ntsc-dv video.dv
or
ffmpeg -i video.avi -target pal-dv video.dv
Permalink | Leave a comment, tiger
Posted: 25 January 2011 @ 19:44 GMT
ACPI administration advocacy advocacy advocacy opinion alsa amarok apache apple apt aptitude audio audo authentication automount avi awk bash BIOS boot business cache calendar calibre censorship commandline computerscience console cron cut database date debian degree design desktop development disk dpkg dvd economics education emacs email europe exim faad ffmpeg files firefox firewall flash foss freedom ftp fun fuse git gnumeric grep growisofs grub gtkpod hardware hardware html idiocy images installation ip iphone ipod iptables iso itunes ivman kde kernel keyboard knoppix lame laptop latex linux locale lockin longlines m4a microsoft mimetypes minitab mount mp3 mp4 mplayer multimedia music mysql network nfs nfs4 nmap openbox openoffice opinion opinion partition pdf perl php politics postgresql printing privacy programming rant remote rhythmbox rss rsync rxvt scp script scripting scsi security sed server shell siteadmin sitenews sitesoftware skype skype slackware sound sox spam spreadsheet ssh statistics subversion sudo svk swap t23 t43 terminal text thinkpad thunderbird time timezone ubuntu udev upgrade usb usbmount users uuid versioncontrol vfat video vnc windows wine wordpress wordprocessing X40 xwindows xwindows youtube