Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to display Chinese characters in dwm's status bar. More specifically I would like the symbols to represent the different tags in dwm. Using an online converter, I found that the unicode representation for the symbols I want is:

憤怒
unicode: 憤怒

Putting the unicode characters directly into my config.h doesn't work, they don't even show up in vim. My locale is set to ISO-8859-1 and I'm using the Liberation Mono font for dwm.

What can I do to get those symbols up there?

EDIT Following Mat's instructions and patching dwm, the patch command hangs. Running strace:

[max@prometheus dwm-6.0]$ strace patch -Np1 ../dwm-pango/dwm-pango/dwm-6.0-pango.patch 
execve("/usr/bin/patch", ["patch", "-Np1", "../dwm-pango/dwm-pango/dwm-6.0-p"...], [/* 30 vars */]) = 0
brk(0)                                  = 0x1d52000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9dc4713000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=92801, ...}) = 0
mmap(NULL, 92801, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9dc46fc000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\25\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1983446, ...}) = 0
mmap(NULL, 3804112, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9dc4152000
mprotect(0x7f9dc42e9000, 2097152, PROT_NONE) = 0
mmap(0x7f9dc44e9000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x197000) = 0x7f9dc44e9000
mmap(0x7f9dc44ef000, 15312, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f9dc44ef000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9dc46fb000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9dc46fa000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9dc46f9000
arch_prctl(ARCH_SET_FS, 0x7f9dc46fa700) = 0
mprotect(0x7f9dc44e9000, 16384, PROT_READ) = 0
mprotect(0x61a000, 4096, PROT_READ)     = 0
mprotect(0x7f9dc4714000, 4096, PROT_READ) = 0
munmap(0x7f9dc46fc000, 92801)           = 0
brk(0)                                  = 0x1d52000
brk(0x1d75000)                          = 0x1d75000
getpid()                                = 10412
lstat("/tmp/po8GP02f", 0x7fffdc075210)  = -1 ENOENT (No such file or directory)
lstat("/tmp/pikSWXEs", 0x7fffdc075210)  = -1 ENOENT (No such file or directory)
lstat("/tmp/prB1wVgF", 0x7fffdc075210)  = -1 ENOENT (No such file or directory)
lstat("/tmp/pp27ATSR", 0x7fffdc075210)  = -1 ENOENT (No such file or directory)
rt_sigaction(SIGCHLD, {SIG_DFL, [CHLD], SA_RESTORER|SA_RESTART, 0x7f9dc4186cb0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGHUP, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGHUP, {0x40cd90, [], SA_RESTORER, 0x7f9dc4186cb0}, NULL, 8) = 0
rt_sigaction(SIGPIPE, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGPIPE, {0x40cd90, [], SA_RESTORER, 0x7f9dc4186cb0}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTERM, {0x40cd90, [], SA_RESTORER, 0x7f9dc4186cb0}, NULL, 8) = 0
rt_sigaction(SIGXCPU, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGXCPU, {0x40cd90, [], SA_RESTORER, 0x7f9dc4186cb0}, NULL, 8) = 0
rt_sigaction(SIGXFSZ, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGXFSZ, {0x40cd90, [], SA_RESTORER, 0x7f9dc4186cb0}, NULL, 8) = 0
rt_sigaction(SIGINT, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {0x40cd90, [], SA_RESTORER, 0x7f9dc4186cb0}, NULL, 8) = 0
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
open("/tmp/pp27ATSR", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600) = 3
fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9dc4712000
lseek(3, 0, SEEK_CUR)                   = 0
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9dc4711000
read(0, 

Could I be missing something?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

I don't think you'll get Unicode support from dwm without patching it (and adding additional dependencies, notably pango).

If that's an option for you, the Arch package dwm-pango seems to work. (Download the tarball, unpack it, and patch your dwm with the patch file - you don't need to be using Arch. Patch applies with a bit of fuzz on top of dwm-0.6.)

$ tar xzf dwm-6.0.tar.gz 
$ tar xzf dwm-pango.tar.gz 
$ cd dwm-6.0
$ patch -Np1 < ../dwm-pango/dwm-6.0-pango.patch 

After that, you can edit your config file and put unicode literals (\u followed by the unicode codepoint in hex) in the tags strings for example.

/* tagging */
static const char *tags[] = { "\u00c0",
                              "\u61a4\u6012",
                              "\u10e5\u10d0\u10e0",
                              "4", "5", "6", "7", "8", "9" };

First item is À, second are your two symbols, third is some Georgian script ('cos I think it looks cool).

With a large font, this results in:

enter image description here

share|improve this answer
    
Thanks for an awesome answer. I'm currently giving this a try. I've never patched anything before so this is a bit of a learning experience :) –  MaxMackie May 13 '12 at 17:14
    
I tried patching and I'm getting a weird error. patch seems to be hanging. Please see my post for an strace –  MaxMackie May 13 '12 at 17:46
1  
Oouups sorry about that. Patch doesn't read from the argument you pass it, it reads from stdin. Updated my post, you need to patch -Np1 < patch.file . –  Mat May 13 '12 at 17:47
    
I got the patch on correctly, thanks. However, once I've changed my tags, rebuilt dwm and restarted, my statusbar basically disappears (it looks like its taking about 5 pixels but has no text). Could the patch have messed something up? I didn't have any other patches before this one. –  MaxMackie May 13 '12 at 17:58
2  
Did you copy/reuse your "original" config.h? If so, make sure you change the font entry too. X font selector strings don't seem to work with this patch. Try static const char font[] = "Sans 14";. (BTW, use Xnest to try your changes, much better than restarting your desktop all the time.) –  Mat May 13 '12 at 18:08
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.