Saving some space


The png file format has become the de-facto lossless file format for pixmaps. One of interesting aspects of this format, is that a given image can be compressed in multiple ways, and that most tools only use one. This means that given the right tools, png files can be made smaller without any loss of quality. On Mac OS X, it is very easy to find all the png files in one’s home directory and reduce their size, assuming your have the Developer Tools and Mac ports installed:

sudo port install optipng
mdfind -0 -onlyin ~ "kMDItemContentType=public.png" | xargs -n 5 -0 optipng -preserve

The first line install the optipng tool.
The second line involves three command-line tools:

  • mdfind searches for all files of type public.png in the home directory (~) separating each item with a null character
  • xargs takes the file paths in bunches of 5 (completely arbitrary value) and passes them as parameters to the next command:
  • optipng compresses the files, preserving the file attributes

To be honest I did not bother checking how much space this save me, I just wanted to play around with mdfind… Adding the parameter -o 3 to optipng could save more space, but increase the processing time. Technically you could run this command on the System directory to compress all the png files there, but I don’t think this would be wise. I realise the same technique could be used for jpeg files using jpegtran, if I have some time, I’ll explain how to do it.

Flattr this!

Screen Capture iTunes and Doodle Logo in

Use old style Next-Step icons for commercial e-mail

Screen Capture iTunes and Doodle Logo in

One feature of on OS X that I like is that it shows the picture associated with the sender of an e-mail. The normal way of associating a picture with an e-mail is using the Address Book. While this makes sense for the humans I’m interacting with, I don’t want to add an address book entry for

The good news is, there is an old Next-Step era mechanism that still works, even under Mac OS X 10.7: just add a tiff file with a name e-mail.tiff into the folder ~/Library/Images/People, restart and you are done. So for instance the Flattr logo goes into file ~/Library/Images/People/ If you want to reuse the icon of a desktop application, just open the application’s package (context menu) and go down into the Resources folder and open the Application-name.ics file with copy paste the high-resolution icon into a new file and save it as tiff.

While there is no way to have a file match multiple e-mail addresses, you can avoid duplicating files using symbolic or hard links. On the other hand, those images, contrary to the ones added in address book can contain an α-channel (transparency).

Flattr this!

Python shell with Snake Emoji in the Title

Use Emoticons to distinguish shells

Python shell with Snake Emoji in the Title

One application that has been updated in Mac OS X Lion is the venerable which finally supports 256 colours. While playing around with emoji characters, I realised they were quite useful to mark different terminals. I typically have multiple windows open with local and remote shells, along with a python interpreter. Previously I used the background colour of the terminal to distinguish the various contexts, but now I also add a relevant emoji in the title. Among the useful characters for this use

  • Shell 🐚
  • Snake (Python) 🐍
  • Camel 🐫
  • Computer 💻
  • Bug 🐛
  • Ant 🐜

To add the character to a terminal’s title, just go into Terminal/Preferences, select the Settings Icon and the Window tab. In the Title item, you can enter the emoticon in the title text.

Flattr this!

xlogo: it works

Post Unix OS

The most interesting technical read of last week was undoubtedly . While for consumers the new feature set is very modest, having a software company release a new version of an operation system with mostly bug fixes and performance improvements is something very interesting. I wish others would follow this example. Most engineer know that I you give them enough time, they can improve the code tremendously, most very often this time is not given.

Besides optimizations, Snow Leopard introduces a set of new technologies related to performance. As single core performance is not improving much anymore, this means more parallelism. is a operating system level work-queue management framework. The C language and its variants have been extended to support closures. Those closures can then dispatched to various work-queues. Instead of using a lock to protect a given resource, a serial work queue is created and associated with the resource. Where this gets interesting is that the closures might not run on the CPU: closures are compiled to LLVM code, which might be dispatched on the GPU using Open CL.

Taken separately, none of these technologies is really innovative – there have been numerous projects and language that implemented them. The caveat is that they only solved part of the problem and never managed to gain much traction outside of specialized markets. Here we have an operating system that lets the programmer handle the machine as if it were a small cluster. Code is compiled into some virtual machine code and sent to various processing queues. The number of processors, and their precise instruction sets are irrelevant. While on OS X, the code is only dispatched on the CPU and the GPU, this architecture can be used for sending processing to other machines or add-on processing cards. The grand plan of the Cell processor, where processing could be sent from your mobile phone could sent processing tasks to your TV set might still be relevant. The coolest bit is that most of those technologies are free: Apple open-sourced GCD, LLVM is open source, Open CL is a standard handled by the same group as Open GL.

