Saturday, December 30, 2006

Formatting SD Cards

MultiMedia Cards (MMCs) are automagically mounted after insertion. Formatting them is harder.

After finding that a 128MB MMC was reporting ~20MB total space, something was wrong and it was suggested to me that it should be reformatted. But I didn't know how. I knew the filesystem was FAT, but FAT what? FAT12? FAT16? FAT32? Was there a format option in Ubuntu?

I couldn't find a tool to format the card, so I listed my mounted devices and saw:

/media/HP43xCARD /dev/mmcblk0p1 on /media/HP43xCARD type vfat (rw,nosuid,nodev,quiet,shortname=mixed,uid=1000,gid=1000,umask=077,iocharset=utf8)

And the space reported as:

/dev/mmcblk0p1 122912 108064 14848 88%

So a shot in the dark with mkdosfs /dev/disk/by-label/HP43xCARD reveals a card that has a total capacity of 128MB.

Searching for "formatting cf cards" or "formatting sd cards" turns up nothing useful. But a search for "formatting mmcs" turns up the kernel driver documentation.

Wednesday, December 27, 2006

Adding 7zip Support

7zip support is not enabled by default in Ubuntu 6.10. But Nautilus does identify the file as compressed and to be used with the Archive Manager.

It even does this when the p7zip package is installed.

The Ubuntu Wiki was searched and no information was found, other than p7zip will be packaged with the next release. But a thread on the Ubuntu Forums lead to a link that had this to say:

Install p7zip-full and your problem will be solved :-)

file-roller doesn't like p7zip for some reason.

Tuesday, December 26, 2006

Reading eBooks

So I have some .lit eBooks that I find are for Microsoft Reader. That requires a .NET Passport account, so I'm not using that.

Is there an eBook reader for Linux? Yes! It's called OpenBerg.


Oh, that doesn't work with Firefox 2. So let's try openclit. There's no package for openclit, so it looks like I'm forced to compile it:

First, you need libtommath (available from math.libtomcrypt.com).

I also need to compile libtommath. So by my math that's two programs I must compile.

$ make
cc -I./ -Wall -W -Wshadow -Wsign-compare -O3 -funroll-loops -fomit-frame-pointer -c -o bncore.o bncore.c
In file included from bncore.c:1:
./tommath.h:18:19: error: stdio.h: No such file or directory
./tommath.h:19:20: error: string.h: No such file or directory
./tommath.h:20:20: error: stdlib.h: No such file or directory
./tommath.h:21:19: error: ctype.h: No such file or directory
In file included from /usr/lib/gcc/i486-linux-gnu/4.1.2/include/syslimits.h:7,
from /usr/lib/gcc/i486-linux-gnu/4.1.2/include/limits.h:11,
from ./tommath.h:22,
from bncore.c:1:
/usr/lib/gcc/i486-linux-gnu/4.1.2/include/limits.h:122:61: error: limits.h: No such file or directory
In file included from bncore.c:1:
./tommath.h:537: error: expected declaration specifiers or ‘...’ before ‘FILE’
./tommath.h:538: error: expected declaration specifiers or ‘...’ before ‘FILE’
make: *** [bncore.o] Error 1

It turns out that I get this error because linux-libc-dev isn't installed. I sudo aptitude install libc6-dev and continue.

...
a - bn_mp_sqrt.o
a - bn_mp_is_square.o
a - bn_mp_init_set.o
a - bn_mp_init_set_int.o
a - bn_mp_invmod_slow.o
a - bn_mp_prime_rabin_miller_trials.o
a - bn_mp_to_signed_bin_n.o
a - bn_mp_to_unsigned_bin_n.o
ar: unable to rename 'libtommath.a' reason: Operation not permitted
make: *** [libtommath.a] Error 1

SSHFS strikes again. This time I compile libtommath locally. It wants to install into /usr, but I hate that and manually edit the makefile to install it to ~/pro.

