Georg Grabler (STiAT) - blog

Life is like an endlessly recursive fractal of perverse pain and suffering.

Tibia in Linux, Hotkey, Razer Naga, Profiles

Okay, may some know, I’m not the gamer within, but there is a special game I like, Tibia. It’s a 2D MMORPG which features a native Linux client.

The only thing which is annoying is, that there is no proper configuration for the Razer Naga mouse I’m using to play the game. So I sat down, and did my own “configuration”, added profiles to TIbia for playing different characters, and did some re-binding of some keys. This here is intended to make it easier for newcomers wanting to play this in Linux to configure.

My Setup

So, how did I set up my system for this. As a side-note I’m currently using KUbuntu with binary NVidia drivers, since I get the best performance out of that.

I created a ~/Games/Tibia folder, where I unpacked the Tibia files. Later, I created another folder in the Tibia folder called “TibiaSettings” which include the profiles for my different characters, named Tibia_Arisyn, Tibia_Stiorra and so on, we’ll get to that later.

As a small piece, my folder structure. Note that I use the StarTibia.sh in the TibiaSettings folder, not the one shipped with TIbia:

schurl@ggpc:~$ find Games/Tibia/ |grep -v map
Games/Tibia/
Games/Tibia/StartTibia.sh
Games/Tibia/TibiaSettings
Games/Tibia/TibiaSettings/StartTibia.sh
Games/Tibia/TibiaSettings/Tibia_Arisyn
Games/Tibia/TibiaSettings/Tibia_Arisyn/Tibia.cfg
Games/Tibia/TibiaSettings/Tibia_Arisyn/Server Log.txt
Games/Tibia/TibiaSettings/Tibia_Arisyn/Tibia.cfg.bak
Games/Tibia/TibiaSettings/Tibia_Arisyn/English Chat.txt
Games/Tibia/TibiaSettings/Tibia_Arisyn/Phoric.txt
Games/Tibia/TibiaSettings/Tibia_Bazhuk
Games/Tibia/TibiaSettings/Tibia_Bazhuk/Tibia.cfg
Games/Tibia/TibiaSettings/Tibia_Bazhuk/Tibia.cfg.bak
Games/Tibia/TibiaSettings/Tibia_Bazhuk/English Chat.txt
Games/Tibia/TibiaSettings/Tibia_Bazhuk/Phoric.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra
Games/Tibia/TibiaSettings/Tibia_Stiorra/Zimmiee.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra/Tibia.cfg
Games/Tibia/TibiaSettings/Tibia_Stiorra/Server Log.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra/Tibia.cfg.bak
Games/Tibia/TibiaSettings/Tibia_Stiorra/Emily Sofie.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra/English Chat.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra/Kurotshuchi.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra/Local Chat.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra/Wanderers.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra/Phoric.txt
Games/Tibia/TibiaSettings/Tibia_Stiorra/Tibia.exp
Games/Tibia/TibiaSettings/Tibia_Izolde
Games/Tibia/TibiaSettings/Tibia_Izolde/Tibia.cfg
Games/Tibia/TibiaSettings/Tibia_Izolde/Server Log.txt
Games/Tibia/TibiaSettings/Tibia_Izolde/Tibia.cfg.bak
Games/Tibia/TibiaSettings/Tibia_Izolde/English Chat.txt
Games/Tibia/TibiaSettings/Tibia_Izolde/Phoric.txt
Games/Tibia/TibiaSettings/Tibia_Ahazin
Games/Tibia/TibiaSettings/Tibia_Ahazin/Tibia.cfg
Games/Tibia/TibiaSettings/Tibia_Ahazin/Server Log.txt
Games/Tibia/TibiaSettings/Tibia_Ahazin/Tibia.cfg.bak
Games/Tibia/TibiaSettings/Tibia_Ahazin/Emily Sofie.txt
Games/Tibia/TibiaSettings/Tibia_Ahazin/English Chat.txt
Games/Tibia/TibiaSettings/Tibia_Ahazin/Wanderers.txt
Games/Tibia/TibiaSettings/Tibia_Ahazin/Phoric.txt
Games/Tibia/TibiaSettings/Tibia_Ahazin/Tibia.exp
Games/Tibia/TibiaSettings/Tibia_Ephiroth
Games/Tibia/TibiaSettings/Tibia_Ephiroth/Tibia.cfg
Games/Tibia/TibiaSettings/Tibia_Ephiroth/Tibia.cfg.bak
Games/Tibia/TibiaSettings/Tibia_Ephiroth/English Chat.txt
Games/Tibia/TibiaSettings/Tibia_Ephiroth/Phoric.txt
Games/Tibia/TibiaSettings/AutoHotkey.ahk
Games/Tibia/Patch
Games/Tibia/Tibia
Games/Tibia/libc6
Games/Tibia/libc6/libnss_files.so.2
Games/Tibia/libc6/libpcprofile.so
Games/Tibia/libc6/libresolv-2.7.so
Games/Tibia/libc6/ld-2.7.so
Games/Tibia/libc6/libdl-2.7.so
Games/Tibia/libc6/libpthread-2.7.so
Games/Tibia/libc6/libBrokenLocale-2.7.so
Games/Tibia/libc6/libnsl-2.7.so
Games/Tibia/libc6/libcrypt-2.7.so
Games/Tibia/libc6/libcidn.so.1
Games/Tibia/libc6/libutil.so.1
Games/Tibia/libc6/libnss_dns.so.2
Games/Tibia/libc6/libthread_db-1.0.so
Games/Tibia/libc6/libSegFault.so
Games/Tibia/libc6/libc.so.6
Games/Tibia/libc6/libnss_files-2.7.so
Games/Tibia/libc6/libnss_nisplus.so.2
Games/Tibia/libc6/libmemusage.so
Games/Tibia/libc6/libutil-2.7.so
Games/Tibia/libc6/libBrokenLocale.so.1
Games/Tibia/libc6/librt-2.7.so
Games/Tibia/libc6/libm.so.6
Games/Tibia/libc6/libnss_compat-2.7.so
Games/Tibia/libc6/libanl-2.7.so
Games/Tibia/libc6/libm-2.7.so
Games/Tibia/libc6/libthread_db.so.1
Games/Tibia/libc6/libnss_nis-2.7.so
Games/Tibia/libc6/libanl.so.1
Games/Tibia/libc6/README
Games/Tibia/libc6/libcrypt.so.1
Games/Tibia/libc6/libnss_hesiod.so.2
Games/Tibia/libc6/libpthread.so.0
Games/Tibia/libc6/libc-2.7.so
Games/Tibia/libc6/libdl.so.2
Games/Tibia/libc6/libresolv.so.2
Games/Tibia/libc6/libnss_dns-2.7.so
Games/Tibia/libc6/libnss_compat.so.2
Games/Tibia/libc6/librt.so.1
Games/Tibia/libc6/libnss_hesiod-2.7.so
Games/Tibia/libc6/libnss_nis.so.2
Games/Tibia/libc6/ld-linux.so.2
Games/Tibia/libc6/libnsl.so.1
Games/Tibia/libc6/libnss_nisplus-2.7.so
Games/Tibia/libc6/libcidn-2.7.so
Games/Tibia/Tibia.xpm
Games/Tibia/Tibia.dat
Games/Tibia/Showerror
Games/Tibia/Tibia.pic
Games/Tibia/Tibia.spr

