Daniel 'MaTachi' Jonsson

Tag Archives: Linux

How to Get Your Playstation 3 Dualshock 3 Sixaxis Controller to Work on Linux

Jstest-gtk

To see if the controller works, install jstest-gtk (it’s in Ubuntu’s repository). It will list all connected game controllers and show which buttons are pressed and which not.

Install it with:

sudo apt-get install jstest-gtk

Xboxdrv

My Playstation 3 Dualshock 3 Sixaxis controller worked quite well, sometimes, without any drivers. But it was quite unreliable, and the L2 and R2 triggers wouldn’t get recognized in Euro Truck Simulator 2. A much better solution is to install and run xboxdrv to emulate it as a Xbox 360 controller when you want to play games.

Install xboxdrv:

sudo apt-get install xboxdrv

Start it with:

sudo xboxdrv --detach-kernel-driver

Press the Playstation button on the controller to get xboxdrv start receiving and processing the inputs from the controller. This will print a lot of text in the terminal. If you want to quit it, press Ctrl-c. When it’s running, open Jstest-gtk and see if the controller now shows up as a Xbox Gamepad instead, and if all buttons, triggers and joysticks work.

I connected my controller with a USB cable, so I can’t say if this will work through Bluetooth.

How to Copy Your Euro Truck Simulator 2 Savegame from Windows to Linux

Prerequisites

  1. A Euro Truck Simulator 2 game profile on Windows.
  2. A Euro Truck Simulator 2 game profile on Linux. It’s enough to have started it once and configured a basic profile.

Locating your savegame folder from Windows

In Ubuntu, open Nautilus (the file manager/browser), click on your Windows partition in the left sidebar under Devices to mount it. Then navigate to:

/media/[linux-username]/[xxxxxxxxxxxxx]/Users/[windows-username]/Documents/Euro Truck Simulator 2/profile

There you will find a folder containing your savegame and profile. My folder was called 417A757361.

Locating your savegame folder on Linux

Open a new window and navigate to the following folder on Linux:

/home/[linux-username]/.local/share/Euro Truck Simulator 2/profiles

Here I also found a folder named 417A757361.

Copy over your Windows savegame

Rename the Linux folder to 417A757361_old, then copy over your savegame folder 417A757361 from Windows into the profiles folder on Linux. Now you should have the following folders:

/media/[linux-username]/[xxxxxxxxxxxxx]/Users/[windows-username]/Documents/Euro Truck Simulator 2/profile/417A757361
/home/[linux-username]/.local/share/Euro Truck Simulator 2/profiles/417A757361_old
/home/[linux-username]/.local/share/Euro Truck Simulator 2/profiles/417A757361

The first one is a backup of your progress from Windows, the second is a backup of your dummy profile you created on Linux, and the last one is the real, new savegame folder.

Copy over your controls config

Copy controls.sii from 417A757361_old and paste it into the new 417A757361. Because the Windows controls won’t work on Linux. Now the mouse and such should also work when launching the game.

Copy your Windows controls over to Linux

It should be possible to keep your controls you configured on Windows. However, I haven’t tried this. Open controls.sii in 417A757361_old. Instead of replacing the whole controls.sii file in the new 417A757361 folder, just copy over third line looking like this:

input_config : _nameless.0x.14d6.d5d0 {

Copy that line and replace the third line in controls.sii in the new 417A757361, assuming it contains the Windows controls. Otherwise you need to get a new copy of the controls.sii from the Windows folder.

bash bad interpreter with Robocode

The other day I downloaded Robocode, ran the unpacker and tried to execute the shell scripts within the Robocode folder. However, on Ubuntu I got the following error when I did that:

matachi:robocode$ ./robocode.sh
bash: ./robocode.sh: /bin/sh^M: bad interpreter: No such file or directory

To fix this install dos2unix by running:

sudo apt-get install dos2unix

Then run:

dos2unix robocode.sh

And now the script is runnable on Linux.

How To Live Stream Your Ubuntu Desktop

In this post I will show how I managed to set up a live stream of my Ubuntu 12.04 desktop to Justin.tv. Since Justin.tv is tightly connected to Twitch.tv, you can probably with very small modifications make this work with Twitch too.

Step 1.

Create a new file called stream.sh and paste the following text into the file:

#!/bin/bash
INRES="1680x1050" # input resolution
OUTRES="640x360"
OFFSET="1680,0"
FPS="15" # target FPS
QUAL="fast"  # one of the many FFMPEG preset
STREAM_KEY="your_stream_key"
URL="rtmp://live.justin.tv/app/$STREAM_KEY"

avconv -f x11grab -s "$INRES" -r "$FPS" -i :0.0+$OFFSET -ab 192k \
-f alsa -ac 2 -i pulse -vcodec libx264 -crf 30 -preset "$QUAL" -s "1280x720" \
-vol 11200 -acodec libmp3lame -ar 44100 -threads 0 \
-f flv "$URL"

You can get your stream key from this page:

Note that you probably want to change the OFFSET variable to 0,0. I have it because I only wanted to stream my second monitor, which is to the right.

More options to x11grab can be found here, such as draw_mouse and follow_mouse:

The script is based on the one found in this thread:

Step 2.

Update the script’s permissions from the terminal:

chmod u+x stream.sh

Step 3.

The video codec (-vcodec libx264) requires that you have this package installed:

sudo apt-get install libavcodec-extra-53

This did I find out in this Stack Overflow answer:

Step 4.

Start streaming by running:

./stream.sh

Audio

I’m not completely satisfied with the audio quality on the stream. I changed the bitrate argument in the script from 96k to 192k, and I added “-vol 11200″ to increase the audio volume since it was incredibly low. The quality is still not very good, so if you have a solution, please leave a comment.

The package pavucontrol in Ubuntu’s repository is an audio manager that has some more options than the pre-installed. However, I didn’t find anything that I had use of there, but maybe you have.

How to Set Up a Virtual Host on Ubuntu

Add a new site:

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite.local

Then configure the site to fit your needs:

sudo vim /etc/apache2/sites-available/mysite.local

Don’t forget to add this line to the VirtualHost element:

ServerName mysite.local

Enable the site:

sudo a2ensite mysite.local

Reload Apache:

sudo service apache2 reload

Update your hosts file:

sudo vim /etc/hosts

Add the following line to the file:

127.0.0.1 mysite.local

Open a browser and visit mysite.local. Make sure that you don’t precede the URL with www..

If the browser doesn’t show what you are expecting, start with checking Apache’s error log:

cat /var/log/apache2/error.log | tail

Work with Multiple Terminals in a Grid in a Single Window

If you often find yourself with a lot of open terminal windows, I can recommend you to try out the the program Terminator. With it, it’s possible to have open multiple terminals in a grid in a single window.

Terminator

Screenshot of Terminator

Links:

How to Install Pygame to Python 3 on Ubuntu

Installation

Start by installing all necessary dependencies, and mercurial and checkinstall for the installation:

sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev checkinstall mercurial

Then download the latest version of the Pygame source code with the following command (this uses mercurial):

hg clone https://bitbucket.org/pygame/pygame

Go into the downloaded Pygame directory:

cd pygame

Compile the source code by typing this command into the terminal:

python3 setup.py build

Finally install Pygame by doing this:

sudo checkinstall python3 setup.py install

Extra stuff

Click here to read why you should use checkinstall.

Use this command to see information about your pygame installation:

apt-get cache show pygame

And this command to uninstall Pygame:

dpkg -r pygame

or:

sudo apt-get remove pygame

Notes

The most recent stable pygame version when writing this is 1.9.1 (which is from August 2009). I did this installation on Ubuntu 12.04 and this was needed since there isn’t a python3-pygame available in the repository.

How to Fix Ugly Japanese Fonts in Firefox

The other day I took and reinstalled Ubuntu on my computer. So now I’m running 12.04, and I have to say that it’s a really nice OS.

Anyway, in Firefox I encountered an ugly Japanese font on some pages. It looked like an old/jagged serif font. However, on some other pages it looked much better and modern.

After looking around I finally managed to fix that ugly font problem by doing these steps:

  1. Open Firefox’s Preferences window.
  2. Select the Content tab.
  3. Click on the “Advanced…” button under “Fonts & Colors”.
  4. A new window appears with the title Fonts.
  5. Select Japanese in the “Fonts for:” drop-down list.
  6. Select “sans-serif” in the “Serif:” drop-down list.
  7. Finally close the window by clicking the OK button and you are done.

How to Compile a gtkmm Project in Code::Blocks

To compile a C++ application using gtkmm in Code::Blocks, do the following steps:

  1. Open Project > Build Options…
  2. Select your project.
  3. On the Compiler settings tab, select Other options and add this to the field:
    `pkg-config gtkmm-3.0 –cflags`
  4. Select the Linker settings tab and type the following line in the Other linker options text area:
    `pkg-config gtkmm-3.0 –libs`