install -d -g wheel -o root ~/pro/lib
install: invalid group `wheel'
make: *** [install] Error 1

Why does this need to be in the group for sudo? There is no documentation so I'll assume I can run it in userland. I have to edit the makefile again.

ifndef INSTALL_GROUP
GROUP=usergroup

$ make install
install -d -g usergroup -o root ~/pro/lib
install: cannot change owner and/or group of `~/pro': Operation not permitted
make: *** [install] Error 1

I edit the makefile again.

ifndef INSTALL_USER
USER=user

And the installation finishes. It's now time to compile openclit.

hexdump.c: In function ‘hexdump’:
hexdump.c:37: warning: implicit declaration of function ‘memset’
hexdump.c:37: warning: incompatible implicit declaration of built-in function ‘memset’
cc -funsigned-char -Wall -O2 -I ../libtommath-0.30/ -I ../lib -I ../lib/des -I . -c -o drm5.o drm5.c
drm5.c:38:21: error: tommath.h: No such file or directory
drm5.c: In function ‘get_next_key’:
drm5.c:116: warning: pointer targets in assignment differ in signedness
drm5.c:117: warning: pointer targets in passing argument 1 of ‘read_whole_file’ differ in signedness
drm5.c:122: warning: pointer targets in assignment differ in signedness
drm5.c:123: warning: pointer targets in passing argument 1 of ‘read_whole_file’ differ in signedness
drm5.c:144: warning: pointer targets in passing argument 2 of ‘strcpy’ differ in signedness
drm5.c:145: warning: pointer targets in passing argument 2 of ‘strcpy’ differ in signedness
drm5.c:168: warning: pointer targets in passing argument 2 of ‘strcpy’ differ in signedness
drm5.c:169: warning: pointer targets in passing argument 2 of ‘strcpy’ differ in signedness
drm5.c: In function ‘ms_base64_decode’:
drm5.c:185: warning: pointer targets in assignment differ in signedness
drm5.c: In function ‘get_element’:
drm5.c:267: warning: implicit declaration of function ‘isalnum’
drm5.c: At top level:
drm5.c:295: error: expected ‘)’ before ‘*’ token
drm5.c: In function ‘drm5_handle_key’:
drm5.c:342: error: ‘mp_int’ undeclared (first use in this function)
drm5.c:342: error: (Each undeclared identifier is reported only once
drm5.c:342: error: for each function it appears in.)
drm5.c:342: error: expected ‘;’ before ‘c’
drm5.c:376: warning: implicit declaration of function ‘mp_init’
drm5.c:376: error: ‘c’ undeclared (first use in this function)
drm5.c:377: error: ‘p’ undeclared (first use in this function)
drm5.c:378: error: ‘mod’ undeclared (first use in this function)
drm5.c:379: error: ‘d’ undeclared (first use in this function)
drm5.c:380: warning: implicit declaration of function ‘mp_read_radix’
drm5.c:382: warning: implicit declaration of function ‘mp_read_unsigned_bin’
drm5.c:383: warning: implicit declaration of function ‘mp_exptmod’
drm5.c:384: warning: implicit declaration of function ‘my_mp_to_unsigned_bin’
drm5.c:426: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘__builtin_strcmp’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘__builtin_strcmp’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘__builtin_strcmp’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘__builtin_strcmp’ differ in signedness
drm5.c:426: warning: pointer targets in passing argument 1 of ‘strncmp’ differ in signedness
make: *** [drm5.o] Error 1

openclit looks for tommath.h in other directories. So I change the CFLAGS line
in the Makefile to:

CFLAGS=-funsigned-char -Wall -O2 -I ../libtommath-0.30/ -I ../lib -I ../lib/des -I . -I ~/pro/include

gcc -o clit clit.o hexdump.o drm5.o explode.o transmute.o display.o utils.o manifest.o ../lib/openclit.a ../libtommath-0.30/libtommath.a
gcc: ../libtommath-0.30/libtommath.a: No such file or directory
make: *** [clit] Error 1

