Linux locale problems over ssh from a Mac

Most users of Debian/Ubuntu have at some time seen these annoying messages:


perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

There are a variety of causes – usually locales not being generated properly or incorrect environment variables.

Lately I’ve been getting these a lot of these, but only some of the time. After some messing around I eventually discovered the problem wasn’t on the server itself. The problem only occurs when I’m logged in over SSH from a Mac. The default sshd on Debian copies LANG and LC_* variables from the client. The LC_CTYPE variable was set on my Mac, apparently by default, to “UTF-8″. While this seems to work on MacOS X, it’s not a valid value for Linux.

The easiest solution was just to add the following to my ~/.profile on the Mac:


export LC_CTYPE=en_GB.UTF-8

That fixes it, and doesn’t appear to cause harm on the Mac.

Invert mouse scroll wheel in Debian

I’ve been using the beta of MacOS X Lion for a few weeks now, and after a few days of initial annoyance I’ve grown to really like the inverted sense of the scroll wheel. I recall when I first got one, in fact, and found the direction downright confusing. This seems to have been an easy behaviour to unlearn.

My desktop box at work runs Debian, and I wanted the same behaviour there to stop me getting split-brain and dribbling a lot. There was a time when a quick change in xorg.conf to ZAxisMapping "5 4" would do this, but it’s not so the modern age of HIDs and evdevs. After a bit of messing about I figured out how to flip the scroll wheel. This will probably work for Ubuntu too.

  • Open the file /usr/share/X11/xorg.conf.d/10-evdev.conf
  • Look for the section with MatchIsPointer "on". It’s at the top by default.
  • Add this line:
    Option "ButtonMapping" "1 2 3 5 4 6 7 8"

Add more buttons if you need them for your mouse. The section should look like:

Section "InputClass"
Identifier "evdev pointer catchall"
MatchIsPointer "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "ButtonMapping" "1 2 3 5 4 6 7 8"
EndSection

That’s it! Just restart X.