Saturday, April 30, 2016

Getting Custom Compose Key Sequences to Work in Debian: The Odyssey

Having just spent a very frustrating afternoon trying to get custom compose key sequences working on my new Debian install, I figured I would write a quick post to help others who might be in the same boat.

(For those who don't know, the compose key is a metonym for a fabulous system in Linux that lets you easily type thousands of symbols not found on keyboards. It usually has to be enabled in keyboard settings and can be set to a wide number of keys, but usually the right Windows or Alt keys are popular. Once you have it enabled, you can simply type <Compose Key>-^-a to get â. Or <Compose Key>-"-o to get ö. Or <Compose Key>-o-c to get ©, and so on and so on. There are typically hundreds or thousands of such combinations available by default, ranging from letters from common and uncommon languages to all sorts of esoteric symbols and punctuation [such as the interrobang, ‽, Compose Key-!-?]. Many of them are set up with key combinations that sort of make sense based on the component parts so it's often easy to guess without needing to specifically remember all the combinations. However, I digress.)

This all started with my desire to type some Hawaiian this afternoon, and for that I needed an ʻokina, the letter ‘ʻ’ at the start of the word ʻokina (which is not a quotation mark, despite how it looks; it's Unicode symbol U+02BB, “MODIFIER LETTER TURNED COMMA” [‽]). This is one symbol that isn't in the extensive list of default compose key sequences, but it's not too difficult to add your own—by default in Linux Mint Debian Edition (and I'm guessing plain Debian) there's a file in your home directory called .XCompose where you can simply look at the syntax of all the other entries and define your own sequence based on that.

This file came over in my transfer to Debian, and from what I could find it was what you used to define custom compose key sequences there too, but my sequence I'd added to print an ʻokina in LMDE simply wasn't working, nor were any of the additional ones I created as further tests. (Testing is pretty simple because the .XCompose file is read by programs each time they start up, so you can make a change, re-open a terminal or another text editor, and immediately try it out.)

From some more Googling and reading around, I found the suggestion to add the phrase
export GTK_IM_MODULE=xim # Warning, see below.
to my .profile file in my home directory. Now I'm not super-clear on what all of this means myself, but as best I can tell IM refers to “input method,” and xim refers to an older and more limited input method used by the X server that handles graphical things on Linux. GTK is a toolkit (bunch of code) for making graphical user interfaces that underlies quite a lot of software, along with another toolkit, Qt, and they apparently both have their own internal input methods that seem to not allow custom compose key sequences.

Anyway, what I'm actually trying to say here, is that the above code does not appear to work anymore, although it apparently did in the past. With it in place my custom compose sequence no longer beeped at me angrily like it did before, but simply silently failed with no output. After several hours of following comments in Stack Trace and nearly a score of reboots and reloggings in a futile effort to get things to work, I finally chanced upon a comment suggesting the use of “uim” instead of “xim” (‘u’ for ‘universal;’ I think it's a newer input mode with more functionality). This finally worked for me so I've added the following lines to my .profile file (I added the QT one for completeness, though I don't know how necessary it really is):
export GTK_IM_MODULE=uim
export QT_IM_MODULE=uim
Once you've done that, you'll need to make sure you have the actual uim package installed; on Debian, run
$ sudo apt-get install uim
Once you've done that, log out and log back in and things should hopefully work now. Hope that helps! As for me:

◦ Confounding compose key conundrum: cracked!

Wednesday, April 27, 2016

Distrohopping to Debian

