Posts from June 2008

Getting Thunderbird to open links in your favorite browser.

I’ve been using Thunderbird for a while now, and suddenly it stopped responding on clicks on links, they do not open in my preferred browser Firefox. After googling a little bit I found out how to make it open links in the browser you want.

Close Thunderbird and find the prefs.js file in ~/.thunderbird/*.default where * is the string your profile is given.

At the end of the prefs.js file append the following lines:


user_pref("network.protocol-handler.app.http","/usr/bin/firefox");
user_pref("network.protocol-handler.app.https","/usr/bin/firefox");
user_pref("network.protocol-handler.app.ftp","/usr/bin/firefox");

You can of course use a path for another browser if you want.

Also if you Firefox will not open mailto links in Thunderbird you can find Firefox’s prefs.js file in ~/.mozilla/firefox/*.default and append the following line:


user_pref("network.protocol-handler.app.mailto","/usr/bin/thunderbird");

Driving license, oww yea'!

Finally I got my driving license. I was so freaking nervous this morning right before the test. First I went out driving with my instructor just to warm up, it went really good, so I stopped being nervous for a while there. But when the test started it suddenly came back, and the little mistake I made to start with didn’t help me at all. I release the clutch a little bit too fast and the engine went out. I got it started again, and I was good to go.
The test went very well, the first half of it the instructor was pretty quiet. He only said which way I was supposed to go. But then I broke the silence by talking about the weather. I hate sitting and just drive. Anyways, we talked a bit a bout the weather and other stuff, and suddenly the test was over!
So now I have my driving license! Oww yea’!

How to check what CFLAGS are suited for your system.

I recently discovered that the newer GCC versions now support using -march=native which is pretty cool, because GCC will then find the CFLAGS which suit your system. Here is how I found out which CFLAGS, GCC finds best for my system:


echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test

This command should be executed from the terminal, and make sure you are using GCC >= 4.2.0:


echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.3.1/work/gcc-4.3.1/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.1 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-cld --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.1 p1.0'
Thread model: posix
gcc version 4.3.1 (Gentoo 4.3.1 p1.0)
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1 -v test.c -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 -mtune=generic -dumpbase test.c -auxbase test -O2 -version -o /tmp/cc8FolQd.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include-fixed
/usr/include
End of search list.
GNU C (Gentoo 4.3.1 p1.0) version 4.3.1 (i686-pc-linux-gnu)
compiled by GNU C version 4.3.1, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=127766
options passed: -v test.c -march=prescott --param l1-cache-size=32
--param l1-cache-line-size=64 -mtune=generic -O2
options enabled: -falign-labels -falign-loops -fargument-alias
-fauto-inc-dec -fbranch-count-reg -fcaller-saves -fcommon
-fcprop-registers -fcrossjumping -fcse-follow-jumps -fdefer-pop
-fdelete-null-pointer-checks -fearly-inlining
-feliminate-unused-debug-types -fexpensive-optimizations
-fforward-propagate -ffunction-cse -fgcse -fgcse-lm
-fguess-branch-probability -fident -fif-conversion -fif-conversion2
-finline-functions-called-once -finline-small-functions -fipa-pure-const
-fipa-reference -fivopts -fkeep-static-consts -fleading-underscore
-fmath-errno -fmerge-constants -fmerge-debug-strings
-fmove-loop-invariants -foptimize-register-move -foptimize-sibling-calls
-fpcc-struct-return -fpeephole -fpeephole2 -fregmove -freorder-blocks
-freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec
-fsched-stalled-insns-dep -fschedule-insns2 -fsigned-zeros
-fsplit-ivs-in-unroller -fsplit-wide-types -fstrict-aliasing
-fstrict-overflow -fthread-jumps -ftoplevel-reorder -ftrapping-math
-ftree-ccp -ftree-ch -ftree-copy-prop -ftree-copyrename -ftree-cselim
-ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre -ftree-loop-im
-ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops=
-ftree-pre -ftree-reassoc -ftree-salias -ftree-scev-cprop -ftree-sink
-ftree-sra -ftree-store-ccp -ftree-ter -ftree-vect-loop-version -ftree-vrp
-funit-at-a-time -fvar-tracking -fvect-cost-model
-fzero-initialized-in-bss -m32 -m80387 -m96bit-long-double
-maccumulate-outgoing-args -malign-stringops -mcld -mfancy-math-387
-mfp-ret-in-387 -mfused-madd -mglibc -mieee-fp -mmmx -mno-red-zone
-mno-sse4 -mpush-args -msahf -msse -msse2 -msse3 -mtls-direct-seg-refs
Compiler executable checksum: 11cc1d92ac4cc0eab595215165f2ebd2
main
Analyzing compilation unit
Performing interprocedural optimizations
Assembling functions:
main
Execution times (seconds)
expand : 0.01 (100%) usr 0.00 ( 0%) sys 0.01 ( 1%) wall 3 kB ( 1%) ggc
scheduling 2 : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.74 (87%) wall 0 kB ( 0%) ggc
TOTAL : 0.01 0.00 0.85 584 kB
Internal checks disabled; compiler is not suited for release.
Configure with --enable-checking=release to enable checks.
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /tmp/cc4KdoRg.o /tmp/cc8FolQd.s
GNU assembler version 2.18 (i686-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
COMPILER_PATH=/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/:/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/lib/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-Q' '-O2' '-o' 'test'
/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../crt1.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../crti.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/crtbegin.o -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.1 -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.1 -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../.. /tmp/cc4KdoRg.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/crtend.o /usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../crtn.o

The options that passed for my system are:


options passed: -v test.c -march=prescott --param l1-cache-size=32 --param l1-cache-line-size=64 -mtune=generic -O2

Crickey!

Getting tablet and rotation to work on Thinkpad X60t

Getting pen and rotation to work on X60t.

NOTE: I used Gentoo Linux with kernel 2.6.25 with tuxonice patch and linuxwacom-0.8.0_p20.

First make sure you have the wacom drivers that come with the kernel compiled into the kernel or compiled as a module.
Though I’m not sure if it is nessesary or not.


	Deveice Drivers --->
		Input Device Support --->
			Tablets --->
				<M>   Wacom Intuos/Graphire tablet support (USB)

In gentoo you have to unmask the newest version of the linuxwacom driver. To do this do the following unless you are running
an ~arch:


	echo "x11-drivers/linuxwacom ~*" >> /etc/portage/package.keywords

Now install the linuxwacom package:


	emerge linuxwacom

When it is done installing we can add the nessesary sections in the Xorg.conf to make it respond to the input from the tablet.

Make your Section “ServerLayout” look similar to this (yours might look a little bit different, the important part is the
Stylus, Cursor and Eraser):


	Section "ServerLayout"
		Identifier     "X.org Configured"
   	Screen      0  "Screen0" 0 0
		InputDevice    "Mouse0" "CorePointer"
		InputDevice    "Mouse1" "SendCoreEvents"
		InputDevice    "Keyboard0" "CoreKeyboard"
		InputDevice    "Cursor" "SendCoreEvents"
		InputDevice    "Stylus" "SendCoreEvents"
		InputDevice    "Eraser" "SendCoreEvents"
	EndSection

We also need to add some device sections:


	Section "InputDevice"
		Identifier  "Cursor"
		Driver      "wacom"
		Option      "Device" "/dev/ttyS0"
		Option      "Type" "cursor"
		Option      "ForceDevice" "ISDV4"
		Option      "Mode" "Absolute"
		Option      "BottomY" "18432"
		Option      "BottomX" "24576"
	EndSection

	Section "InputDevice"
		Identifier  "Stylus"
		Driver      "wacom"
		Option      "Device" "/dev/ttyS0"
		Option      "Type" "stylus"
		Option      "ForceDevice" "ISDV4"
		Option      "TPCButton" "off"
		Option      "BottomY" "18432"
		Option      "BottomX" "24576"
		Option      "Mode" "Absolute"
	EndSection

	Section "InputDevice"
		Identifier  "Eraser"
		Driver      "wacom"
		Option      "Device" "/dev/ttyS0"
		Option      "Type" "eraser"
		Option      "ForceDevice" "ISDV4"
		Option      "BottomY" "18432"
		Option      "BottomX" "24576"
	EndSection

The Optiopn “ForceDevice” “ISDV4″ is nessesary when using serial tablets.

Before we can restart Xorg, we need to tell the system where the tablet device is, you have to do this on every boot:


	setserial /dev/ttyS0 port 0x0200 irq 5 autoconfig

Add this line to /etc/conf.d/local.start (or at least that is how you do in gentoo, this might be different on other
distro’s with different kind of init systems).

After a restart of Xorg the tablet should now work. Try it out. I use Xournal to make notes.

Now we got the tablet to work we can play a bit with rotating the screen when you swivel down the screen and when you
swivel it up. Also when you push the rotate button on the buttons beneath the screen.

Make sure you have the newest thinkpad package and acpid installed:


	echo "app-laptop/thinkpad ~*" >> /etc/portage/package.keywords
	echo "sys-power/acpid ~*" >> /etc/portage/package.keywords

Install both packages:


	emerge thinkpad acpid

Modprobe the thinkpad module and start the acpid daemon:


	modprobe thinkpad
	/etc/init.d/acpid start

Also make the daemon start and load the module on every boot:


	rc-update add acpid default
	echo 'modules_2_6="${modules_2_6} thinkpad"' >> /etc/conf.d/modules
	echo 'module_thinkpad_args_2_6=""' >> /etc/conf.d/modules

When you swivel down the monitor and when you swivel it up it generates an acpi event. This event looks like this:

When swivling down:


	Jun  9 02:22:37 arcadia acpid: received event "ibm/hotkey HKEY 00000080 00005009"

When swivling up:


	Jun  9 02:22:45 arcadia acpid: received event "ibm/hotkey HKEY 00000080 0000500a"

You can find out what events your tablet makes either by tailing /var/log/messages or use acpi_listen.

When we know what events there are made, we can make acpid execute some scripts for us.

Make a file in /etc/acpi/events called x60t-swivel-down and one that is called x60t-swivel-up.

x60t-swivel-down should contain the following:


	# called when tablet screen swivels down (into tablet mode)
	event=ibm/hotkey HKEY 00000080 00005009
	action=/etc/acpi/actions/x60t-swivel-down

x60t-swivel-up should contain:


	# called when tablet screen swivels up (into laptop mode)
	event=ibm/hotkey HKEY 00000080 0000500a
	action=/etc/acpi/actions/x60t-swivel-up

As you can see in both files, I took the received events and and assigned some actions for them.

Make the action scripts, these are placed in /etc/acpi/actions:

x60t-swivel-up:


	#!/bin/bash
	/usr/bin/xrandr -o normal
	xsetwacom set "Stylus" Rotate none
	xsetwacom set "Cursor" Rotate none
	xsetwacom set "Eraser" Rotate none

x60t-swivel-down:


	#!/bin/bash
	/usr/bin/xrandr -o inverted
	xsetwacom set "Stylus" Rotate half
	xsetwacom set "Cursor" Rotate half
	xsetwacom set "Eraser" Rotate half

The -o option for xrandr indicates the rotation of the screen. You can use normal, left, right and inverted here.
You have to tell Xorg, which orientation the Stylus, Cursor and Eraser have when rotating.

Save the scripts. Restart acpid and test it:


	/etc/init.d/acpid restart

Now try swivel the screen down, you should se the screen rotate. Swivel it up and it returns to normal.
You might also want to use the rotate button – this button does not generate acpi events, though it generates
X events, that you can grab with xev:


	emerge xev

Now fire up xev and push the button, the output looks like this (your output might look different):


	KeyRelease event, serial 30, synthetic NO, window 0x3a00001,
		root 0x59, subw 0x0, time 719677542, (609,349), root:(613,403),
		state 0x0, keycode 203, same_screen YES,

What we need is the keycode, which in this case is 203. If it does not appear, you might need to run:


	setkeycodes 6c 153

That has to be done upon every boot. Add it to your /etc/conf.d/local.start, and try run the xev app again and see if
you can grab the event now.

Now make a file called .Xmodmap in your home directory containing:


	keycode 203 = F13

And make a file called .xbindkeysrc containing the following:


	"/home/username/bin/rotate"
	F13

As you can see the file points to /home/username/bin/rotate we have to make that file, and this one contains:


	#!/usr/bin/env bash

	# This is a script that toggles rotation of the screen through xrandr,
	# and also toggles rotation of the stylus, eraser and cursor through xsetwacom

	# Check orientation
	orientation=`xrandr --verbose -q | grep LVDS | awk '{print $5}'`
	# Rotate the screen and stylus, eraser and cursor, according to your preferences.
	if [ "$orientation" = "normal" ]; then
		/usr/bin/xrandr -o right
		xsetwacom set "Stylus" Rotate cw
		xsetwacom set "Cursor" Rotate cw
		xsetwacom set "Eraser" Rotate cw
	elif [ "$orientation" = "inverted" ]; then
		/usr/bin/xrandr -o left
		xsetwacom set "Stylus" Rotate ccw
		xsetwacom set "Cursor" Rotate ccw
		xsetwacom set "Eraser" Rotate ccw
	elif [ "$orientation" = "right" ]; then
		/usr/bin/xrandr -o inverted
		xsetwacom set "Stylus" Rotate half
		xsetwacom set "Cursor" Rotate half
		xsetwacom set "Eraser" Rotate half
	elif [ "$orientation" = "left" ]; then
		/usr/bin/xrandr -o normal
		xsetwacom set "Stylus" Rotate none
		xsetwacom set "Cursor" Rotate none
		xsetwacom set "Eraser" Rotate none
	fi

Remember to make it executable!

We are almost done. Make your window manager run xmodmap ~/.Xmodmap and xbindkeysrc upon start. I use gnome and made
a little script containing the two commands and configured the gnome session to run the scrip when starting.

Run the following commands and test the button:


	xmodmap ~/.Xmodmap
	xbindkeys

We are now done!

How to get Ventrilo working in WINE

Yeah this should be obvious. This is how to get Ventrilo to work in WINE. I used Gentoo Linux with kernel 2.6.25 and WINE 1.0_rc2 and Ventrilo 3.0.1.

So yeah lets get to it!

I suggest that you have the latest version of wine, so do:

echo “app-emulation/wine ~*” >> /etc/portage/package.keywords

Now install it:

emerge wine

Download Ventrilo from their homepage, then install it from the dir you downloaded it to:

wine ventrilo-3.0.1-Windows-i386.exe

OK we are near the end.

Now do:

winecfg

Go to Audio, set hardware acceleration to emulation, and check if there are input and output devices for sound systems and ALSA.

Before we fire up Ventrilo you have to find the msgsm32.acm file somewhere on the internet, and put it in ~/.wine/drive_c/windows/system and add the following line in ~/.wine/drive_c/windows/system.ini under the [drivers32] section:

msacm.msgsm610=msgsm32.acm

Now fire the missiles!!! Err I mean fire up Ventrilo and that has to be done from the folder you installed it in. Create your profile, and enable all directsound stuff. Now it should work! Oh yeah and remember to turn up the capture device in your mixer.