You may wonder how I manage to write one Useful but Unknown Unix
Something blog posting per day. Well, I don t. I write them in
bursts, but don t want to flood Planet Debian and Planet Symlink with
more than one such posting a day.
The first bunch of postings were mostly slides (or part of a slide
plus what I tell while showing the slide) from my Unknown but Useful Unix
Tools talk and written somewhen last week. And this blog
posting and yesterday s blog posting were written in a row, too.
What does that have to do with Unix commandline tools? Well I use
Blosxom as blogging engine and it s based on simple text files
lounging around in some directories, and the last modification time
stamp is the posting s date which is cached after first time seen
by the entries_index plugin so that I can fix typos without resetting
the posting s release date. Postings with a modification date in the
future won t be shown before that time.
So how do you set the last modification date to a date in the future?
With touch from GNU Coreutils of course. Like date ,
touch also knows the option -d to explicity set a date and time
instead of using the current date and time.
Now in my humble opinion the cool feature is that you can easily
describe dates by giving touch values like now + 1 hour , 12:00
tomorrow or so:
$ touch bla $ ls -l total 0 -rw-r--r-- 1 abe abe 0 2010-11-23 22:59 bla $ touch -d 'now + 1 day + 23 hours - 42 minutes' bla $ ls -l total 0 -rw-r--r-- 1 abe abe 0 2010-11-25 21:17 bla $To see all the possibilities you have to describe relative dates with touch , date , and maybe other GNU Coreutils tools, check that you have info installed and call:
$ info '(coreutils.info.gz)Relative items in date strings'Oh, and this whole story about setting modification dates manually to arbitrary values also means that the Tattletale Statistics: Blogtimes November 2010 image in my blog s side bar is absolute nonsense, at least this month. Well, never trust any statistic you haven t faked yourself. ;-) But on the other hand, the dates in the example may give a hint when I really wrote that blog posting. Or not. ;-) And I wonder what my backup tools think about last modification times in the future. Well, they probably only check for modification dates newer than last backup and therefore should be fine. *phew*
Surprisingly, my Monday blog post has received much more attention than I did expect and was source for at least one article full of speculations (in Czech). Hey, there was no new information in the post, nor some secret information leak (not that I know something what is not known publicly).
Anyway meanwhile public announcement about UNIX copyrights has been made. I don't think it changes much, but it seems to be one if things people wanted to know.
What I find more interesting (and hard to read and understand) is explanation of the currently publicly available bits from a transactional lawyer at The Standards Blog. At least it gave me basic idea why some things are so complex in this deal and just confirmed that I want to avoid need for contact with lawyers language as much as possible :-).
Filed under: Suse 0 comments Flattr this!
Okay, so it's been five months since the last update. Sorry about
that. I guess I could force myself to more regular updates.
What have you missed? Only the branching of what will eventually
(soon?) become FusionForge 5.1. Quoting from the default home page,
and in no particular order:
=debian-x mailbox.
Debian XSF News #1
mesa 7.9
was uploaded to experimental by Julien Cristau.xserver-xorg-sun* drivers to experimental for us.mrconfig file to ease downloading/updating all XSF packages,
thanks to the mr tool, and
some bits of documentation. I also
added the git URL
to the upstream repositories to debian/watch* for all packages.DRI, and unfortunately, I
haven t digged into mesa yet, but thankfully we had some answers
from upstream there.xfonts-* packages, prepared by Julien Cristau.x11-* bundles as well. Why are we creating
bundles? Because there are many tiny applications, which (from the
distribution point of view) don t deserve their own package. For
example x11-apps contains toys like xclock, xeyes, or
xlogo.lib* packages, plus pixman. When there were no
fundamental changes (as in: no need for an shlibs bump, which
could prevent some packages from migrating), those were uploaded to
unstable, others went to experimental.libx11, from a stable
branch. The
2:1.3.3-4 version
has been unblocked for squeeze,
and brings support for
Compose O A and for
Compose \ o /.apple:badmap and
apple:goodmap options for macintosh keyboards in
xkeyboard-configuration (which produces the xkb-data binary
package), thanks to a
bugreport from Yves-Alexis Perez;
it s been unblocked for squeeze as
well. If someone notices an inversion of those keys after the
upgrade, that s probably because one of those options was added at
some point, was ignored and unnoticed, and finally taken into
account. Depending on the case, it s sufficient to switch to the
other one, or to remove it entirely.experimental.xserver-xorg-video-mga user (Ferenc W gner), we were
able to extract and apply a patch from
launchpad s #292214
to fix the dual head
breakage. Since we haven t seen any complains since then, we ll
probably ask for an unblock for squeeze.RC1 for
X11R7.6
and it d be nice to keep it that way, but that requires time/work.| [1] | Ike Antkare. Ike
Antkare one of the great stars in the scientific
firmament. April, 2010. http://membres-lig.imag.fr/labbe/Publi/IkeAntkareSub.pdf, retrieved November 25th, 2010. |
Colin Watson is not a high-profile Debian figure, you rarely see him on mailing lists but he cares a lot about Debian and you will see him on Debconf videos sharing many thoughtful comments. I have the pleasure to work with him on dpkg as he maintains the package in Ubuntu, but he does a lot of more interesting things. I also took the opportunity to ask some Ubuntu specific questions since he s worked for Canonical since the start. Read on.
My questions are in bold, the rest is by Colin.
Who are you?
Hi. I m 32 years old, grew up in Belfast in Northern Ireland, but have been living in Cambridge, England, since I was 18. I m married with a stepson and a daughter.
I became interested in Debian due to the critical mass of Debian work happening in Cambridge at the time (and perhaps more immediately because my roommate was running Debian: hey, what s that? ), started doing random bits of development in 2000, and joined as a developer in 2001 (a really exciting time, with lots of new people joining who became integral parts of the project). I d only really been intending to do QA work and various bits of packaging around the edges, and maybe some work on the BTS, but then Fabrizio Polacco died and I took over man-db from him, and it sort of snowballed from there.
I graduated from university shortly before becoming a Debian developer. I worked for a web server company (Zeus), then a hardware cryptography company (nCipher), before moving to work for Canonical in 2004, since when I ve been working full-time on Ubuntu. By this point, I suspect that going back to work in an office every day would be pretty tough.
What s your biggest achievement within Debian or Ubuntu?
One thing I should say: I rarely start projects. Firstly I don t think I m very good at it, and secondly I much prefer coming on to an existing project and worrying away at all the broken bits, often after other people have got bored and wandered off to the next new and shiny thing. That s probably why I ended up in the GNU/Linux distribution world in the first place, rather than doing lots of upstream development from the start I like being able to polish things into a finished product that we can give to end users.
So, I ve had my fingers in a lot of pies over the years, doing ongoing maintenance and fixing lots of bugs. I think the single project I m most proud of would have to be my work on the Debian installer. I joined that team in early 2004 (a few months before Canonical started up) partly because I was a release assistant at the time and it was an obvious hot-spot, and partly because I thought it d be a good idea to make sure it worked well on the shiny new G4 PowerBook I d just treated myself to. I ended up as one of the powerpc d-i port maintainers for a while (no longer, as that machine is dead), but I ve done a lot of core work as well: much of the work to put progress bars in front of absolutely everything that used to have piles of text output, rescue mode, the current kernel selection framework, a good deal of udev support, several significant debconf extensions, lots of os-prober work, and I think I can claim to be one of the few people who understands the partitioner almost top to bottom. 11 comments Liked this article? Click here. My blog is Flattr-enabled.
Just over a month ago I bought a Wikireader [1] from Officeworks (an Australian chain of stores that sell all manner of office supplies). It cost only $99, thanks to Brianna for informing me about this [2]. When I purchased my Wikireader an Officeworks employee had to get one from the back office and told me that I was the first person to buy one. I suggested to him that when a product isn t mentioned in their advertising and isn t put on the shelves it s unlikely to sell in quantity and that they shouldn t rely on bloggers to promote what is possibly one of the most desirable products that they stock.The Wikireader stores a copy of the text of the English language version of Wikipedia on a micro-SD card. They have a service whereby you can get two updates posted to you every year for $29, which would make it pretty close to free once postage and the cost of the micro-SD cards is taken into account. Also you can download new content. I have no immediate plans for updating my Wikireader as the content is more than good enough to answer idle questions while waiting for a bus but as it s lacking external links due to no net access and images it can t be used for serious Wiki reading IMHO.Brianna has documented the process of updating a Wikireader to add more content [3], she added the Chinese version and discovered that inter-wiki links are preserved! I have no immediate plans to add extra content (I don t know any other language well enough to read an encyclopaedia). Also an 8GB MicroSD card (which is the minimum requirement to use multiple languages) costs $35 and is a significant portion of the original purchase price.In terms of functionality the device is pretty good. The screen is not back-lit, but if it was then the two AA batteries wouldn t last anywhere near a year. The screen is not high resolution and the touch functionality isn t particularly accurate or sensitive but I guess that s a necessary trade-off to get the $99 price. The Wikipedia content seems quite complete, so far the only page which I found to be missing was the bio of an Australian architect, I m not sure if his page was removed from the Wikireader to save space or whether my device has a snapshot that predates the addition of the page.The Wikipedia page about downloading the database is interesting [4], it s 6GB of compressed data for the text of the English pages (not including history or talk pages) and for years they haven t even tried to provide a dump of the images. So I guess that a Wikireader that displays pictures is out of the question.The Wikireader has a parental filter, in my quick tests the only page that has been blocked is Sexual Intercourse , I could read all about safe-sex, infidelity, and lots of other related adult topics without being asked for a password. It also shows pages about goatse and other related things without asking for a password NB if you don t know what goatse is then you probably don t want to learn, trust me that it s something that most people won t want their children to learn about. The filter is so bad that I think they shouldn t include it, it will just give people false confidence. It s OK to sell a cheap device that is designed to give a detailed description of goatse etc on request to anyone, but IMHO it s not OK to sell such a device with a claim that it is kid safe and has parental controls . Note that holding down the History button will allow you to clear your history this is useful if you have just verified that goatse isn t blocked and you want to give the device to a young child.There is a button to give a random page, I believe that this would be more useful if it had some metric to make it more often return pages that might be interesting. It could weight the randomness by the length of the page (usually a longer page is more interesting to more people and has more links to other pages) or by some other metric that indicates the potential popularity. Random links often get me pages about obscure country towns and other things that probably aren t of interest to people who don t live near them.But overall this is a great product, $99 is not much to pay, and I recommend getting one!
For the Freaky Wall I have installed a Debian GNU/kFreeBSD system
using the installer with ZFS support announced on:
http://robertmh.wordpress.com/2010/09/06/debian-installer-with-zfs/
I used the mini.iso found on:
http://people.debian.org/~rmh/zfs/kfreebsd-amd64/monolithic/mini.iso
the 12th of October of 2010; as I had some problems and reported them to
Robert is possible that the current image solves part of them.
Installation plan
I did a standard installation on a machine with two hard disks, but only used
the first one from the installer.
The plan was to use ZFS with RAID-1, but current versions of grub do not
support booting from a ZFS + RAID file system, so I had to use the same
technique used for Linux for a long time; three partitions: a swap partition,
a small /boot partition and a big partition for /; / and /boot were
formated to use ZFS.
First reboot
After the installation the system failed to boot because of a bug when
building the /boot/grub/grub.cfg (some routes were missing a //@ prefix);
to be able to boot Iwe edited the config on the grub prompt and later fixed
the file:
--- grub.cfg.orig 2010-10-13 16:40:39.000000000 +0200
+++ grub.cfg 2010-10-13 18:38:47.535436766 +0200
@@ -64,7 +64,7 @@
set root='(hd0,1)'
search --no-floppy --fs-uuid --set a371979bb836d1fe
echo 'Loading kernel of FreeBSD 8.1-1-amd64 ...'
- kfreebsd /kfreebsd-8.1-1-amd64.gz
+ kfreebsd //@/kfreebsd-8.1-1-amd64.gz
insmod part_msdos
insmod zfs
set root='(hd0,3)'
@@ -75,7 +75,7 @@
insmod zfs
set root='(hd0,1)'
search --no-floppy --fs-uuid --set a371979bb836d1fe
- kfreebsd_module /zfs/zpool.cache type=/boot/zfs/zpool.cache
+ kfreebsd_module //@/zfs/zpool.cache type=/boot/zfs/zpool.cache
set kFreeBSD.vfs.root.mountfrom=zfs:dkfbf1-ad4s3
set kFreeBSD.vfs.root.mountfrom.options=rw
I haven't tested the installer since that day, but I believe that the current
ZFS installer was fixed by Robert to deal with that problem.
Once the system was booted I had to fix a couple of things:
dpkg-reconfigure kbdcontrol
/boot partition was mounted on /target/boot, as that was what was
recorded on the ZFS file system; to fix it I executed the following commands:
# zfs set mountpoint=/ dkfbf1-ad4s3
# zfs set mountpoint=/boot dkfbf1-ad4s1
Where dkfbf1-ad4s3 is the root file system and dkfbf1-ad4s1 is the
original /boot.
I reported that to Robert also and I believe it is fixed on the ZFS
installer now.parted; the final result was:
# parted -l
Model: ST3250620NS/3BKS (ide)
Disk /dev/ad6: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 256MB 255MB primary
2 256MB 4256MB 4000MB primary
3 4256MB 250GB 246GB primary
Model: ST3250620NS/3BKS (ide)
Disk /dev/ad4: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 256MB 255MB primary
2 256MB 4256MB 4000MB primary linux-swap(v1)
3 4256MB 250GB 246GB primary
To use the second partition of both disks as swap I added the following to
/etc/fstab:
/dev/ad4s2 none swap sw 0 0
/dev/ad6s2 none swap sw 0 0
To configure the mirroring for the root file system I did the following:
zpool attach dkfbf1-ad4s3 ad4s3 ad6s3
As the /boot can't work as a replica I adjusted it to make two copies of
every file:
zfs set copies=2 dkfbf1-ad4s1
Leaving the second disk copy alone, although my plan is to configure it to
hold a copy of the /boot partition synchronized with rsync each night.
After all those changes the system didn't boot, as the grub-pc generates a
buggy /boot/grub/grub.cfg; the problem is on the /etc/grub.d/10_kfreebsd
section:
### BEGIN /etc/grub.d/10_kfreebsd ###
menuentry 'Debian GNU/kFreeBSD, with kFreeBSD 8.1-1-amd64' --class debian \
--class gnu-kfreebsd --class gnu --class os
insmod part_msdos
insmod zfs
set root='(hd0,1)'
search --no-floppy --fs-uuid --set a371979bb836d1fe
echo 'Loading kernel of FreeBSD 8.1-1-amd64 ...'
kfreebsd /kfreebsd-8.1-1-amd64.gz
set kFreeBSD.vfs.root.mountfrom=unknown:/dev/ad4s3
set kFreeBSD.vfs.root.mountfrom.options=rw
### END /etc/grub.d/10_kfreebsd ###
To fix it there has to be a copy of the modules for ZFS on the boot partition
(in my case I moved the /lib/modules directory to /boot and created a
link on the root partition to the new directory):
cd /boot
mkdir lib
mv /lib/modules lib
cd /lib
ln -s ../boot/lib/modules
And instead of fixing the /etc/grub.d/10_kfreebsd code I wrote a new
script (/etc/grub.d/09_zfs_kfreebsd) that creates the right config for my
current configuration on the grub.cfg file:
#!/bin/sh
prefix=/usr
exec_prefix=$ prefix
bindir=$ exec_prefix /bin
libdir=$ exec_prefix /lib
. $ libdir /grub/grub-mkconfig_lib
prepare_boot_cache="$(prepare_grub_to_access_device $ GRUB_DEVICE_BOOT sed -e "s/^/\t/")"
kfreebsd_versions="$(ls /lib/modules/)"
zfs_root_device="$(zfs list awk '/\/$/ print $1 ' head -1)"
for kversion in $kfreebsd_versions; do
cat << EOF
# Entry when using ZFS (we have issues with /etc/grub.d/10_kfreebsd)
menuentry 'Debian GNU/kFreeBSD, with kFreeBSD $kversion and ZFS' --class debian --class gnu-kfreebsd --class gnu --class os
$ prepare_boot_cache
echo 'Loading kernel of FreeBSD $kversion ...'
kfreebsd //@/kfreebsd-$kversion.gz
kfreebsd_module_elf //@/lib/modules/$kversion/opensolaris.ko
kfreebsd_module_elf //@/lib/modules/$kversion/zfs.ko
kfreebsd_module //@/zfs/zpool.cache type=/boot/zfs/zpool.cache
set kFreeBSD.vfs.root.mountfrom=zfs:$zfs_root_device
set kFreeBSD.vfs.root.mountfrom.options=rw
EOF
done
I solved the problem this way to have a working solution that does not break
with squeeze upgrades, assuming that a future grub-pc package will deal well
with my config and I'll be able to remove this script, but I guess I'll have
to install it from backports.
The entry generated by the script when called from update-grub will be
similar to:
### BEGIN /etc/grub.d/09_zfs-kfreebsd ###
# Entry when using ZFS (we have issues with /etc/grub.d/10_kfreebsd)
menuentry 'Debian GNU/kFreeBSD, with kFreeBSD 8.1-1-amd64 @ ITI' --class debian --class gnu-kfreebsd --class gnu --class os
insmod part_msdos
insmod zfs
set root='(hd0,1)'
search --no-floppy --fs-uuid --set a371979bb836d1fe
echo 'Loading kernel of FreeBSD 8.1-1-amd64 ...'
kfreebsd //@/kfreebsd-8.1-1-amd64.gz
kfreebsd_module_elf //@/lib/modules/8.1-1-amd64/opensolaris.ko
kfreebsd_module_elf //@/lib/modules/8.1-1-amd64/zfs.ko
kfreebsd_module //@/zfs/zpool.cache type=/boot/zfs/zpool.cache
set kFreeBSD.vfs.root.mountfrom=zfs:dkfbf1-ad4s3
set kFreeBSD.vfs.root.mountfrom.options=rw
### END /etc/grub.d/10_iti-kfreebsd ###
And after rebooting the machine with this new configuration the system boots
OK.
On my next post I'll continue explaining how to compile a kernel that supports
the use of the OpenBSD Packet Filter and related technologies (CARP, pflog,
etc.).
Just recently someone asked on #debian.de how to extract the 3rd to
8th character out of some string. That reminded me that the GNU
Coreutils tool cut is also quite unknown.
The solution to his problem is:
$ echo Hurzlipuh cut -c3-8 rzlipuMy favourite usage of cut is to restrict the output of programs which can t do that themselves to 80 columns (common terminal width):
$ dpkg -l grep -i macro cut -c-80 ii docbook-to-man 1:2.0.0-28 ii latex-cjk-common 4.8.2+git20090105-5 ii m4 1.4.14-3 ii mp4h 1.3.1-5 rc swfdec-gnome 2.28.0-1cut can cut out columns based on characters (-c), bytes (-b), fields (-f) delimited by tab (or the delimiter given by -d). After many comments: Yes, dpkg -l is capable of restricting and even fitting its output to the number of available columns if $COLUMNS is passed as environment variable. (And $COLUMNS is set by default in the shell, but not exported as environment variable as it may change on terminal resize or WINCH signal.)
#!/bin/sh
set -e
IMAGES=/boot/images
. /usr/lib/grub/grub-mkconfig_lib
if test -e /boot/memdisk ; then
MEMDISKPATH=$( make_system_path_relative_to_its_root "/boot/memdisk" )
echo "Found memdisk: $MEMDISKPATH" >&2
find $IMAGES -name "*.iso" -o -name '*.img' sort
while read image ; do
IMAGEPATH=$( make_system_path_relative_to_its_root "$image" )
case "$image" in
*.iso)
echo "Found iso image: $IMAGEPATH" >&2
cat << EOF
menuentry "Bootable ISO Image: $(basename $IMAGEPATH sed s/.img//)"
EOF
prepare_grub_to_access_device $ GRUB_DEVICE_BOOT sed -e "s/^/\t/"
cat << EOF
linux16 $MEMDISKPATH iso
initrd16 $IMAGEPATH
EOF
;;
*.img)
echo "Found floppy image: $IMAGEPATH" >&2
cat << EOF
menuentry "Bootable Floppy Image: $(basename $IMAGEPATH sed s/.img//)"
EOF
prepare_grub_to_access_device $ GRUB_DEVICE_BOOT sed -e "s/^/\t/"
cat << EOF
linux16 $MEMDISKPATH raw
initrd16 $IMAGEPATH
EOF
;;
esac
done
fi
P.S. I got the idea and some code snippets from several blog and wiki entries in the net and just added the iso part, so thats not all my code :)
A few weeks ago, I ve been busy at work updating the OFED packaging for OFED 1.5.2. We needed a version of the stack newer than what s (partially) available in Squeeze. As this has now been tested, we are all happy to contribute this work to Debian, courtesy of my customer, EDF.
This morning, I ve pushed out packages for OFED 1.5.2 to the pkg-ofed SVN repository on Alioth. The packages should be made available in experimental at some point too, though a number of them will have to go through NEW.
With this update, I ve cleaned up & updated the packaging where needed and also made two important changes that I need to highlight:
Somebody linked me to this reddit story about the fact that Viewsonic appear to be engaging in the currently fashionable trend of shipping Android devices without providing any source. This one's more interesting though, in that Viewsonic appear to be entirely happy to publicly state that they have no intention of following their license obligations. I've pulled the kernel image for the device and confirmed that it contains code that's not present in the generic Android Tegra tree, so I don't think they have a leg to stand on here.
<quote>"We are working on consolidating and will be distributing the open sourcecode in the coming weeks."</quote>
Sometime you get an UTF-8 encoded text file you want to print. But
most text to postscript converters (often invoked automatically by
your print server) can only render ISO-Latin-1 text files properly and
so you get the notorious et al on your printout.
This is especially annoying at PGP/GnuPG keysigning parties where
nowadays most people have the names in their UIDs encoded in UTF-8.
Fortunately there is paps (Debian package), a Pango based commandline tool to
convert UTF-8 encoded text files into PostScript.
See the paps home
page for a neat example.
Update 02:10 (CET): Funnily the explicitly as HTML
entities à and ¤ written
above got rendered as in Liferea, but only in the Planet
Debian and Planet Symlink feeds, and only until I put that
ä in this paragraph, because both got converted to their
ISO-Latin-1 8-bit equivalent bytes, so that without the ä ,
ä , converted to 8-bit ISO-Latin-1 characters
looks also like an UTF-8 . And Liferea seems to guess the
character set somehow and if it validates as UTF-8, it
uses UTF-8 even if it isn t UTF-8. This is a strange
Planet.
I ve never quit a job before. Well, not a real job. Quitting PC World was more than easy, it was practically required for my soul not to leave my body. Quitting Waitrose was, well, it was a freaking supermarket job. And Southampton football stadium I just stopped turning up after one girl fainted in the kitchen from heat exhaustion. But a real, proper handing in of notice is something new in no small part because I ve been in the same place since my first job as a new graduate.
Not that I m ungrateful, mind. Looking after big iron at the University of Oxford has been pretty awesome more blinky lights than you can shake a stick at but there comes a time when you need to think about your career, and move on to pastures new. I m fairly sure six and a bit years is WELL past that point.
When I started looking at work, I had only a few mandatory criteria a sysadmin job, working with Free Software, without any significant decrease to my monthly income. Beyond that well, in this economy, who am I to argue?
What I hadn t accounted for, however, was a job whose awesomeness can t be contained. A job with a dedicated Free Software company whose entire staff roster, top to bottom, is filled with the most talented, smart, and generally awesome people you could hope to work with. Such a job would be a fevered dream, the mere ramblings of a madman. Yet, somehow, for the second time running, I find myself in an enviable job, working exclusively on Free Software.
Being able to show off root access to a box with 256 cores and a tibibyte of RAM is pretty cool. But you know what s even cooler? A job where I never need to worry about openSUSE 10.1 administration ever again. A job where several of my colleagues are fellow Debian Developers, with all the prestige and knowledge that comes with such a title. And somehow, by rolling proverbial twenties, I find myself in that position.
I am very, VERY proud to say that from the start of January, I ll be joining Collabora Ltd as their new Systems Manager.
I finally took some time to finish my color contrast corrector. It's now able to compare two colors and to tell if they are readable when used as foreground and background color for text rendering. If they are too close, the code corrects both colors so to they'll become distant enough to be readable. To do that, it uses color coordinates in the CIE L*a*b* colorspace. This allows to determine the luminance difference between 2 colors very easily by comparing the L component of the coordinates. The default threshold used to determine readability based on luminance difference is 40 (on 100), which seems to give pretty good results so far. Then it uses the CIE Delta E 2000 formula to obtain the distance between colors. A distance of 6 is considered to be enough for the colors to be distinctive in our case, but that can be adjusted anyway. That depends on reader's eyes. If both the color and luminance distances are big enough, the color pair is considered readable when used upon each other. If these criteria are not satisfied, the code simply tries to correct the color by adjusting the L (luminance) component of the colors so their difference is 40. Optionally, the background color can be fixed so only the foreground color would be adjusted; this is especially handy when the color background is not provided by any external style, but it the screen one (like the Emacs frame background in my case). Here is an example result generated over 10 pairs of random colors. Left colors are randomly generated, and right colors are the corrected one. <style type="text/css"> </style>
bg: DarkSeaGreen4 fg: gray67 -> fg: #4a6b4b bg: #cccccc bg: SlateGray4 fg: forest green -> fg: #9faec0 bg: #005700 bg: grey13 fg: grey36 -> fg: #131313 bg: #6c6c6c bg: MediumPurple2 fg: honeydew -> fg: #9e78ed bg: #f0fff0 bg: grey43 fg: chartreuse3 -> fg: #5e5e5e bg: #79de25 bg: linen fg: DeepPink2 -> fg: linen bg: DeepPink2 bg: CadetBlue4 fg: blue1 -> fg: #6c9fa4 bg: #0000e1 bg: gray33 fg: NavajoWhite3 -> fg: #525252 bg: #cfb58c bg: chartreuse1 fg: RosyBrown3 -> fg: #9cff38 bg: #b28282 bg: medium violet red fg: DeepPink1 -> fg: #9c0060 bg: #ff55b9All this has been written in Emacs Lisp. The code is now available in Gnus (and therefore in Emacs 24) in the packages color-lab and shr-color. A future work would be to add support for colour blindness. As a side note, several people pointed me at the WCAG formulas to determine luminance and contrast ratio. These are probably good criteria to choose your color when designing a user interface. However, they are not enough to determine if displayed color will be readable. This means you can use them if you are a designer, but IMHO they are pretty weak for detecting and correcting colors you did not choose.
Next.