Razer Naga

Oh ye, that is a tough one. By default, the keys for the Razer Naga in Linux are bout to 1-12, but we’ll need them boud to F1-F12. You can achieve that by a simple thing: A Startscript. So I created Script, which gets more and more things added over the course, first is the Razer Naga stuff.

I want to note here that the ground work for this was done by a user (Xaero252) on the Arch Linux forums. I just tweaked it a little, as you can see at my comment int he forum below.

#!/bin/bash

remote_id=$(

xinput list |
	sed -n 's/.*Naga.*id=\([0-9]*\).*keyboard.*/\1/p'
)

[ "$remote_id" ] || exit

mkdir -p /tmp/xkb/symbols
cat >/tmp/xkb/symbols/custom <<\EOF

xkb_symbols "remote" {
	key { [F1, F1] };
	key { [F2, F2] };
	key { [F3, F3] };
	key { [F4, F4] };
	key { [F5, F5] };
	key { [F6, F6] };
	key { [F7, F7] };
	key { [F8, F8] };
	key { [F9, F9] };
	key { [F10, F10] };
	key { [F11, F11] };
	key { [F12, F12] };
};

EOF

This script will set the Razer Naga keys to F1-F12. I added this to the startscript of Tibia on the top.

Keyboard Settings

Well, Tibia is much more convenient playing using the keypad because you can move diagonal there. For that, I usually set the 5 key on the keypad to “down”, and the PAGE UP to SHIFT, and PAGE DOWN to CTRL to have it a little bit more convenient playing. To do this, we need to reassign the keys to new keycodes in X. This can be done by xmodmap.

