iconv script for converting character encodings

well the whole character encoding problems in the german language with utf-8 and iso-8859-1 is pretty tedious. a fine little program called iconv does the whole encoding changes pretty nicely but… (well there had to be a but huh?) you can’t switch encodings with input and output being the same file.
so moving/deleting/renaming makes it a little painfull.

i wrote a little script that does this for me, it’s really simple but simplifies everything.

#!/bin/bash
#
# Convert arguments handle different encodings
iconv -f $1 -t $2 "$3" -o "$3-new"
# Create backup
mv "$3" "$3~"
mv "$3-new" "$3"

i called it “econv” and instead of:
iconv -f iso-8859-1 -t utf-8 myfile.txt -o myfile_new.txt

then deleting the old file and renaming the new one, i just type:
econv iso-8859-1 utf-8 myfile.txt

which does the trick and even creates a “myfile.txt~” backup of the original.

put the script in your /usr/local/bin or whatever you prefer and you can use it globally.

resize a directory full of images using imagemagick

people wo have image galleries on the net know that the images that come from your digital camera are usually to big. even gallery scripts that do resize the images might fall into a timeout when uploading alot of images. i used to batch resize my images with a GIMP script, but why? i don’t know. using imagemagick is ten times simpler!

mogrify -resize 800x600 "*" *.jpg

easiest possible way to go…
and with the option -quality you can also set the quality… check out the mogrify man page for more information.

enabling desktop effects ubuntu 7.04 nvidia

well since ubuntu has the new little desktop-effects menu in system -> preferences i wanted to try it, but i kept getting this:
munzli@freddy:~$ /usr/bin/desktop-effects
modinfo: could not open /lib/modules/2.6.20-15-386/volatile/nvidia_legacy.ko: No such file or directory
modinfo: could not open /lib/modules/2.6.20-15-386/volatile/nvidia.ko: No such file or directory
modinfo: could not open /lib/modules/2.6.20-15-386/volatile/nvidia.ko: No such file or directory
nvidia hardware not available
Segmentation fault (core dumped)

my system has been upgraded from previous releases and already had beryl and compiz running before upgrading to feisty and has tons of dead entries and packages. the solution was actually quite simple, but here’s all the steps i did.

first i removed the nvidia restricted modules (as you can see i still had others from previous kernels so i removed them as well) and nvidia kernel drivers (this step is probably not necessary but i did it anyway to make sure)
sudo apt-get remove --purge nvidia-kernel-common linux-restricted-modules-2.6.15-23-386 linux-restricted-modules-2.6.17-10-386 linux-restricted-modules-2.6.17-11-386 linux-restricted-modules-2.6.20-15-386

then i reinstalled the packages (you can take the generic package but i used the 686 package since i have a P4 here at the office)
sudo apt-get install nvidia-glx-new linux-restricted-modules-686

make sure you have the nvidia specific stuff in your xorg.conf, if you don’t, the easiest thing to do is run:
sudo nvidia-xconfig --composite
sudo nvidia-xconfig --render-accel
sudo nvidia-xconfig --allow-glx-with-composite
sudo nvidia-xconfig --add-argb-glx-visuals

restart X and you should see the nvidia module, easiest check is running System -> Administration -> Restricted Drivers Manager. it should look like this (you only need the nvidia driver in there):
Restricted Drivers Manager

well i didn’t have it loaded at first and noticed that it was still missing the /lib/modules/2.6.20-15-386/volatile/nvidia.ko file, so in that directory i noticed the nvidia_new.ko so i just made a symbolic link:
ln -s nvidia_new.ko nvidia.ko

after that it still wasn’t working! well here’s the final and real step that made it work and you might only have to do this!

check the gconf-editor and make sure that no dead plugins are loaded, mine looks like this now:
active_plugins
mine still had “animations” and “3d” in there, and after removing animations it worked!

a nice way to waste some time ;)

if your cube doesn’t rotate, then also make sure that the key /apps/compiz/general/screen0/options/hsize is set to 4 or more. for others plugin go check the compiz site.

final shot

ubuntu dist-upgrade with an iso image

well since ubuntu feisty fawn 7.04 is out, i thought i’d go for the distribution upgrade… so i downloaded the iso.

upgrading through the online repositories usually is pretty time consuming so i wanted to upgrade through the iso without burning a cd, who needs cds anyways ;)

the only way i got this going was to mount the iso into a directory (in my case: /media/ubuntu)
sudo mount -o loop -t iso9660 /path/to/my/iso/ubuntu-7.04-desktop-i386.iso /media/ubuntu

then edit the sources.list in /etc/apt and replace “edgy” with “feisty” and add this line to the top
deb file:/media/ubuntu/ubuntu feisty main restricted

not very nice but the cdromupgrade is missing in feisty!

now do a:
sudo apt-get clean
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get -f install # optional
sudo dpkg --configure -a

HINT: “sudo apt-get -f install” is only needed if you get errors during the dist-upgrade.

for some reason i also needed to uncomment the normal “main/restricted” package source because it still wanted to download every package.
# deb http://archive.ubuntu.com/ubuntu feisty main restricted

if anybody has easier ways, please tell me!