Using EMMS on OS X

I spend most of my tube time in Emacs. Many years ago I used mpg123.el to play music in Emacs. For some reason, perhaps because I started using more audio formats, I changed to other music players. I mostly used mpd with ncmpc.

When I made the switch to Macintosh I continued to live in Emacs but continued to use terminal-based music players. No longer! It's time Emacs did what it does best… er… play music!

Install mpg321, flac123 and libtag from Homebrew.

Clone latest version of EMMS from git:

% git clone git://git.sv.gnu.org/emms.git
% cd emms
% make

Copy the emms-print-metadata program (that uses libtag to be able to edit music metadata) to my program directory:

% cp src/emms-print-metadata ~/bin/

Add to ~/.emacs.el:

; Emacs Multimedia System (EMMS)
(add-to-list 'load-path "~/hacks/emms/lisp")
(require 'emms-setup)
(emms-standard)
(require 'emms-tag-editor)
(require 'emms-info)

; Use only libtag for tagging.
(require 'emms-info-libtag)
(setq emms-info-functions '(emms-info-libtag))
(setq emms-info-libtag-program-name "/Users/mc/bin/emms-print-metadata")

(emms-default-players)
(setq emms-source-file-default-directory "~/Music/")

; Play FLAC with flac123.
(define-emms-simple-player flac123 '(file) 
  "\\.flac$" "/usr/local/bin/flac123")
(add-to-list 'emms-player-list emms-player-flac123)

; Add music file or directory to EMMS playlist on ! in dired.
(define-key dired-mode-map "!" 'emms-add-dired)

Note well: Tag information won't work if you have spaces in file names.

If you really need to change large amount of files and directories, consider using the Perl rename script from Homebrew and then do:

% find . -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;

over your music collection.

First day at new job

First day at the new job at a university library!

Flying to Uppsala was uneventful, but as usual included a 'random' pat down at the airport, and some much colder weather than expected.

Half the day was spent in meetings, then some tech stuff where I was brought up to speed with the systems I'll manage. More of the same tomorrow.

I'm now at the hotel, with a beer and a sauna.

First day's t-shirt: “We come in peace”, 27C3's official t-shirt.

Tomorrow's t-shirt: “Miscatonic University, Arkham, Mass.”.

Today's music: Sidewalking, The Jesus and Mary Chain.

FreeBSD serial console on another port

On many of my FreeBSD servers I use a serial console. It's pretty straightforward to set up as the Handbook illustrates.

Combined with a serial port server with SSH access (thanks XS4all!) or, say, HP's iLO which can also provides SSH access to the serial port it's a very nice way to be able to access your server even if you need to boot to single-user or if you locked yourself out. Even better, combine this with a firmware that knows something about console redirection and you also get at the BIOS setup over the same port.

I recently found myself in a situation where I couldn't use COM1 as the serial console port on a new server. The Handbook says:

If there is no COM1 (sio0), get one. At this time, there is no way to select a port other than COM1 for the boot blocks without recompiling the boot blocks.

[…]

25.6.4.2. Using a Serial Port Other Than sio0 for the Console

Using a port other than sio0 as the console requires the boot blocks, the boot loader, and the kernel to be recompiled as follows.

which sounds a bit scary. I'm not foreign to the notion of running a customized kernel. However, on a stock x86 server in co-lo which I hope to be able to update with freebsd-update(8), I don't really want to run a custom kernel. Thinking it through a little and looking at the uart(4) manual page I got an idea.

There is an alternative to compile your own kernel, and I admit it might fall under the tip “get one” above: Change your COM3 (or whatever) to COM1! Here's how I did it:

Normal /boot/device.hints lists the first serial port as:

hint.uart.0.at="isa"
hint.uart.0.port="0x3F8"
hint.uart.0.flags="0x10"
hint.uart.0.irq="4"

Note that sio(4) as mentioned in the Handbook is not listed in device.hints anymore.

The serial port I want to use as console is on the PCI bus, so I changed uart.0 to:

hint.uart.0.at="pci"
hint.uart.0.port="0xEC00"
hint.uart.0.flags="0x10"
hint.uart.0.irq="B"

and it just works! The details were taken from what the BIOS setup told me about what it called “COM3”. The AMI BIOS of a Supermicro C7X58 motherboard can see at least a 16C550 compatible PCI serial cards just fine.

If you later want to enter the BIOS setup over the serial port, use ESC 4 when it tells you to press F4. Move around by pressing arrow keys and TAB after each arrow key.

Personality types

[Corrected spelling.]

During the mid-90's there was a brief fad of doing web-based personality tests in my small part of Swedish hackerdom. Typically you would then publish your result in your .signature, customised mail header, finger-able .plan file, those newfangled web pages or some corresponding metadata.

It was seen as a good thing to qualify as an INTP or INTJ in the Myers-Briggs Type Indicator system. I think it may have originated with Eric Raymond's famous A Portrait of J. Random Hacker, an appendix in ESR's version of The Jargon File based on questions posed to readers of a Usenet newsgroup back in the Olden Days.

I'm usually sceptical about personality tests and about many psychological tests in general. It's often much too easy to fake the result and many of them have poor test-retest results. The exception, perhaps, are depression scale tests like Montgomery-Åsberg Depression Rating Scale, which I believe are genuinly useful and occassionally lifesaving.

But of course I fell for the group pressure. So I did a test. I seem to remember it was some bastardised form of the Keirsey temperament sorter combined with Myers-Briggs, probably an abridged version of the 'real thing', if there is such a thing. I ended up as Architect/INTP. Quotes from the Wikipedia page on the Architect role:

[…] introspective, logical, rational, pragmatic, clear-headed, informative, and attentive.

Architects are designers of theoretical systems and new technologies. Rearranging the environment to fit their design is a distant goal of Architects.

Time passes…

In 2009 my wife was handpicked for a series of leadership courses. Myers-Briggs testing was a part of the course. I piggybacked on the test and finally did a 'real' Myers-Briggs test. Like many tests I found that it probably would be easy to fake a result that you want, but I decided to do this one honestly.

One of the funny things with the real Myers-Briggs test, at least as it was given in this course, is that as a part of the test you were supposed to guess your result! I guessed, based on the earlier experiences with the (uncomplete and online) Keirsey/MBTI test that I would end up INTP (although I know that there is much debate that Keirsey's INTP and Myers-Brigg's INTP are different things), but…

Result: ISFP with only a slightly higher S over N, rather ISFP than INFP.

Some descriptions of the ISFP type:

You can find the corresponding INFP descriptions easily. Et cetera ad nauseam.

Getting ISFP instead of INTP could, of course, be explained by poor test-retest, but my artist mentality is slightly offended by that…

I'm a sensitive artist, dammit!

Autumn is here

Les sanglots longs
Des violons
De l’automne
Blessent mon cœur
D’une langueur
Monotone.

Autumn is here and with it the usual diseases: the flu, the common cold, the melancholia. Consequently, I'm at home nursing a sick child. It wouldn't be so bad except for the little one's constant crying when she's not asleep. I try my best to cheer her up, but a high fever is hard to live with if you're four years old (or 41, for that matter).

This weekend I revisited the isolated cottage I first wrote of in 2011. As usual, we had a nice evening of good food, decent wine and a fine brandy. The night was cold and clear with a spectacular full moon and lots of stars visible.

We listened to a lot of music fitting for the season and the mood, including some film music by Zbigniew Preisner and Yann Tiersen. I was glad to discover that Zbigniew Preisner's entire Requiem for my friend (dedicated to his friend Krzysztof Kieślowski) is available on Youtube.

I'm looking forward to hearing Brahm's Ein deutches Requiem on November 2.

Surviving OS X on a Macbook Air

For almost two months I've been using a new computer. It's a mid-2013 Apple Macbook Air (MacbookAir6,1) running OS X 10.8.4. It has the optional 8 GiB RAM, 128 GiB SSD and an ANSI style keyboard. A friend who saw it said “Oh, it has one of those programmer's keyboards!”. As you can imagine, ANSI style keyboards are pretty rare in Sweden.

The computer is very fast, incredibly light and quiet. So far I've never even heard the fan. I've been travelling quite a lot this summer and it's been very comfortable to travel with the Air. It's like a luxary version of my Efika Smartbook but with a lot more oomph.

OS X itself feels very much like a real Unix. I feel right at home. That said, I mainly spend my time in Emacs or in ssh sessions to our development servers. Emacs with TRAMP (and a little help from rsync and ssh) works quite OK for remote development.

Here are some notes I wrote about what I've learned so far about OS X and how to configure it to my liking: OS X survival guide.

Using the pomodoro technique with Emacs

This week I've been trying out the pomodoro technique. It's a time-management technique that looks something like this:

  1. Work for 25 minutes.
  2. Take a short break, typically five minutes.
  3. Work for 25 minutes.
  4. Short break.
  5. Work for 25 minutes.
  6. Short break.
  7. Work for 25 minutes.
  8. Take a longer break, typically 15–30 minutes.

Then repeat the whole thing again and again during the day.

This looks simple enough. So simple, in fact, that there must be something more to the system. There is. The real magic is not in this simple list. The real magic is in scheduling all your work items in sizable 25 minute chunks.

When I have something I'm able to complete in just 25 minutes, I find it's much easier to focus on the task. I'm not allowed to check my e-mail, respond to instant messages or doing something else during those 25 minutes unless it's an emergency.

The original pomodoro is named after the Francesco Cirillo's kitchen timer, which was in the shape of a tomato (“pomodoro” in Italian). He simply set his tomato timer according to the list above.

Unlike Francesco I'm not using a physical timer. I'm using Dave Kerschner's pomodoro.el in Emacs to keep time.

I'm on a Mac these days, so I customized pomodoro-sound-player to the OS X built-in sound player /usr/bin/afplay. I recorded a small sound (a discreet “Hrmph!”) with QuickTime to use with the timer.

I found the counter in the mode line counting down the seconds a little hysterical. I changed it to show only minutes left to the next period instead.

The original code just displayed the time for the current period, say “w24:59”, but I wanted to see where in the cycle I was, so I changed it to say “w1-24” for 24 minutes left of the the first work period, “w2-09” for 9 minutes left of the second work period, et cetera.

I also added a function I call pomodoro-reset to reset the counters to the beginning of a work set.

Here's a diff:

diff --git a/pomodoro.el b/pomodoro.el
index 85069f1..b3b86dd 100644
--- a/pomodoro.el
+++ b/pomodoro.el
@@ -102,6 +102,12 @@
 (defvar pomodoro-mode-line-string "")
 (defvar pomodoro-end-time) ; the data type should be time instead of integer

+(defun pomodoro-reset ()
+  "Reset counters."
+  (interactive)
+  (setq pomodoro-current-cycle "w")
+  (setq pomodoros 0))
+
 (defun pomodoro-set-end-time (minutes)
   "Set how long the pomodoro timer should run"
   ;; no slave can work 2^16 seconds without rest!
@@ -132,8 +138,9 @@
             (setq pomodoro-current-cycle pomodoro-work-cycle)
             (pomodoro-set-end-time pomodoro-work-time))))
     (setq pomodoro-mode-line-string
-          (format (concat "%s" (format-seconds "%.2m:%.2s " time))
-                  pomodoro-current-cycle))
+          (format (concat "%s%s-" (format-seconds "%.2m " time))
+                  pomodoro-current-cycle 
+                  (+ 1 (mod pomodoros pomodoro-nth-for-longer-break))))
     (force-mode-line-update)))

 ;;;###autoload

Happy pomodoring,
MC

Gislövs läge

For some reason Malmö is noisier than usual this time of year. I live and work in the city centre. I can't sleep at night. I can't hear myself think during the day. Rather than going mad(der), I took my refuge to this:

View from the house:

I'm working here:

and sometimes in a comfortable armchair.

My daily lunch walks has been a lot nicer than usual:

As seen from the kitchen window:

Meanwhile, young Leia is planning to take over the galaxy:

May the force be with you,
MC

Barcelona

I recently spent a week in Barcelona with wife and daughter.

Barcelona in 2013 is not the revolutionary city of 1936 that I have dreamt of since first reading the wonderful Homage to Catalonia, the amazing Syndikalismen vid makten and other books about the Spanish civil war. There were no red/black flags meeting the eye, no happy workers or militia members on La Rambla, no A las barricadas blaring from loudspeakers day and night.

Instead of the red/black, most everywhere I looked I saw one of the versions of the Catalan nationalist flag. There are, however, some red/black traces left...

CNT's bookshop, La Rosa de Foc:

Shrapnel marks on a wall from one of at least 200 bombings of Barcelona by the Italian airforce:

The graffiti says “Always remember the victims of fascist regimes”.

The Telefónica building where the 1937 May events started is still in use:

A revolutionary street sign recently uncovered:

If you don't know Catalan I'm told it says “The Unknown Militiaman Square”.

Some of these sights were included in Nick Lloyd's wonderful Spanish Civil War tour. Well worth the three hours and the 20 euros.

Apparently someone else also thought Orwell's Homage to Catalonia was good, so they named a square after him:

At this square there are no less than two vegetarian restaurants! It was really no problem at all to be vegan in Barcelona. Here's me and the daughter at yet another vegan restaurant:

I found some other traces of a living Anarchist culture as well. I passed La Otra Carboniera, a squat with a social center (“Centre Social Okupat”), a few times.

Wife and daughter spent some time at the beach. I was at the beach only once. I can't handle the sun very well.

Of course, we visited most of the tourist traps, including the hideous La Sagrada Família:

I concur with Orwell that the Anarchists showed bad taste in not blowing it up when they had the chance. Mind you, other Gaudi houses and Parc Güell are quite beautiful.

I leave you with a few photos from the slopes of Montjuïc, close to Hotel Miramar:

Wayland, window managers and suicide

I received a disturbing e-mail a few days ago:

From: "Anonymous Remailer (austria)" <mixmaster AT THE DOMAIN remailer.privacy.at>
To: mc AT THE DOMAIN hack.org
Subject: I have sad, tragic news, mister widerkrantz

Dear Sir,

with wayland, running mcwm will not be possible anymore.
We have to give up our litte window managers and switch
to GNOME or KDE. Sad as it is, that is called progress, I guess.

Good-bye, I'm going to kill myself once that comes true

Anonymous

Dear Anonymous,

Like you, I often get emotionally attached to my tools. I would find it hard to live in a world without, say, Emacs. I admit that I have strong feelings about the user interface of programs I use, and, yes, about window managers, too.

The Wayland system is a replacement for the aging X system. Wayland defines a protocol for clients to speak with a compositor for later display, much like the X11 protocol is a protocol for clients to speak with the X server, although there are many differences.

Unlike X, which typically uses a separate process for window management, the window management functionality in Wayland is by design a part of the compositor. This means, as the letter writer above suggests, that it's not possible to change the window manager without also changing compositor. But why would that be a problem?

In the default Wayland system the compositor is called Weston. Weston seems to be built mostly by function calls to libraries. It wouldn't be that hard to replace Weston entirely by using the same library functions in your own compositor. In fact, this is probably what KDE and Gnome intend to do.

There are already alternatives to Weston available:

Here's a video where a developer using Enlightenment as a Wayland compositor:

https://www.youtube.com/watch?v=dfnvYAKKPZI

Here's a video with someone using ADWC:

https://www.youtube.com/watch?v=vKcvE6Rhbk4

A short demo of the Hawaii desktop environment is here:

https://www.youtube.com/watch?v=yWvgxUqkr7I

I don't know what will happen with Wayland and if it will replace X on any major Linux distribution soon. My guess is that it will probably be some time before that happens. This means there will be plenty of time to write a compositor/window manager that doesn't suck too much.

Complicating the picture is Canonical's recent announcement that they won't be using Wayland after all. Instead, they're going with something they call Mir.

I haven't looked that much at Mir and I'm not sure I understand the reasons they don't want to use Wayland other than that they seem to prefer C++. *shiver*

My guess, however, is that it's quite possible to the same thing in Mir and replace the default compositor with something that you can live with.

Take care,
MC.