Interrogation marks and keyboard layouts

I recently switched from KDE to XFCE because I could not stand KDE bugs anymore. The upside is that XFCE is super simple, fast, and minimalist. The downside is that everything looks “blocky” (as in “lego blocks”).

Anyway, two issues have been bugging me these past few days and I finally got around them today.

Accented characters displayed as interrogation marks in terminal

I write in French and English so I sometimes need to type accented characters on the command line. Unfortunately, after installing XFCE on archlinux, I found that every time I typed an accented character in the terminal, it was replaced by an interrogation mark.

After messing around with my configuration files for three days, I finally found the solution on the archlinux wiki:

# in ~/.bashrc
export LC_ALL=
export LC_COLLATE="C"
export LANG=en_US.utf8

# in /etc/environment
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

I believe that only the /etc/environment is necessary, but setting your language in your bash file is considered to be a good practice and other programs might use these variables to determine your locale. Obviously, this is in complement of configuring your /etc/locale.gen file properly.

Keyboard layouts and xfce4-xkb-plugin

This was an extremely annoying bug that probably cost me a few years of my life expectancy in stress. After installing the xfce4-xkb-plugin, I added an extra keyboard layout (English Canada) and I set the layout switch key combination to alt-shift. Unfortunately, the plugin, as other users have reported, has a tendency to “forget” the layout and/or the key combination every once in a while.

The plugin seems to be patched in various distributions, but since archlinux rarely patch programs (which is a generally a good thing), I was stuck with a buggy version.

After some research, I uninstalled the plugin and added this script in /etc/X11/xinit/xinitrc.d/50-keyboard-bart

#!/usr/bin/bash

# Reset keyboard options
setxkbmap -option ""
# Set layout
setxkbmap -layout "us,ca"
# Set international keyboard
setxkbmap -model "pc105"
# Use alt-shift to switch layout
setxkbmap -option "grp:alt_shift_toggle"

If you go down that path, don’t forget to make the script executable. You also need to restart your X session (or you can just execute the script in the current session). The downside is that you do not see your current layout on your panel, but I see this as less cutter :–)

Updating MoinMoin - Major Python Update on ArchLinux

This morning, I upgraded my server, which runs ArchLinux. As you may know, ArchLinux recently updated their Python packages so that the default python points to python3. Python 2.6 was also updated to Python 2.7 (accessible from python2) Everything went relatively well, but I had to recreate all my virtual environments because they were too tightly integrated with python 2.6. I have one virtual environment for each big application running on my server (Trac, MoinMoin, and my ph.d. project, recodoc) and it took longer than expected... MoinMoin must be the worst wiki on earth because every time I want to update it (either MoinMoin or Python), I get a few extra gray hairs. Here are the steps that worked for me:

  1. Stop your wsgi/fcgi server (in my case, gunicorn)
  2. Backup wiki config (share/moin) and wiki data/underlay directories.
  3. Remove the .pyc files from the backup (e.g., share/moin/config/wikiconfig.pyc)
  4. If upgrading Python, remove the cache files from the backup:
    rm -r path_to_moin/data/pages/*/cache/*
    rm -r path_to_moin/underlay/pages/*/cache/*
  5. Update MoinMoin/Python/Whatever
  6. Restore share/moin directory and wiki data/underlay directories.
  7. Restart wsgi/fcgi

Steps 4 and 5 are essential if you are upgrading Python. Indeed, compiled python files are not necessarily compatible from one version to the other (that was my first problem). MoinMoin cache files contain python bytecode that may not be compatible. Backing up the data/underlay directory is not necessary (as long as you delete the cache files when upgrading Python), but I would hate losing my wiki data during an update. Frankly, the only reason I stick with MoinMoin is because it's Python and not PHP. MoinMoin updates are just plain unusable, broken, and evil. Come on, why do I need to run such potentially nasty commands like rm -r with stars? Ok, back to work.

Enabling ASUS USB N13 on ArchLinux

I have a thinkpad x61s and the network card does not work super well, especially on Linux: it takes a long time to authenticate on wpa/wpa2 protected networks and the connection drops frequently.

Based on this post and other reviews, I bought a ASUS N13 usb adapter. The range, the authentication speed, and the connection speed is better than my laptop built-in card. It worked immediately on Windows 7 (Windows downloaded the driver automatically), but it took some fiddling to install it on archlinux.

Essentially, the card works with the RT2870sta chipset driver which conflicts with other drivers. The trick is to disable these conflicting drivers/modules in /etc/rc.conf:

MODULES=( ... !rt2800usb !rt2x00usb !rt2x00lib ... )