Well, after about two months of waffling, I finally went ahead yesterday and installed Debian (short ‘e’ as in ‘bed’ if you're curious) on my desktop like I've been meaning to. And it wasn't even all that difficult, actually!

When I first decided to switch to using Linux as my main operating system over two years ago, I took a look at the dizzying number of distros out there, and…

…actually, let's back up and establish some terminology first. “Linux” isn't an operating system like Windows or Mac OS, per se. It's the name of a kernel—the central core of an operating system, that loads first and handles all the interactions between all of the programs and the hardware. Linux is often used however as a metonym (technically, a synecdoche) for the many different operating systems built on top of the Linux kernel. These usually go by the name distributions, or distros for short. Some popular ones are Linux Mint, Debian, Ubuntu, openSUSE, Fedora, and Manjaro (taken from What distinguishes one distro from another could be anything—large things like what kind of packaging system they use (so that software packages created for one distro won't work on another) to cosmetic things like what desktop manager they use (many distros allow you a choice of several) to a million and one little variables that can be tweaked such as the default programs included. There are literally hundreds of distros out there, though the vast majority of them are based on just a handful of main distributions (since it's a lot easier [relatively speaking] to create a new distro by modifying an existing one than it is to create one from scratch). Anyway, back to what I was saying…

When I first decided to switch to using Linux as my main operating system over two years ago, I took a look at the dizzying number of distros out there, and decided to go with Linux Mint Debian Edition, or LMDE. Let's unpack that a bit:

  • Linux Mint (by itself) is a very popular distribution made to be easy-to-use out of the box and good for Linux newcomers. It's based on…
    • Ubuntu, long and widely considered the most popular distribution partly due to a similar reputation, which is itself based on…
      • Debian, one of the oldest distributions, dating all the way back to 1993 and the distribution with the largest number of distros based upon it.
Anyway, as you can see, Linux Mint is basically two steps removed from its original base. A few years ago a new distro called Linux Mint Debian Edition was introduced, based directly on Debian and cutting out the middleman of Ubuntu so to speak. I liked the idea of keeping things simple, and since I was still a relative newcomer to Linux I decided to stick with a distribution with a reputation for user-friendliness.

Fast forward to today, and with a few more years' experience with Linux under my belt I decided to once again ‘cut out the middle man’ and switch directly to Debian itself. I'm no power user, but I know my way around a command line interface well enough, and I feel there's a benefit to using a more widely-used distribution (LMDE was, unfortunately, always kind of a side project to the main Linux Mint version).

Debian apparently used to have a reputation for being difficult to install, but I found the whole installation process for Debian 8.4 “Jessie” pretty simple, even with my setup having root and home installed on different partitions. (Which allowed me to keep all my user data when switching; very convenient!) I had a few wrinkles along the way, to be sure; I've got a separate hard drive for storing all my big files that don't need to take up space on my SSD like photos and music, and had forgotten how my more Linux-experienced friend Graham had mounted and linked it when we first set up my computer (the drive was actually auto-mounted and I could access it, just not the way my shortcuts were set up to expect). Thankfully, Graham was able to swing by after work and get it sorted, and with my current level of experience I think I could duplicate it in the future if necessary. There've been a few more small issues but so far I've been able to solve them all, and it looks like everything is working.

Oh, and to explain the title, it's a tongue-in-cheek reference to “distrohopping,” the practice of trying out lots of different Linux distros, sometimes without any sort of “main” distribution. Obviously, trying a second distro in as many years doesn't exactly qualify. A hui hou!

Monday, April 18, 2016

Vectorizing Flags

The Europa Universalis IV wiki had a contest running for the last two weeks to help get things updated after the new 1.16 patch, but along with all the needed text was a request for higher-resolution versions of a whole bunch of country flags which previously existed only as tiny 192x128 pixel images. I figured it'd be a fun chance to brush up on my Inkscape skills, so I vectorized a number of flags and created higher-resolution versions. I'm pretty happy with how they turned out, so I thought I'd share some of the more interesting ones. These aren't actually the vector images themselves, just PNGs, as SVG images often still don't play well with some web browsers.

Berar is a small Indian nation that doesn't exist at the start of the game in 1444, but can appear later on. This one was a fun exercise in tracing the entire outer shape, followed by removing the cutouts using the difference operation on a series of paths with the main one. (A path in Inkscape is essentially any arbitrarily shaped object defined by a series of vertices and spline curves between them such that they define either a curve or an area. They can have a large variety of mathematical Boolean operations such as union, difference, intersection, exclusion, etc. applied to them. This lets you build up a path from a collection of smaller paths, or, as in this case, punch out a bunch of holes in a large path.)

Caddo is a North American nation from the Mississippi region. Of course, whether they ever actually had a flag like this questionable; all nations in EU IV require a flag for identification, but given that it covers the whole world from 1444 to 1821 there are a lot of little nations that likely never had an official flag, so Paradox Interactive has to come up with something based on…I don't know, really, presumably important symbols in that nation's history and the like. Anyway, regardless of its historical veracity, I like the geometric shapes on this one.

Kazembe is a small nation in the interior of Africa, one of the new nations added in the 1.16 patch in fact. This one was a massive amount of fun to trace for some reason despite (or maybe because of?) the slight asymmetries present throughout the entire thing.

Quito is a small nation in the Andes, in modern-day Ecuador (and lending its name to Ecuador's capital). This is another nice set of geometric shapes (I did tend to pick ones that would fairly quick to do, rather than ones having complicated images).

Riga is a tiny nation on the Baltic Sea in 1444, now the capital of modern-day Latvia. That staff on the right took a lot of time trying to replicate all the little bumps in the original image (and having to guess a lot, given the tiny resolution). Most of the bumps are actually small circles added to the path of the staff.

Sioux is a nation in the Great Plains region of North America, with some cool geometrical shapes. Getting the rotation and placement of the tipi shapes around the edge was an interesting challenge. (Also, go read the article on tipis on Wikipedia, it's pretty interesting.)

Tarascan is a Mesoamerican nation towards the western edge of the region, and historically one of the largest rivals of the Aztecs. Similar to the Berar flag, this is just a large circle (with a radial gradient) with a whole bunch of shapes punched out of it.

Tyo is another of the new Central African nation added in the 1.16 patch. This was a great chance to use a clipping mask; each of the little half-circle shapes is actually part of a full, nearly-circular ellipse, with a copy of the brown background circle serving as a clipping mask so you only see the parts of them inside the circle. This one was quite fun to do.

Yaka is the third new Central African nation here (being new, they didn't have high-resolution flags so there were several to do). This was a pretty simple case of vector tracing.

Finally, here's the flag of Kutai, a small nation on the eastern shores of Borneo. This one took a lot longer than the others (which typically took less than twenty minutes) due to the amount of detail present:

I did this one because I really liked the original flag, and once played a game as Kutai partly because of that. By the way, here's the original file I was working from (I'm not sure why the tiger's tongue is orange):

Yep, that's the actual size. (Same for all of the other flags, of course.) While most of it wasn't too difficult to vectorize (just time-consuming), I couldn't really recover any detail from that crown thing, so I kind of made something up based on what I thought it was supposed to look like.

All in all, a fun little project, and it's been fun to get back to working with vector images again. A hui hou!

Thursday, April 7, 2016

Keeping Busy, with Art!

Well, here I am, unemployed for the first time in…over five years, I think? It's strange to have this much free time on my hands, but by no means unpleasant. Apart from the usual stuff of looking around for a new job, I'm relishing the chance to get back to doing something I haven't done as much of lately: art.

I've never really considered myself much good at doing real-world pencil-to-paper type art, so when I discovered programs like Inkscape, GIMP, and Blender, I was quite excited. I've spent many happy hours playing around with each of them, but with a full-time job I found I just didn't seem to have as much creative energy left at the end of the day. (Probably because I was often spending a lot of it at work coding!) With all this free time on my hands, though, I'm looking forward to getting back into creating more visual stuff again.

In fact, I got back into Blender this week, and came up with some simple but neat-looking stuff. I haven't used Blender for even longer than Inkscape or GIMP (due to occasionally having need of 2D image manipulation but not much need for 3D modeling) so I was worried I'd need to completely relearn it, but it looks like quite a lot of it is coming back to me already after a little brushing up. Monday I created a simple test of Blender's more physically-accurate renderer Cycles with a small brushed-metal model and some simple lights:

I think it came out pretty nicely for not having used Blender in a few year (and not really using Cycles even at that point, as it was pretty new back then). I'd like to really push my Blender skills and improve them while I have the chance, so I'll probably have more practice work to post on this blog in the next few weeks. And maybe some other stuff too, who knows? A hui hou!