I have to edit the Makefile again to point it to the correct path for libtommath.

$ ./clit
+---[ ConvertLIT (Version 1.8) ]---------------[ Copyright (c) 2002,2003 ]---
ConvertLIT comes with ABSOLUTELY NO WARRANTY; for details
see the COPYING file or visit "http://www.gnu.org/license/gpl.html".
This is free software, and you are welcome to redistribute it under
certain conditions. See the GPL license for details.

This program has three modes of operation:
First, is ** EXPLOSION **, or the expanding of a .LIT file into an
OEBPS compliant package.
To explode, you type: clit \
For Example:
clit ebook-propietary.lit ebook-oebps\
If the directory does not exist, you MUST put a trailing \ or / after it!

To disable creating multiple subdirectories, use the "-d" flag.

Second, is the DOWNCONVERTING of a .LIT file down to "Sealed",
or DRM1 format for reading on handheld devices.
To downconvert, you type: clit
For Example:
clit "drm5 ebook.lit" ebook-open.lit

Third, is the INSCRIBING of a .LIT file which allows you to label
your ebooks. This is very similar to downconverting, you just add
a third argument: clit
For example:
clit ebook.lit inscribed.lit "the Library of Basil Frankweiler"

DRM5 is supported if you have a "keys.txt" file that contains
the private key(s) for your passport(s) in either the CLIT program
directory or the current directory.
Use the -k flag to force the location of your keys.txt

This is a tool for **YOUR OWN FAIR USE** and not for stealing
other people's ebooks.

Please do not use this program to distrbute illegal copies of ebooks.
... that would make Baby Jesus sad.

We can now convert my eBooks to something Linux can understand.



A text file...

Monday, December 25, 2006

Sunday, December 24, 2006

Desktop Recording Crusade

It's simple enough. One wants to make a video of what they're doing on the desktop and post it on the Internet. Just record the content of my desktop for the video source, and capture the output of my sound card as the audio source. Encode it, and I can upload it to a site of my choosing. It should be simple.

sudo aptitude install istanbul

No hitches. I was trying to capture video and istanbul captured this instead:

$ istanbul (272, 395) - (732, 795) DEBUG: final pipeline: oggmux name=mux ! filesink location=/tmp/tmpWSGyA4 istximagesrc startx=272 starty=395 endx=731 endy=794 name=videosource use-damage=false ! video/x-raw-rgb,framerate=10/1 ! videorate ! ffmpegcolorspace ! videoscale method=1 ! video/x-raw-yuv,width=460,height=400,framerate=10/1 ! theoraenc ! queue ! mux. gconfaudiosrc name=audiosource ! audioconvert ! vorbisenc ! queue ! mux. (istanbul:4147): GStreamer-CRITICAL **: gst_caps_get_structure: assertion `GST_IS_CAPS (caps)' failed Segmentation fault (core dumped) $

The times it did run, Istanbul decided to capture video and not write it to disk. Sometimes Istanbul was too stuck up to even capture video. So I decided to try recordMydesktop. I know its a Debian package I'm trying to install on Ubuntu, but compiling is a last resort and Debian packages work most of the time.

$ sudo dpkg --install recordmydesktop_0.3.0r2-1_i386.deb dpkg: error processing recordmydesktop_0.3.0r2-1_i386.deb (--install): cannot access archive: Permission denied Errors were encountered while processing: recordmydesktop_0.3.0r2-1_i386.deb $

dpkg seems to dislike the way I mounted sshfs. So it was copied to the hard drive and recordMydesktop and gtk-recordMydesktop were installed.

Now the moment of truth!



...and nothing. So the FAQ on the homepage says:

If the frontend doesn't start at all, it is most likely that you haven't got installed gnome-python-extras.
Run gtk-recordMyDesktop on a terminal. If it says something like egg.TrayIcon is not found, then
your problem is definately that one.

So I try that and get this:

$ gtk-recordMyDesktop
Traceback (most recent call last):
File "/usr/bin/gtk-recordMyDesktop", line 30, in ?
from recordMyDesktop import rmdSimple
ImportError: No module named recordMyDesktop
$

Maybe I can get it from the command line instead of using the frontend:

$ recordmydesktop --help

Usage:
recordmydesktop [-h| --help| --version| -delay n[H|h|M|m]| -windowid id_of_window|
-display DISPLAY| -x X| -y Y|-width N| -height N| -fps N(number>0)| --on-the-fly-encoding|
-v_quality n| -s_quality n| -v_bitrate n| --no-framedrop| -dummy-cursor color|
--no-cursor| -freq N(number>0)| -channels N(number>0)| -device SOUND_DEVICE|
--no-sound| --with-shared| --no-cond-shared| -shared-threshold n| --full-shots|
--quick-subsampling| -workdir DIR| --zero-compression| --no-wm-check| --overwite| -o filename]^filename


General Options:
-h or --help Print this help and exit.
--version Print program version and exit.

Image Options:
-windowid id_of_window id of window to be recorded.
-display DISPLAY Display to connect to.
-x X Offset in x direction.
-y Y Offset in y direction.
-width N Width of recorded window.
-height N Height of recorded window.

-dummy-cursor color Color of the dummy cursor [black|white]
--no-cursor Disable drawing of the cursor.
--with-shared Enable usage of MIT-shared memory extension at all times.
--no-cond-shared Do not use the MIT-shared memory extension when aquiring large areas.
-shared-threshold n Threshold over which shared memory is used(default 75).
--full-shots Take full screenshot at every frame(Not recomended!).
--quick-subsampling Do subsampling of the chroma planes by discarding,not averaging.
-fps N(number>0.0) A positive number denoting desired framerate.

Sound Options:
-channels N(number>0) A positive number denoting desired sound channels in recording.
-freq N(number>0) A positive number denoting desired sound frequency.
-device SOUND_DEVICE Sound device(default hw0:0).
--no-sound Do not record sound.

Encoding Options
--on-the-fly-encoding Encode the audio-video data, while recording.
-v_quality n A number from 0 to 63 for desired encoded video quality(default 63).
-v_bitrate n A number from 45000 to 2000000 for desired encoded video bitrate(default 45000).
--drop-frames Allow theora encoder to drop frames.
-s_quality n Desired audio quality(-1 to 10).

Misc Options:
--no-wm-check Do not try to detect the window manager(and set options according to it)
--zero-compression Image data are always cached uncompressed.
-workdir DIR Location where a temporary directory will be created to hold project files(default $HOME).
-delay n[H|h|M|m] Number of secs(default),minutes or hours before capture starts(number can be float)
--overwrite If there is already a file with the same name, delete it
(default is to add a number postfix to the new one).
-o filename Name of recorded video(default out.ogg).

If no other options are specified, filename can be given without the -o switch.


I estimate the amount of time I would have to spend experimenting with all of the options and it's much for me to invest. So I hunker down and try this out:

$ recordmydesktop -o test.ogg
Initial recording window is set to:
X:0 Y:0 Width:1440 Height:900
Adjusted recording window is set to:
X:0 Y:2 Width:1440 Height:896
Your window manager appears to be beryl


Detected 3d compositing window manager.
Reverting to full screen capture at every frame.
To disable this check run with --no-wm-check
(though that is not advised, since it will probably produce faulty results).

Initializing...
Playback frequency 22050Hz is not available...
Using 44100Hz instead.
Recording on device hw:0,0 is set to:
2 channels at 44100Hz
Capturing!
An error occured while reading sound data:
Input/output error
Shutting down.Saved 174 frames in a total of 182 requests
.An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error

An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
Killed
$

Now since I am using Beryl, I don't expect it to be perfect. But it didn't catch my sound hardware correctly. Testing with Beryl worked, but only if --no-sound was specified. Time to consult the FAQ again:

In order to record sound from a source(e.g. microphone) you have to set it
through a mixer like kmix, gnome-mixer or alsamixer. recordMyDesktop will
not set anything itself but it will rather start recording from any preselected
source.
To test if you can record you can run cat /dev/dsp on a terminal session
It should start printing characters whenever sound reaches your selected source.
Another reason for no sound might be the presence of more than one soundcards.
In that case make sure you've set the right one (consult the manpage on how to do this).

Oh, okay:

Sound Options:

-channels N(number>0)
A positive number denoting desired sound channels in recording.

-freq N(number>0)
A positive number denoting desired sound frequency.

-device SOUND_DEVICE
Sound device(default hw0:0).

--no-sound
Do not record sound.

I don't see anything about that in the man page. Time to try another method of capturing. Hmm...xvidcap uses ffmpeg to encode captured video and audio. Nice. Let's try that.

$ sudo apt-get install xvidcap
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package xvidcap

So I downloaded xvidcap_1.1.3-1_i386.deb from somewhere else and went on.

$ xvidcap
xvidcap: error while loading shared libraries: libpng.so.2: cannot open shared object file: No such file or directory

It turns out the Debian repository linked from xvidcap's homepage only has 1.1.3, which is linked to libpng.so.2. xvidcap 1.1.4, from the Sourceforge page, loads fine.

So let's start recording! I press the record button and:

$ xvidcap
xtoffmpeg.c guess_input_pix_fmt(): image depth 32 not supported ... aborting

...which I find odd because I'm running at 24 bits per pixel. The next time I run it I can capture video, but not audio! There seems to be a theme.

I found that the actual device to point xvidcap to was /dev/audio. So now I have audio and video.

Now to enjoy the fruits of my labor!



I give up.

Saturday, December 23, 2006

sh descent3-demo.run

$ sh descent3-demo.run
Verifying archive integrity...tail: Warning: "+number" syntax is deprecated, please use "-n +number"
OK
Uncompressing Descent 3 Demotail: Warning: "+number" syntax is deprecated, please use "-n +number"
..............................................
=============================================================
Welcome to the Descent 3 Demo
=============================================================

Would you like to read the README for this update? [Y/n]: n

=============================================================
Would you like to apply this update? [Y/n]: Y

Please enter the installation path: []: ~/pro

=============================================================
Performing update:
ERROR: Unable to make path ~/pro/demos/descent3_demo
The program returned an error code (3)
$ mkdir ~/pro/demos/
$ mkdir ~/pro/demos/descent3
$ sh descent3-demo.run
Verifying archive integrity...tail: Warning: "+number" syntax is deprecated, please use "-n +number"
OK
Uncompressing Descent 3 Demotail: Warning: "+number" syntax is deprecated, please use "-n +number"
..............................................
=============================================================
Welcome to the Descent 3 Demo
=============================================================

Would you like to read the README for this update? [Y/n]: n

=============================================================
Would you like to apply this update? [Y/n]: Y

Please enter the installation path: []: ~/pro

=============================================================
Performing update:
100%
Product updated successfully.

Friday, December 22, 2006

Line Rider


I've heard a lot about it. I bet it's fun.

Thursday, December 21, 2006

./snapscreenshot > snap.tga


The results of trying to take a screenshot of the console:

Wednesday, December 20, 2006

Tuesday, December 19, 2006

sh quake4-linux-1.0-demo.x86.run

$ ./quake4-demo
Quake4 Demo Final V1.0.0 linux-x86 Nov 28 2005
found interface lo - loopback
found interface eth1 - 192.168.1.101/255.255.255.0
CPU: Intel CPU with MMX & SSE & SSE2 & SSE3
enabled Flush-To-Zero mode
--------- Initializing File System ----------
Loaded pk4 /home/pro/quake4-demo/q4base/game000.pk4 with checksum 0xc01bb9a0
Loaded pk4 /home/pro/quake4-demo/q4base/game100.pk4 with checksum 0xe71d2aa2
Loaded pk4 /home/pro/quake4-demo/q4base/pak001.pk4 with checksum 0x4a4195c2
Loaded pk4 /home/pro/quake4-demo/q4base/zpak_english.pk4 with checksum 0xab62ab5e
Loaded pk4 /home/pro/quake4-demo/q4base/zpak_french.pk4 with checksum 0x88c09a6b
Loaded pk4 /home/pro/quake4-demo/q4base/zpak_italian.pk4 with checksum 0xb7cf593a
Loaded pk4 /home/pro/quake4-demo/q4base/zpak_spanish.pk4 with checksum 0x1dec3532
Current search path:
/home/.quake4-demo/q4base
/home/pro/quake4-demo/q4base
/home/pro/quake4-demo/q4base/zpak_spanish.pk4 (864 files)
/home/pro/quake4-demo/q4base/zpak_italian.pk4 (822 files)
/home/pro/quake4-demo/q4base/zpak_french.pk4 (784 files)
/home/pro/quake4-demo/q4base/zpak_english.pk4 (779 files)
/home/pro/quake4-demo/q4base/pak001.pk4 (7663 files)
/home/pro/quake4-demo/q4base/game100.pk4 (2 files)
/home/pro/quake4-demo/q4base/game000.pk4 (2 files)
game DLL: 0x0 in pak: 0x0
Addon pk4s:
file system initialized.
---------------------------------------------

Running in restricted demo mode.

------------ Initializing Decls -------------
Loading guides.... 59 loaded
479ms to load 1064k of material
44ms to load 43k of skin
326ms to load 719k of sound
3ms to load 1k of materialType
605ms to load 2078k of lipSync
98ms to load 105k of playback
1397ms to load 1666k of effect
---------------------------------------------
-------- Initializing renderSystem ----------
using ARB renderSystem
renderSystem initialized.
---------------------------------------------
Found default language English with VO
.... found additional language 'french' with VO
.... found additional language 'italian' with VO
.... found additional language 'spanish' with VO
641 strings read from strings/english_code.lang
1669 strings read from strings/english_guis.lang
5631 strings read from strings/english_lips.lang
6100 strings read from strings/english_maps.lang
641 strings read from strings/french_code.lang
1668 strings read from strings/french_guis.lang
5630 strings read from strings/french_lips.lang
6099 strings read from strings/french_maps.lang
641 strings read from strings/italian_code.lang
1668 strings read from strings/italian_guis.lang
5630 strings read from strings/italian_lips.lang
6099 strings read from strings/italian_maps.lang
641 strings read from strings/spanish_code.lang
1668 strings read from strings/spanish_guis.lang
5630 strings read from strings/spanish_lips.lang
6099 strings read from strings/spanish_maps.lang
Couldn't open journal files
execing default.cfg
"ALT" isn't a valid key
"CTRL" isn't a valid key
couldn't exec editor.cfg
couldn't exec Quake4Config.cfg
couldn't exec autoexec.cfg
-------- Initializing Sound System ----------
sound system initialized.
---------------------------------------------
--------------- R_InitOpenGL ----------------
Initializing SDL subsystem
Loading GL driver 'libGL.so.1' through SDL
libGL warning: 3D driver claims to not support visual 0x5b
8/8/8/8 RGBA bits, 24 depth bits, 8 stencil bits
dlopen(libasound.so.2)
asoundlib version: 1.0.11
Alsa is available
------ Alsa Sound Initialization -----
opened Alsa PCM device default for playback
device buffer size: 5644 frames ( 22576 bytes )
allocated a mix buffer of 16384 bytes
--------------------------------------
...using GL_ARB_multitexture
...using GL_ARB_texture_env_combine
...using GL_ARB_texture_cube_map
...using GL_ARB_texture_env_dot3
...using GL_ARB_texture_env_add
X..GL_ARB_texture_non_power_of_two not found
...using GL_NV_blend_square
...using GL_ARB_texture_compression
X..GL_EXT_texture_compression_s3tc not found
signal caught: Segmentation fault
si_code 1
Trying to exit gracefully..