What is also interesting is that Apple is incrementally replacing traditional part of the operating system with more modern versions. In previous versions Launchd replaced the traditional dæmons, DTrace was used to replaced various system probes. Now Apple has started to replace the tool-chain: clang is a new C-compiler that generates LLVM code, it currently only support C and objective-C, but C++ is in the works. While gcc is the traditional compiler it has many problems, its error handling is horrible, the generated code is far from optimal, more importantly its code base is monolithic and old, this means it is difficult to improve it in any way. Finally gcc is not designed in part as a library (say for integration into an IDE), the GPL license is also a deterrent for such adoption. My hope is that clang will have the same effect on the compiler world that Webkit had on web browser: make things move forward.

Flattr this!

xkbbell & xkbevd

X11 Logo ⓒ MIT

So I started working with Eclipse on Linux. I was hoping to redefine the keyboard shortcuts to use the meta key, as I’m connecting remotely with a Mac OS X laptop and X11. I though it would be an easy task. I was wrong. In KDE applications, this just requires you to select the action, type in the new shortcut and it is done. With gtk2 this does not work. I checked with xev, the key events are the expected one: left-meta. I searched online, no useful information, just other lost users and the nagging feeling that Gnome does not honor the xmod file. Changing the keyboard settings in the gnome-control-center has no effect, this might be related to the fact I’m running a KDE desktop, but I have hardly the choice, on my virtual machine Gnome just crashes. I tried reproducing the issue on my laptop but installing gnome-terminal and launching result in the program dying horribly on launch, probably because there is no gnome desktop running, and plain X11 is way too scary. I have not solved the issue (getting rid of all things gtk would probably be the sanest solution), but digging around I stumbled on a interesting X11 extension: X Keyboard.

I have written a small binary program called xbkgrowl that does the same thing than the script presented here. It does not require any configuration file and does a few other things, link priority translation. Please check it out.

In short, this extension can be used to control the lights and modifiers on the keyboard, it also gives a way of sending notifications to the X11 server. This would be something useful when I’m working on a remote Linux box, streaming back sounds is wasteful and far from stable. On my Mac, I have Growl installed so it would be really convenient to be able to trigger growl notifications. There are versions of Growl, or Growl-like project under linux, and Growl has network support, but this requires a fixed IP adresses, an open port on my Mac, and installing software or at least writing some script. But actually by using the X keyboard dæmon and an old command line you can do this using the X11 connection and without installing anything on the Linux side.

  • Install growlnotify on Mac OS X.
  • Create a configuration file with the following content:
    Bell()  shell "/usr/local/bin/growlnotify --message \"$(name)\" --appIcon X11; true "
  • Start the X11 server (you can just start xlogo)
  • Start the X keyboard dæmon with the following command xkbevd -cfg -bg. This will start the program in background using the configuration defined in
  • You can now trigger a notification using the command xkbbell message, for instance xkbbell "lasers offline". This should work both locally and on remote machines.

    This only works if the X11 display on your Unix box point back to the X11 server on your Mac. You can test this by launching xlogo on the Unix box, it should display the logo on the Mac’s screen. If you have connected using ssh, make sure you selected the -Y option.

Some notes:

  • This is an old protocol (1995) which has never been seriously supported. Use at your own risk.
  • The xkbevd program, is buggy. In particular, there seems to be some issue with the memory buffer used for command substitution, no end marker is inserted, so when a long message is followed by a short one, the short command will have the last characters from the long one at its end. This is why the second command is true, which ignores all its arguments.
  • While the xkbbell command recognises many options, only the volume flag seems to be carried to the server. The volume is in the $(volume) variable, with the value of 50 added.
  • The notifications are carried over NX, but the text message is discarded.
  • There are some standard bell names defined in the header files, but any arbitrary ASCII string seems to work.
  • Instead of growl, you can also use the Mac OS X command say. In that case, the configuration file would be:
    Bell()  shell "/usr/bin/say \"$(name)\" ; true "
  • It is possible to define different actions for different messages, so for instance.
    Bell()  shell "/usr/local/bin/growlnotify --message \"$(name)\" --appIcon X11; true "
    Bell(Warning) shell "/usr/bin/say Warning

I more or less fixed the gtk issue with xmodmap, but this is really a kludge.

Flattr this!

Much ado about nothing

Like many other computer geeks, I’m a regular reader of web-sites like slashdot, or osnews, not to mention a few technical blogs. It is a good source of news, and there are often good technical links, but politics and ideology have the annoying tendency to come to the foreground.

The kernel of the operating system Mac OS X is open-source, that is the source code can be downloaded and compiled freely. There are a myriad of different open-source projects which are distributed under different licences, with very strong debates about which licenses are more free, better, etc. I must admit that my interest in those debates is very limited.

