SwirlyMyself

2006-11-21T14:59:03+00:00

Unicode Hack

(No, this is not security related. Some people call screensavers “hacks”. But I did get your attention, didn’t I?)

Whenever I happen to run gucharmap, I like to just browse and have a look at all those weird characters other people, especially asian, are using: A lot of them look really cool. So I thought: This would be a great screensaver.

After some API digging I created that screensaver. It uses fontconfig to open the FreeSans and the DejaVu Sans fonts, selects a random glyph from these and display’s it full screen. Below, the unicode code point and characer name are printed. After a few seconds, the next character is displayed – nothing else, nothing hectic, quite relaxing.

When you download the code, you will find a file “uncode.c”, which is the hack itself, a file “unicode-names.h”, which is taken from gucharmap and only slightly modified, as well as a buch of files from the xscreensaver distribution. To re-compile the binary, use the script “compile”, which runs gcc with flags I stole from the xscreensaver Makefile. I know this build “system” is everything but correct or sensible, but it works for me...

Unfortunately I don’t think it can be included in xscreensaver, as it depends on libfontconfig. If someone would rewrite it using only libX11, this might be possible, so if you like it, feel free to steal the idea.

Comments

Neat hack! I changed the compile script as follows to make it compile on NetBSD (and probably anything that has pkg-config properly installed):

gcc -pedantic -Wall -Wstrict-prototypes -Wnested-externs -I. -I/usr/X11R6/include \
`pkg-config --cflags --libs gtk+-2.0` \
`pkg-config --cflags --libs libpng12` \
`pkg-config --cflags --libs libxml-2.0` \
`pkg-config --cflags --libs libglade-2.0` \
-DSTANDALONE -DHAVE_CONFIG_H -g -O2 -L/usr/X11R6/lib -lSM -lICE -lXt -lX11 -lXmu -lXext -lm -lXft -o unicode *.c
#1 Magnus Henoch am 2006-11-21T20:27:58+00:00
Sounds like a cool screensaver, and would like to see something like this in Gnomes screensaver. Don't know anything about any dependencies there, though.
#2 Stoffe am 2006-11-21T15:46:58+00:00
Should be possible, as Gnome loads these libraries anyways. But as I don’t use gnome-screensaver, someone probably has to adjust the hack to gnome-screensaver’s interface. Should not be hard, if anyone want’s to give it a shot.
#3 Joachim Breitner (Homepage) am 2006-11-21T16:23:06+00:00
Just FYI: you're advertised as having the email address jwz at jwz dot org in unicode.c.
#4 HE am 2006-11-21T15:54:59+00:00
Thx, fixed. It was my test if someone actually reads the code.

No, not really.
#5 Joachim Breitner (Homepage) am 2006-11-21T16:21:41+00:00
I've got a new screensaver now! :)

I inverted the colors, though. They should be configurable.
#6 beza1e1 (Homepage) am 2006-11-22T11:43:26+00:00
Glad someone is using it :-)

Yes, it could be configurable, but I don’t think it’s worth the hassle: It won’t go in the xscreensaver distribution, it is not worth making an extra package, so I’ll just leave it on my blog for interested people, and they can easily change the code. For now at least.
#7 Joachim Breitner (Homepage) am 2006-11-22T12:24:38+00:00

Have something to say? You can post a comment by sending an e-Mail to me at <mail@joachim-breitner.de>, and I will include it here.