xmodmap -e 'keycode 84=Down'
xmodmap -e 'keycode 117=Control_L'
xmodmap -e 'keycode 112=Shift_L'

To set the keys back to their original value, you can use the following code:

xmodmap -e 'keycode 84=Begin'

xmodmap -e ‘keycode 117=Next’
xmodmap -e ‘keycode 112=Prior’

Profiles
Yes, I use several different characters, and those who know TIbia know that different characters need different hotkeys. Since CIP did not implement hotkey profiles in the native clients (only in the Flash Client, which does not work very well for me in Linux), there is a workaround to do it.
Therefore, a folder for each character will be created, as described above. I’ll do that with the example of Stiorra and Arisyn, two of my characters.
First, the Script. To get a proper “setting” value to tibia, you need to add starting tibia.

cd ~/Games/Tibia

./Tibia path $1

Pretty easy, isn’t it? But it’s only half of the rent, since you need shortcuts. For that I created desktop shortcuts. Note that those are MY shortcuts with MY pathes:

Arisyn

[Desktop Entry]
Comment[en_US]=
Comment=
Exec=/home/schurl/Games/Tibia/TibiaSettings/StartTibia.sh /home/schurl/Games/Tibia/TibiaSettings/Tibia_Arisyn/
GenericName[en_US]=Tibia Arisyn
GenericName=Tibia Arisyn
Icon=
MimeType=
Name[en_US]=Tibia Arisyn
Name=Tibia Arisyn
Path=/home/schurl/Games/Tibia
StartupNotify=true
Terminal=false
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=

Stiorra

[Desktop Entry]
Comment[en_US]=
Comment=
Exec=/home/schurl/Games/Tibia/TibiaSettings/StartTibia.sh /home/schurl/Games/Tibia/TibiaSettings/Tibia_Stiorra/
GenericName[en_US]=Tibia Stiorra
GenericName=Tibia Stiorra
Icon=
MimeType=
Name[en_US]=Tibia Stiorra
Name=Tibia Stiorra
Path=/home/schurl/Games/Tibia
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

Note that I start Tibia using a shell script passing the path to the folder to be used as profile to Tibia as the first parameter. The script will be posted afterwards as complete script.

The complete Script

This should basically do what you need, put it in your TibiaSettings folder created, and it will. If you only need parts of what I do, you can remove the parts described above seperately, they don’t have any effect on each other.

#!/bin/bash

remote_id=$(
	xinput list |
		sed -n 's/.*Naga.*id=\([0-9]*\).*keyboard.*/\1/p'
)

[ "$remote_id" ] || exit

mkdir -p /tmp/xkb/symbols
cat >/tmp/xkb/symbols/custom <<\EOF

xkb_symbols "remote" {
	key { [F1, F1] };
	key { [F2, F2] };
	key { [F3, F3] };
	key { [F4, F4] };
	key { [F5, F5] };
	key { [F6, F6] };
	key { [F7, F7] };
	key { [F8, F8] };
	key { [F9, F9] };
	key { [F10, F10] };
	key { [F11, F11] };
	key { [F12, F12] };
};

EOF

setxkbmap -device $remote_id -print | sed 's/\(xkb_symbols.*\)"/\1+custom(remote)"/' | xkbcomp -I/tmp/xkb -i $remote_id -synch - $DISPLAY 2>/dev/null
xmodmap -e 'keycode 84=Down'
xmodmap -e 'keycode 117=Control_L'
xmodmap -e 'keycode 112=Shift_L'

cd ~/Games/Tibia
./Tibia path $1

xmodmap -e 'keycode 84=Begin'
xmodmap -e 'keycode 117=Next'
xmodmap -e 'keycode 112=Prior'

There are no comments

Leave a Reply

Your email address will not be published. Required fields are marked *