One of the latest scandal in this online community was the fact that Apple did not distribute the source code for the Intel version of Mac OS X. People reacted very violently, which was kind of strange because Mac OS X’s kernel, Darwin, dit not gather so much interest when it was open. But post were posted, and blog entries written decrying the fact that Apple reneged their committement to open-source, that it was the begining of the end. The closing of the web site open-darwin, which hosted most of the Apple-related open-source project fueling the whole debate…

Nobody seemed to take the common sense approach: Apple had just moved their main OS to another architecture (intel), and their source code tree would probably be a mess. As the OS contains proprietary bits, some licenced from another companies, the lawyers of the company would probably not want anything published until everything had been checked. Not to mention engineers who would like to have some time to clean up things.

Of course, if you took the common sense explanation, the fact that the source code of the kernel is now available for intel and a new web site hosting Mac-related open source projects opened would not be a real surprise…

Flattr this!

Leopard mockups

Apple should soon show of what the next version of Mac OS X, named Leopard, will show in improvements. As usual, there are plenty of rumors and fake screen-captures circulating on the internet. One web site, took the idea further, and organized a contest of fake Leopard screenshots. The winners have now been selected and I must say I like the ideas of the winner a lot.

The main area of improvement is Mac OS X’s file browser, the Finder. This application has been criticized a lot, it is slow, not very consistent and in general the weak point of OS X. I can’t say I love the finder, but the truth is, I increasingly do my file-system navigation from the command-line, switching back and forth with drag-and-drop and the open command. The proposed improvements include tabs, the possibility to use large icons / preview in the last column of the column mode (the mode inherited from Next I use most) and the possibility to filter by file-type (in a way that is similar to what search does in I’m not so convinced by the capacity to preview many file-types within the file-system browser, Konkeror offers this option, but I’m not convinced.

Flattr this!

OS X sur Intel

Ces jours, il y a eu beaucoup de bruits concernant Mac OS X. Plus précisément, des gens ont réussi à faire tourner la version développeur du système d’exploitation OS X sur des PC génériques. En soi, cela n’a rien de très étonnant, vu que Darwin le noyau open source, tourne déjà sur des PCs génériques, et que la version PPC fonctionne dans un émulateur PPC. Il est clair que la situation sera un peu différente avec la version finale de l’OS, peut-être à cause de mesures qu’Apple aura pris, très probablement surtout à cause de changements internes entre les versions de développement et la version finale. La question que beaucoup de gens se sont posées est naturellement, que va faire Apple ? Naturellement, je ne peux proposer que des conjectures gratuites, n’oublions pas que ceci est un blog.

Tout d’abord je doute que les gens d’Apple ont un plan précis. Le changement d’architecture a été passablement abrupt, et à ce stade ils auraient tord d’exclure des possibilités. À une extrémité du spectre des possibilités, Apple vend son OS pour des machines génériques, et ses propres machines ne sont qu’un cas spécial, à l’autre extrémité, OS X ne tourne que sur les machines Apple et l’authenticité du hardware est vérifiée grâce à des puces de sécurité. Naturellement, les choix sont surtout dictés par des considération commerciales, mais au delà il reste une question techniques, celle des drivers

Les drivers sont les composantes logicielles qui assurent l’interface entre le système d’exploitation et le matériel. Sans drivers, l’OS ne peut tout simplement rien faire. Le problème, c’est qu’écrire des drivers est une tâche ardue. D’abord parce qu’un des rôles du système d’exploitation est de simplifier la programmation, cette aide n’est pas disponible quand on programme un driver, qui s’exécute dans le système d’exploitation. Ensuite quand du hardware est fabriqué, un certain nombre de choses sont prises en compte: simplicité, réutilisation, performance, mais en général, concevoir du hardware pour que le driver soit simple est quelque chose d’assez rare. C’est une tendance qui a tendance à s’atténuer pour des composants génériques, comme les appareils photos ou les clefs USB qui partagent en fait le même driver générique USB, mais cela reste l’exception plutôt que la règle.

Or pour faire tourner OS X sur du matériel il faut des drivers. OS X contiendra des drivers pour le matériel Apple, et certains types de hardware génériques, mais cela ne suffira pas pour faire fonctionner la pléthore de matériel qu’on trouve dans le monde PC. À ce niveau, il faut comprendre qu’il y a de nombreuses interprétations de la phrase ce système d’exploitation fonctionne sur telle machine, la plus brute est que le système est capable de parler aux composantes de base : le processeur, la mémoire, un contrôleur disque et un disque. Si on ajoute une carte réseau, c’est suffisant pour faire tourner un serveur, à l’autre extrême le système d’exploitation est capable de gérer toutes les fonctionnalités de la machine, ce qui inclut les fonctions de veilles de la carte mère, le son, et la carte graphique avec de bonnes performances. Avec des drivers génériques et de l’émulation, on peut très vite arriver au premier niveau. Arriver au second requiert les bons drivers ce qui demande beaucoup de travail. Il faut noter que les autres systèmes d’exploitation ont le même problème, trouver les bons drivers pour avoir toutes les fonctionnalités d’un laptop sous Linux n’est pas toujours simple.

Techniquement, rien n’empêche qui que ce soit d’écrire des drivers pour un matériel donné pour Mac OS X que ce soit la version PPC ou la version i8086. Un exemple notable est le project XPost-Facto. Ce projet gère une série de drivers permettant de faire tourner OS X sur de vieilles machines qui ne sont plus supportées par Apple. Naturellement, dans ce cas, comme il s’agit de matériel Apple, le projet a droit, sinon au support, au moins à l’indifférence de Apple. Le projet semble être partiellement supporté par des compagnies qui vendent des cartes accélératrices. Malgré cela, le niveau de support reste assez approximatif : beaucoup de composantes ne fonctionnent pas, ou pas complètement. Par exemple, j’avais reçu d’Alias un vieux G3 beige sur lequel j’avais joué avec XPostFacto et les composantes suivants n’était pas reconnus:

  • Le lecteur de disquettes
  • La carte vidéo accessoire
  • La cache de niveau 2 du processeur
  • La fonction de veille

Outre cela, l’OS était incapable de gérer la souris ADB Logitech qu’Alias m’avait donné avec la machine, heureusement j’ai trouvé une souris Apple dans les poubelles du CERN. Bref si la machine fonctionnait à peu près, et pouvait servir de serveur, comme machine pour travailler c’était vraiment pas ça.

Si je n’ai aucun doute que quelque soit les protections qu’Apple mettra en place pour éviter que leur OS tourne sur du matériel non Apple, elles seront brisées assez rapidement. Par contre, je suis moins sûr en ce qui concerne les drivers pour les cartes mères qui ne sont pas de Apple. Car les cartes de Apple seront probablement assez différentes vu qu’elles n’ont aucun besoin d’être compatibles avec 30 ans d’histoires de PC. Dans ce conditions, je soupçonne qu’Apple se contentera de mettre des protections symboliques, suffisantes pour que personne ne puisse prétendre avoir installé l’OS par erreur et laisser les enthousiastes écrire des drivers, surtout si ce faisant, ils écrivent des drivers pour leurs périphériques – ce qui intéresserait Apple beaucoup plus.

Flattr this!

Un grand changement

J’ai horreur de parler de la même chose que tout le monde, mais je suppose qu’il faut parfois faire des exceptions. Hier, Apple a annoncé qu’ils allaient utiliser des processeurs Intel dans leur machines. Cette nouvelle est une petite révolution dans le monde informatique, ou Apple a depuis des décennies toujours utilisé des processeurs différents de la série 8086 dominante. Je dois avouer avoir été surpris – la rumeur que Apple veuille changer de processeur est récurrente, ce qui fait que là encore, je l’avais fondamentalement ignorée. Dans le faits j’aurais dû réaliser qu’elle se réaliserait tôt ou tard simplement au vu des discussion sur slashdot. En effet, je réalise que la majorité des changements techniques faits par Apple depuis l’introduction d’OS X étaient en général des idées qu’on trouvait sur ce forum durant l’année précédente.

Cela dit, qu’est-ce que ce changement implique? Pour moi, honnêtement, pas grand chose, je ne vais probablement pas acheter de nouvelle machine avant deux ans. La plupart des applications que j’utilise sont soit des composant open-source (qui sont généralement portés depuis la plate-forme Intel), ou des applications récente ou produites par Apple directement, i.e qui peuvent être portées facilement. Dans les faits, le gros problème sera pour exécuter les applications qui ne peuvent être recompilées, ce qui veut dire principalement les jeux. Dans ce cas, l’espoir est surtout que le gain de puissance soit suffisant pour que l’émulation puisse se faire à une vitesse acceptable.

D’une manière générale, cette annonce confirme surtout une tendance générale, qui est que le modèle exact du processeur n’est plus si important. Ironiquement Microsoft a quitté la plate-forme Intel en faveur de processeurs PowerPC pour la XBox 2. Les processeurs sont une commodité que l’on change selon les besoins. En ce qui concerne Apple, je soupçonne que le changement vont surtout affecter les anciens clients rois de Apple, c’est à dire les applications de mise en page, il y a fort à parier qu’il faudra beaucoup de temps à Quark pour porter XPress vers OS X/Intel. En fin de compte, cela montre surtout que Apple est en train de s’aligner beaucoup avec le monde Linux, et qu’OS X se positionne de plus en plus comme un Linux plus facile à utiliser.

Comme d’habitude, John Siracusa d’ a une analyse assez fine de la situation (qui n’est plus disponible sur le web).

Flattr this!