Hours of Idleness https://inigo.katxi.org/blog/ Quiero que te sientas tan inútil como un vaso sin whisky entre las manos -- José María Fonollosa en-us Mon, 31 Jul 2017 00:00:00 +0200 https://inigo.katxi.org/blog/2017/07/31/lms_el.html https://inigo.katxi.org/blog/2017/07/31/lms_el.html <![CDATA[lms.el: squeezebox controller for emacs]]> lms.el: squeezebox controller for emacs

Slim Devices was a now-defunct company who produced network music players well ahead of its time. It offered more-than-good music streaming quality and many other special features, like music synchronization with devices placed on different rooms.


The squeezebox devices are the music players, which work with a free central software server (perl-based) called Logitech Media Server (aka Squeezebox Server, aka SqueezeCenter, aka SlimServer) installable on Linux, *BSD, Windows or Mac computers or even NAS devices, and where you could store and manage your local music library or even listen to internet stations.

In 2006, company was purchased by Logitech and six years later these products were discontinued.

Anyway, it is still one of the best solutions available today for music management and local or remote music streaming. It works and active thanks to the community. And do not be fooled by appearances, it’s very simple to build, even for people without computer skills.

Server software is freely available and it gets new features and enhancements or new plugins often. Even there are many different DYI software/hardware players from the enthusiastic community. Building a player/server with a RaspberryPi, a DAC, and piCorePlayer software is funny, easy and quite cheap indeed.

If you are interested in this solution there are lots of information in internet, but the community meets mainly at http://forums.slimdevices.com/.

Well, that’s enough for the enthusiastic me and the marketing buzzwords ;-).


I own a Squeezebox Boom and a Squeezebox Radio, use a Marantz NR1504 as well (thanks to a plugin called UPnPBridge) and planning to build a couple DYI players in next months.

I control the players with a program on my linux desktop (jivelite) or from an app in my mobile phone (Orange Squeeze, is not free, but there are some others such as free & open source Squeezer).

Ok, very nice… but… hey… there isn’t an emacs package to control squeezebox!


This is an emacs frontend to interact with Squeezebox Server / Logitech Media Server. It is released under GPL version 3 license or later.

It requires emacs version 25 or higher.

Quick instructions: customize some basic parameters lms-hostname, lms-telnet-port, lms-html-port, lms-username, lms-password and run it with lms-ui. From there, you could read complete documentation after pressing h key.

Package should appear in MELPA repository soon, and the code is in BitBucket repository as well.

Some of the features:

- Display song: title, artist, album, year, cover…
- Play, pause, stop, select next / previous song
- Control players: select player, power on/off, volume, repeat and shuffle modes
- Playlist control: list, select song, delete track, clear
- Show track information and change rating

As today, July 30th, 2017, there are some missing features (like music browsing or searching), but they will be added during next weeks (read September as I will leave for holidays in a few days).

It is not aimed to be a complete controller, as it can’t - and won’t - manage external sources such us BBC, Deezer, Pandora, Spotify, or TuneIn Radio.

Of course, any ideas, suggestions and comments will be well received.

../../../_images/lms.el-ss1.jpeg ../../../_images/lms.el-ss2.jpeg ../../../_images/lms.el-ss3.jpeg ../../../_images/lms.el-ss5.jpeg ../../../_images/lms.el-ss4.jpeg
Mon, 31 Jul 2017 00:00:00 +0200
https://inigo.katxi.org/blog/2017/06/26/lfm_v3_1_released.html https://inigo.katxi.org/blog/2017/06/26/lfm_v3_1_released.html <![CDATA[lfm v3.1 released]]> lfm v3.1 released

Just released a maintenance new version of lfm, with some bugs fixes from last times.

More information

Of course, all comments, suggestions, etc. are welcome.

Changes since last version

Version 3.1 ("Recovering inertia") - 2017/06/25:

+ New features
  - support for new compression programs: lzip, lz4

+ Changes & improvements:
  - Improved resources files (docs, default keys and theme) installation
    and loading at runtime

+ Fixes:
  - when installing data files with pip >7.0 & wheel.
    Thanks to Jean-François Bercher
  - PowerCLI: error message is always shown when command finishes.
    Thanks to Jean Terrier for the report
  - filters: glob when parent dir contains special chars (BB issue #5).
    Thanks to Viktor Vad for the report
  - lfm crashes when terminal is too narrow (BB issue #4).
    Thanks to Wayne Tan for the report
Mon, 26 Jun 2017 00:00:00 +0200
https://inigo.katxi.org/blog/2015/10/24/lfm_v3_0_released.html https://inigo.katxi.org/blog/2015/10/24/lfm_v3_0_released.html <![CDATA[lfm v3.0 released]]> lfm v3.0 released ../../../_images/lfm-ss1.jpeg

Yesterday I released lfm version 3.0, the powerful file manager for the UNIX console I started coding in 2000 or 2001.

This is an important release as it’s the first compatible with Python 3, in fact it requires Python 3.4+.

Some of the features you can find in lfm:

  • console-based file manager for UNIX platforms
  • 1-pane or 2-pane view
  • tabs
  • files filters
  • bookmarks
  • history
  • VFS for compressed files
  • tree view
  • dialogs with entry completion
  • PowerCLI, a command line interface with advanced features
  • fast access to the shell
  • direct integration of find/grep, df and other tools
  • color files by extension [Andrey Skvortsov]
  • fully customizable themes (colors)
  • fully customizable key bindings
  • support for filenames with wide chars, f.e. East Asian
  • …and many others

NOTE: If you come from v2.3 please read the Upgrade section in the documentation.

More information

Of course, all comments, suggestions, etc. are welcome.

../../../_images/lfm-ss2.jpeg ../../../_images/lfm-ss3.jpeg ../../../_images/lfm-ss4.jpeg ../../../_images/lfm-ss5.jpeg

Changes since last version

Version 3.0 ("Only you") - 2015/10/23:

+ About the code
  - almost completely rewritten from scratch
    . it hasn't been tested as much as lfm v2.x series on non-linux OS
  - requires Python v3.4+
  - pyview, the file viewer, has been removed from lfm package
  - configuration location has changed to a new directory and files:
    ~/.config/lfm/{lfm.ini, lfm.keys, lfm.theme, lfm.history}

+ New features
  - fully customizable themes (colors)
  - fully customizable key bindings
    . allow Alt-key shorcuts (A-)
    . only for main window (not for dialogs)
  - files filters (using globs)
    . information in pane frame: ".F" => show dotfiles, active filters
    . filters are a property of a tab, they remain active even when chdir
    . Ctrl-f: edit current filter
    . Some examples:
      . "*.png,*.jpg" => hide all PNG and JPEG files
      . "*.jpg,!*shot*" => hide all JPEG files except those with 'shot' in the name
      . "*,!*py" => hide all except python source files
  - up to 35 bookmarks (0-9, a-z)
    . b: go to bookmark, B: set bookmark, C-d: select bookmark
    . fix: don't delete bookmark at start if path does not exist
  - nested archive handling (vfs inside vfs) works now
  - added optional support for filenames with wide chars, f.e. East Asian
    . to enable, set 'use_wide_chars' flag in configuration or use -w command line flag
    . it's disabled by default for performance
    . it's not perfect, but it mostly works
  - there are 2 different versions of move_file to chose from in the key
    bindings file:
    . move_file: old implementation
    . move_file2: alternative version using shtutil.move instead of copy & delete. Faster but less control of errors
  - new action: redraw screen (default key A-r)

+ Changes & improvements (vs v2.x):
  - chmod & chown/chgrp are 2 different actions now
  - cursor_goto_file (C-s): find text pattern (no regex or glob) in the whole file name, not at the beginning as v2.x
  - cursor_goto_file_1char (A-s): go to file by 1st letter of name (old C-s behaviour)
  - bookmarks have new key bindings:
    b: go to bookmark, B: set bookmark, C-d: select bookmark
  - PowerCLI:
    . ending command with % must be $ now
    . added new date variables: dm, dc, da, dn
    . ending command with % must be $ now
    . added new date variables: dm, dc, da, dn
    . old $d variable is $p now
  - find/grep: panelize = create vfs with matched files
    . if rebuild: all files modifications or deletions are translated to original directory so be careful!
  - pyview, the file viewer, has been removed from lfm package

+ Fixes in v3.0 (vs v2.x):
  - nested archive handling (vfs inside vfs) works now
  - find & grep with spaces in file name
  - wide chars file names support (f.e. Eastern languages) => lfm -w
  - sort by size after show dirs size
  - move_file: not overwritten files in destination are not deleted
Sat, 24 Oct 2015 00:00:00 +0200
https://inigo.katxi.org/blog/2015/08/09/pmdm_a_poor_s_man_desktop_mode_replacement_for_emacs.html https://inigo.katxi.org/blog/2015/08/09/pmdm_a_poor_s_man_desktop_mode_replacement_for_emacs.html <![CDATA[pmdm - a poor’s man desktop-mode replacement for Emacs]]> pmdm - a poor’s man desktop-mode replacement for Emacs ../../../_images/emacs-logo.jpeg

As usual, much time has elapsed without updating the blog. I had some ideas in my head but was too lazy to write anything.

Anyway, I come back today with possibly my preferred software application… want to guess? Linux? GNOME? Firefox? even my own lfm? Well, the only application which really matters!

In fact, as time goes by, I appreciate emacs more and more. And as I’ve mentioned somewhere, I can spend a great part of my decreasing spare and idle hours tweaking here or there in my .emacs file configuration and testing new modules - MELPA, so much pain have you inflicted.

Ok, less ramblings and let’s go into detail.

Problems with emacs daemon, desktop-mode, and perspective

I’m using emacs --daemon since a couple of years ago. emacs starts with my GNOME graphical session (nowdays as user systemd service) and ends with it. Very convenient.

I also used desktop-mode, which can save your opened files, frames sizes and much more at emacs session ending and recover all of them the next time you start emacs. It worked more or less for me with emacs daemon mode.

But desktop-mode definitively stopped working when I added perspective to my configuration. [Copying project page description: “perspective provides tagged workspaces in Emacs”.]

Usually this wouldn’t be a serious inconvenient as I use helm-mini (or helm-recentf) to open recent files quickly. But… hey! this is emacs, let’s write a new and superfluous package (and learn in the process)!

Writing pmdm, a simple replacement for saving and restoring opened files

I need to confess that I don’t know much about emacs-lisp, in fact the only language I can consider myself proficient enough nowdays is python, but coding simple stuff in elisp (or haskell, btw) is a good way to relax myself for a couple of hours.

Ok, so we need to write a function to get all buffers containing live files and save their name onto a file. Then, another function to read the stored file names and open them.

Sound simple, uhm?

Let’s start step by step.

Getting the name of opened files

We can get all opened buffers with buffer-list, which returns a list (of course, this is emacs-lisp, there are lists everywhere ;). And buffer-file-name can be used to get the name of the file for the buffer.

Let’s run these functions interactively using ielm and show their output:

ELISP> (mapcar 'buffer-file-name (buffer-list))
(nil "/home/inigo/devel/web.inigo/blog/drafts/pmdm_a_poor_s_man_desktop_mode_replacement_for_emacs.rst" "/home/inigo/devel/emacs/pmdm/pmdm.el" nil nil nil nil nil "/home/inigo/.emacsmine/my-dotemacs.el" nil "/home/inigo/personal/agenda/todo.org" nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil "/home/inigo/personal/agenda/diary" nil nil nil nil nil nil nil nil)

Lots of buffers. Those nil elements correspond to buffers with no file, so we need to filter them out:

ELISP> (delq nil (mapcar 'buffer-file-name (buffer-list)))
("/home/inigo/personal/agenda/todo.org" "/home/inigo/devel/web.inigo/blog/drafts/pmdm_a_poor_s_man_desktop_mode_replacement_for_emacs.rst" "/home/inigo/devel/emacs/pmdm/pmdm.el" "/home/inigo/.emacsmine/my-dotemacs.el")

Much better.

Writing the list to a file

Now we have to save this list into a file.

Diving into elisp documentation we can find a write-region function with this syntax:


it looks like it works with current buffer, so we could create a temporary buffer, insert the list as a string (prin1-to-string), select the text and save it finally.

It’s not very clear from the definition above, but reading the description carefully we noted the function can also be used by passing a string as the first parameter, so we don’t need the buffer!


We also add some comments to the file in case someone read it. We use format to format and concatenate the text to be written.

And now we have our first function finished!

(defun pmdm/write-opened-files()
  (let ((files (delq nil (mapcar 'buffer-file-name (buffer-list)))))
    (write-region (format ";; PMDM file.\n;; Please do not edit manually.\n%s"
                          (prin1-to-string files))

Reading it back

In Emacs, the best way to read a file content is to insert it in a temporary file. Something as fast as:

  (insert-file-contents "~/.emacs.d/.pmdm-files")

We can delete the comments in the file with:

(delete-matching-lines "^;; ")

and get the list with our files to open:

(buffer-substring-no-properties (point-min) (point-max))

Wow, very easy… but there is problem here… what we have is the string representation of the list, not the list itself!

After half an hour thinking and searching internet the solution was simple, the read function can cast the string into a list.

This is how the finished function looks like:

(defun pmdm~read-files-list ()
    (insert-file-contents "~/.emacs.d/.pmdm-files")
    (delete-matching-lines "^;; ")
    (read (buffer-substring-no-properties (point-min) (point-max)))))

[Please consider the security implications of blindly reading a file from the file system and using the contents without any check.]

And finally, visit the files

We loop the files list returned by previous function with dolist and call find-file-noselect to open them in the background.

(dolist (file (pmdm~read-files-list))
  (find-file-noselect file))

Though in emacs it’s harmless trying to load an already opened file, it’s better to check and avoid it. We know how to get a list of currently opened files so for our new file we will check if it is present in the already-opened-files list.

(let ((opened-files (delq nil (mapcar 'buffer-file-name (buffer-list))))
      (files (pmdm~read-files-list)))
  (dolist (file files)
    (unless (member file opened-files)
      (find-file-noselect file))))

We can enhance the function displaying how many files we have opened, so we add a variable that we’ll increment for each new opened file.

(defun pmdm/load-files ()
  (let ((opened-files (delq nil (mapcar 'buffer-file-name (buffer-list))))
        (files (pmdm~read-files-list))
        (count 0))
    (dolist (file files)
      (unless (member file opened-files)
        (find-file-noselect file)
        (setq count (1+ count))))
    (message (if (zerop count)
                 "No files opened"
               (format "%d file%s opened" count (if (> count 1) "s" ""))))))

Final thoughts

Add functions comments, use of defvar instead of hard-coding file name and voilà, we have the final version of pmdm.el.

I know/suppose there are a lot of better implementations of this same idea out here. But using them would be less fun than coding it ourselves!

Sun, 09 Aug 2015 00:00:00 +0200
https://inigo.katxi.org/blog/2014/04/13/bookmarks_v1_0_released.html https://inigo.katxi.org/blog/2014/04/13/bookmarks_v1_0_released.html <![CDATA[Bookmarks v1.0 released]]> Bookmarks v1.0 released ../../../_images/bk-ss1.jpeg

Bookmarks is a simple personal web-based application to manage web bookmarks.

It’s written in Python 3.2+ and uses BottlePy web microframework and jQuery javascript library. Both are included with the package.

It was coded as a funny practice, but it includes some nice features: advanced search, tags cloud, years cloud.

I think this little application can be useful for anyone learning Python web programming.

It’s under GNU Affero GPL License version 3 or later.


More information, and download link at:

Of course, all comments, suggestions etc. are welcome.

Sun, 13 Apr 2014 00:00:00 +0200
https://inigo.katxi.org/blog/2014/04/13/mynewspaper_v4_0_released.html https://inigo.katxi.org/blog/2014/04/13/mynewspaper_v4_0_released.html <![CDATA[MyNewspaper v4.0 released]]> MyNewspaper v4.0 released ../../../_images/mn-ss1.jpeg

I’m really pleased to announce a new release of MyNewspaper, a web-based personal ATOM/RSS aggregator and feeds reader.

This new version has been completely rewritten from scratch.

It’s under GNU Affero GPL License version 3 or later.

Some technical points of interest:

  • written in Python 3.2+
  • backend based on BottlePy web micro framework, FeedParser, SQLite, DateUtil
  • frontend with javascript (jQuery, jQueryUI)

More information, and download link at:



MyNewspaper can be considered an old project, as first version dates from 2005, and since then it has adopted and adapted different web paradigms: CGI running on a web server in v1.0, pure web app in v2.0, javascript and AJAX for v3.0.


A couple of years after v3.0 release I abandoned it to join Google Reader wave, but since the announce of its shutdown I turned to MyNewspaper as I didn’t like any of the alternatives. Thus I rewrote from scratch all the code. It was fast, I had a working version in a month, many weeks before Google Reader closed, but then it took about 10 months more to write the documentation…

Anyway, this is now version 4.0, a very fast and nice web-based feeds reader for personal use.

Of course, all comments, suggestions etc. are welcome.

Sun, 13 Apr 2014 00:00:00 +0200
https://inigo.katxi.org/blog/2012/09/11/liu_cixin__ciencia_ficcion_clasica_made_in_china.html https://inigo.katxi.org/blog/2012/09/11/liu_cixin__ciencia_ficcion_clasica_made_in_china.html <![CDATA[Liu Cixin: Ciencia Ficción clásica made in China]]> Liu Cixin: Ciencia Ficción clásica made in China

En primer lugar perdonad por lo tópico del titular, pero aún así me resisto a buscar otro, éste resume perfectamente lo que trato de explicar en la presente entrada.

Liu Cixin es un escritor chino de ciencia ficción contemporáneo, y según parece, el más popular en su país. Mi primer contacto con él fue a través de una mención de @literfan en Twitter acerca de un cuento suyo gratuito en Amazon, The Sun of China. ¿Ciencia ficción china? merecía la pena probarlo, así que a por él fuimos… ¡bastante interesante!

Más adelante, y vía mención de @literfan, dí también en Twitter con @odo, autor de un gran blog de ciencia ficción y fantasía y quien se ha convertido en el gran valedor e impulsor de la obra de Liu Cixin por aquí. Por cierto, no dejéis de leer la siguiente entrevista a Verbena C.W., la editora en inglés de las obras de Cixin: http://sentidodelamaravilla.blogspot.com.es/2012/05/entrevista-con-verbena-cw-editor-de-liu.html.

Así, entre los cuentos que fueron apareciendo gratis en Amazon y un par de compras (total no más de 1.5 EUR), finalmente he podido leer todo lo que Liu Cixin tiene publicado en inglés. Se tratan todas ellas de novelettes, un formato intermedio entre los relatos cortos y las novelas, editadas durante el 2011, a excepción de Taking Care of Gods que es del 2012.

A continuación copio los twits micro-resúmenes de lo que me pareció cada obra en el mismo orden en el que fui leyéndolas:

../../../_images/sunofchina.jpeg ../../../_images/thewanderingearth.jpeg ../../../_images/mountain.jpeg ../../../_images/takingcareofgods.jpeg
  • Terminado “Sun of China”, de Liu Cixin. CF china. Tiene puntos interesantes. Estaba gratis en Amazon Kindle, ahora por menos de 1 EUR
  • Terminado “The Wandering Earth” de Liu Cixin. CF “clásica” con aire fresco. Si te va lo profundo tal vez te falte algo, pero recomendable
  • Terminado “Mountain” de Liu Cixin. Comienzo muy flojo. Luego con la historia de los extraterrestres gana algo. CF “blanda”. Al menos la idea
  • Terminado “Taking Care of Gods” de Liu Cixin. Magnífica. Pelín moralista pero excelente. Lo mejor del autor que he leído por el momento
../../../_images/thelongestfall.jpeg ../../../_images/devourer.jpeg ../../../_images/ofantsanddinosaurs.jpeg ../../../_images/themicroage.jpeg
  • Terminado “The Longest Fall” de Liu Cixin. Cixin es un escrito de ideas, y por lo general muy buenas. Lástima del estilo (o la traducción)
  • Terminado “Devourer” de Liu Cixin. Ocurrente y muy interesante. Yo diría que Cixin es el más clásico de la CF de nuestros días. Curioso, no?
  • Terminado “Of Ants and Dinosaurs” de Liu Cixin. Un “entretenimiento”. Bastante moralista. Digamos que no veo cómo poder apreciarlo
  • Terminado “The Micro-Age” de Liu Cixin. Buenrollismo. Más que chino Cixin parece aquí californiano de finales de los 60…

No soy muy dado a crear simplificaciones forzadas, pero bueno, voy a dividirlos según lo que me han gustado:

+: Taking Care of Gods, Devourer, The Wandering Earth
.: segunda parte de Mountain, The Longest Fall, Sun of China
-: primera parte de Mountain, Of Ants and Dinosaurs, The Micro-Age

Si algo tiene Cixin es imaginación, buenas ideas que trata de un modo muy clásico, sin entrar en demasiadas profundidas ni tecnológicas ni sociológicas; mucho menos adentrarse en la psicología de los personajes (y cuando lo hace falla estrepitosamente, como por ejemplo en Mountain).

También hay presente un cierto toque moralista que en mi opinión termina por empobrecer el resultado final. En este punto quizá haya que concederle el beneficio de la duda, pues desconocemos hasta qué punto la traducción es suficientemente fiel a las intenciones del autor. No obstante, a mí personalmente lo que menos me convence de estos cuentos es ese buenrollismo, el optimismo que aparece en el final de prácticamente todos los relatos. Cosas de ser un cínico, supongo. Tal vez sea que Cixin es aún demasiado joven… Esperemos que se le pase pronto esta etapa.

Pero a pesar de ello, la grandiosidad de las imágenes que nos ofrece contrarresta (y de qué manera) los puntos negativos.

Para terminar no me queda más que recomendaros que lo leáis, sus historias son realmente refrescantes. Como resumía acertadamente alguien por Twitter (perdonad, no recuerdo quién y no lo encuentro ahora), leer estos relatos de Cixin es como volver a los 12 años…

Tue, 11 Sep 2012 00:00:00 +0200
https://inigo.katxi.org/blog/2012/06/18/screenshot_from_kindle_4_ereader.html https://inigo.katxi.org/blog/2012/06/18/screenshot_from_kindle_4_ereader.html <![CDATA[Screenshot from Kindle 4 ereader]]> Screenshot from Kindle 4 ereader ../../../_images/kindle4.jpg

I bought a Kindle 4 ereader last November, when Amazon started selling this model in Spain.

I already own another couple of ereaders — and in fact I’m still in love with the IREX DR800, but as IREX is now out of business I don’t want to risk the integrity of this marvellous 8” device as I think it’s still the best ereader out there —. Well, I digress… Anyway, I wanted a cheap and small ereader to carry everywhere, so I got a Kindle 4.

After some months using it — I must admit it’s better than I thought initially — I read a jailbreak was already available…

Thus, I spent some hours past weekend hacking it, jailbreak, installing some third party applications and building a cross compiler toolchain. By the way, if you have ebooks in formats not supported natively by Kindle (.fb2, .epub, .chm…) and don’t like the idea of converting to .mobi format, CoolReader 3 is a must.

But I won’t talk about it now. Today we’ll write a tiny python script to convert Kindle 4 screenshots to png format.


Note this script only works for Kindle 4, you should need to modify it to adapt for other models. More information on this later.

Getting the image

In order to use this you need ssh shell access to the Kindle, first to get the screenshot and then to transfer the file to your computer. Both wifi or usbnet work.

To get a copy of the screen display we can read directly from the framebuffer device. Type this command from the Kindle shell:

# dd if=/dev/fb0 of=./screenshot.raw bs=600 count=800

Note 600x800 is the resolution of Kindle 4 screen.

Then copy the file screenshot.raw to your computer.

The script

The image we got in previous step is in raw format with no information about internal colors, rows or columns. That’s why it can’t be opened with your image viewer program [1].

Kindle 4 uses 8 bits (i.e. 1 byte) per pixel [2], so in our case the processing is quite easy, we don’t need to mess with bits shifting.

SIZE = (600, 800)
data = open('screenshot.raw', 'rb').read()
img = Image.frombuffer('L', SIZE, data, 'raw', 'L', 0, 1)
img = ImageOps.invert(img)
img.save('screenshot.png', 'PNG')

Let’s explain:

  1. Image size definition
  2. Read the image raw data from screenshot file
  3. Create an Image object using Python Image Library:
    • L means 8-bit pixels, black and white
    • we need to specify number of columns and rows. Remember data has no format, it contains plain bytes
    • raw indicates image comes as raw bytes
  4. We need to invert colours, black to white and vice versa
  5. Finally, save image as PNG file

For more information consult PIL documentation.

Note that if you prefer to use the currently deprecated compact syntax of Image.frombuffer (line #3 below) you’ll need to flip the image (line 4), as it is read up-down.

SIZE = (600, 800)
data = open('screenshot.raw', 'rb').read()
img = Image.frombuffer('L', SIZE, data)
img = img.transpose(Image.FLIP_TOP_BOTTOM)  # or img = ImageOps.flip(img)
img = ImageOps.invert(img)
img.save('screenshot.png', 'PNG')

You can download the complete script from here.

A resized screenshot as an example:



I’ve just discovered there is a keyboard shortcut to make a screenshots in Kindle 4: press and hold keyboard button then press menu button. Screenshot will be created as .gif files in documents folder.

More tips: http://www.mobileread.com/forums/showthread.php?p=1769412#post1769412


[1]Yes, I’m aware of some programs that let you specify some parameters of the raw image to open it.
[2]In fact Kindle 4 uses 8 bits, but the 4 lower bits are copied in the higher 4 bits. Kindle 3 and older use 4 bits per pixel. More information on MobileRead forum.
Mon, 18 Jun 2012 00:00:00 +0200
https://inigo.katxi.org/blog/2012/05/25/ebook_thumbnailer_py.html https://inigo.katxi.org/blog/2012/05/25/ebook_thumbnailer_py.html <![CDATA[ebook-thumbnailer.py]]> ebook-thumbnailer.py

Today I’ve announced a new little tool I wrote a couple of weeks ago. ebook-thumbnailer.py is a python script which generates cover thumbnails for some common ebook file formats.

This blog entry is a copy of the program web page.


The package also includes the needed schemas to be integrated with GNOME 3 but it should easily work with any other desktop environment.

Current supported formats are:

  • .fb2
  • .epub
  • .pdf
  • .mobi, .prc, .azw, .azw4
  • .chm

Dependencies: python v2.6+, pygtk, cairo, pypoppler, mobi_unpack, python-chm

Note that, as mobi_unpack is not usually provided by your OS, download it from MobileRead, copy to your system and change line #160 in the script. Search MOBI section in source for more information.

You could even use PIL/Imaging instead of pygtk to create the image files. Code is already there, just comment/uncomment the proper lines in function create_thumb.

To download follow the link at the beggining of the post.

Fri, 25 May 2012 00:00:00 +0200
https://inigo.katxi.org/blog/2012/05/14/la_vall_de_lord.html https://inigo.katxi.org/blog/2012/05/14/la_vall_de_lord.html <![CDATA[La Vall de Lord]]> La Vall de Lord

Hace apenas un par de semanas cogí unos días de vacaciones de esos que aún me quedaban del año pasado y nos fuimos a una casa rural, no muy lejos al norte de Solsona, en el prepirineo de Lleida, buscando un poco de paz y que la familia viera algo de verde.

../../../_images/lavalldelord-04.jpg ../../../_images/lavalldelord-02.jpg

Llevaba unos cuantos años queriendo visitar la zona, influenciado por las canciones del grandísimo cantautor solsonés Roger Mas. Las letras de sus primeros discos están llenas de referencias a una naturaleza misteriosa poblada de extraños seres y rincones fabulosos, que entiendo yo surgieron recorriendo los paisajes de su infancia y primera adolescencia…

Así pues, con una cierta ilusión, pero tampoco con excesivo entusiasmo, nos fuimos para La Vall de Lord. La primera impresión fue bastante buena: montañas, bosques y mucho, mucho verde.

Pero según fueron sucediéndose los días el entorno empezó a enamorarme, montón de parajes extraordinarios, tranquilidad, belleza calmada y poca gente.


Como se puede ver en las fotografías, en medio del valle se encuentra el Embalse de la Llosa del Cavall, rodeado de colinas y algún que otro prado donde poder tumbarse a la fresca. Por lo que ví se puede pescar en él.

Sant Llorenç de Morunys es el pueblo principal. No muy lejos de él se encuentra el Santuari de Lord y cercano a él la ermita de Sant Serni.

Subiendo por la carretera hacia La Coma i La Pedra se hallan las Fonts del Cardener, otro rincón de obligada visita. El Cardener es al parecer el mayor afluente del Llobregat.

La zona también acoge la estación de esquí del Port del Comte, creo que no tan popular como otras más al norte pues al contar con menor altitud tiene nieve menos días al año. Casualmente en estos días cayó la mayor nevada de la temporada.

No olvidéis tampoco visitar el casco histórico de Solsona, ya fuera del valle propiamente dicho, y caminar sin prisas por esas antiguas calles cercanas a la catedral.

../../../_images/lavalldelord-03.jpg ../../../_images/lavalldelord-05.jpg ../../../_images/lavalldelord-06.jpg ../../../_images/lavalldelord-07.jpg ../../../_images/lavalldelord-08.jpg ../../../_images/lavalldelord-09.jpg

En definitiva, La Vall de Lord se ha convertido posiblemente en el refugio para desconectar cercano a casa que utilizaremos durante los próximos años.

Mon, 14 May 2012 00:00:00 +0200
https://inigo.katxi.org/blog/2012/03/27/back___de_vuelta.html https://inigo.katxi.org/blog/2012/03/27/back___de_vuelta.html <![CDATA[Back / De vuelta]]> Back / De vuelta

Ok, after more than 6 years of silence, here we are with a new entry in the blog!

Lots of things during this time: a couple of sons, a new job, I recently started my 40’s… but life continues. Even Tom Waits played in Barcelona and I was there!

Anyway, I hope I could update the blog more often now…


¡Tras más de 6 años sin actualizar el blog, aquí estamos de vuelta!

Muchas cosas han cambiado, o más que cambiar, la vida ha seguido transcurriendo: un hijo, cambio de trabajo, otro hijo, los 40… Incluso pude acudir a un concierto de Tom Waits en Barcelona!

Bueno, comenzamos esta nueva temporada con buenas intenciones, entre ellas actualizar ésto de vez en cuando…

Tue, 27 Mar 2012 00:00:00 +0200
https://inigo.katxi.org/blog/2006/01/06/new_katxi_web_site_oficially_released.html https://inigo.katxi.org/blog/2006/01/06/new_katxi_web_site_oficially_released.html <![CDATA[New Katxi web site oficially released]]> New Katxi web site oficially released

As I mentioned in last entry, during December I rewrote Katxijasotzaileak web page . This week I did last tests and changed the redirections, so the new web is officially released to the public now.

Old one was written using Zope application server v2.6.2 and used MySQL for permanent storage. Not bad, it has served for 2 or 3 years; but times are changing, you know, and web applications development uses other technologies nowdays… I’ve used CherryPy, SQLObject, SQLite and Cheetah templating system (see here for complete description of all tools involved). CherryPy app is served with a wsgi launcher run by lighttpd mod_scgi module.

It has been a great pleasure to use the combination of these powerful but simple tools, it has done the development easy and really fast. As a plus, and as this web site has just a few hits per day, I don’t need to have running some weighted processes like a big db or a complex application server (zope used ~90 MB and MySQL ~110 MB of virtual memory, now the wsgi app no more than 35 MB. You note the difference).

And btw, for nostalgic people, there is a place where you can find some presents…

Fri, 06 Jan 2006 00:00:00 +0100
https://inigo.katxi.org/blog/2005/12/18/bye_apache__hello_lighttpd.html https://inigo.katxi.org/blog/2005/12/18/bye_apache__hello_lighttpd.html <![CDATA[Bye Apache, Hello Lighttpd]]> Bye Apache, Hello Lighttpd

Along this week I’ve been reading the documentation of lighttpd, a light and fast web server.

Encouraged by its simplicity I installed and replicated my apache configuration (4 virtual hosts, some complex rewrite rules for a zope site…) in two non complete days. And I liked it, it is light and fast as they stated, but it’s really simple too. After two more days testing some things, mainly SSI and python CGIs, I took the decision to substitute the good ol’ apache with lighttpd.

Today I’ve done it and except a few minor issues regarding non complete support for SSI’s exec and the replacement of several .htaccess with lighttpd’s own method of authentication, it has been straightforward. Not much scientific measurements show virtual memory comsumption has lowered from ~27 MB to ~3 MB, and some large pages loading time improve ~33%.

Also, as far as I finish the new Katxi web site I’ll be able to get rid of zope and MySQL too, replaced by CherryPy and sqlite. Not that I don’t like them, they are great, but perhaps too cumbersome for my needs, not so complex personal webs. But as this will be announced soon, I won’t add more now.

By the way, I’ve also slightly changed http://inigo.katxi.org site, replacing old-style tables with more modern CSS techniques.

Sun, 18 Dec 2005 00:00:00 +0100
https://inigo.katxi.org/blog/2005/11/13/alive_and_new_programs_announced.html https://inigo.katxi.org/blog/2005/11/13/alive_and_new_programs_announced.html <![CDATA[Alive and new programs announced]]> Alive and new programs announced

Much time since I last blogged…

Anyway, today I released Pynahotheka, a python script which generates nice static HTML photo albums in which I’ve been working last 2 months. It’s written with Python, PIL and CheetahTemplate.

I’ve created my friends and my own photo galleries with this tool. Also I’m really proud that some friends uses it to build their own galleries.

I haven’t mention MyNewspaper either, a personal RSS aggregator and reader with a Web UI. This is a project I started this summer, but was halted due to pynakotheka development. I use it every day and it’s quite good!!! It’s written in Python and uses CheetahTemplate and Sqlite/SQLObject.

I’m very happy with both programs’ code… don’t know, maybe I’m learning to program ;-)

From now on, I’m considering different projects:

  • a total rewrite of Katxijasotzaileak web , changing Zope2 with CherryPy and MySql with Sqlite and SQLObject and designing a new more modern look
  • rewrite tintytw, a tripwire-like file system integrity monitor I wrote some years ago
  • and contine improving MyNewspaper, of course
Sun, 13 Nov 2005 00:00:00 +0100
https://inigo.katxi.org/blog/2005/02/14/new_gdesklets__boxmail.html https://inigo.katxi.org/blog/2005/02/14/new_gdesklets__boxmail.html <![CDATA[New gdesklets: boxmail]]> New gdesklets: boxmail

One of the oldest projects in my TODO list was to rewrite a desklet I coded some time ago.

I’ve been considering the idea for many months - maybe too much - but with the latest improvements in gDesklets (Controls, Side Candy, etc) I run out of excuses, so this afternoon I’ve taken a look at SideCandyPopmail and adapted to my old code.

This is how it looks like:


The desklet shows the number of unread/total messages in an Unix mailbox, the size of the mailbox file and the subject of last 4 received emails. Its beauty comes from the SideCandy style.

You can download it from here.

Mon, 14 Feb 2005 00:00:00 +0100
https://inigo.katxi.org/blog/2005/02/13/emacs_and_vim_config_files.html https://inigo.katxi.org/blog/2005/02/13/emacs_and_vim_config_files.html <![CDATA[Emacs and Vim config files]]> Emacs and Vim config files

Last years I’ve been using emacs as main editor - even IDE - for all my coding, with occasional quick uses of mcedit, but after the PyGtk BoF which took place in Mataró last December 2004, I gave vim a chance…

I’ve put here my config files.

Anyway, nowdays I’ve come back to the one true editor ;-)

Sun, 13 Feb 2005 00:00:00 +0100
https://inigo.katxi.org/blog/2004/08/29/elcorreo_py.html https://inigo.katxi.org/blog/2004/08/29/elcorreo_py.html <![CDATA[elcorreo.py]]> elcorreo.py

I’ve added another script to feed my RSS reader.

In this case is elcorreo.py, a python script to get latest news from El Correo Digital.

It is implemented as a command for Liferea, i.e., a script which retrieves news updates, parses them and builds a rss feed at run time, which is written to stdout. It also need BeautifulSoap.

Sun, 29 Aug 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/08/25/googlenews_py.html https://inigo.katxi.org/blog/2004/08/25/googlenews_py.html <![CDATA[googlenews.py]]> googlenews.py

While half the world is watching Olympic Games and the other half is discussing about decorators, and as far as my good proposal (“#decorator” :) has been sadly ignored, I’ve spent last days writing googlenews.py: a simple python script to retrieve news from Google News Service.


  • Supported feeds: es, fr, de, it, nz, au, in, ca, uk, us
  • Can export to: rss2 xml and html files


I use it in a hourly cron script, building rss files which I read with liferea:

[inigo@inigo inigo]$ cat /etc/cron.hourly/googlenews
/home/devel/mine/googlenews/googlenews.py --rss-path=/tmp -w -q es
/home/devel/mine/googlenews/googlenews.py -cnes --rss-path=/tmp -w -q nz
exit 0
[inigo@inigo inigo]$

Type googlenews.py --help for more info.

Hope you like it.

Wed, 25 Aug 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/08/10/pagina_web.html https://inigo.katxi.org/blog/2004/08/10/pagina_web.html <![CDATA[Página web]]> Página web

Poco que comentar, pues en los últimos días apenas he hecho nada… (ya comentaré el por qué más adelante). Lo único destacable es que he upgradeado el blog a la versión 2.4 del NewsBruiser.

Tue, 10 Aug 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/08/07/nueva_pagina_web.html https://inigo.katxi.org/blog/2004/08/07/nueva_pagina_web.html <![CDATA[Nueva página web]]> Nueva página web

Tras unos pocos días trabajando en ella, ya está prácticamente terminada mi nueva página web.

Quedan unas pocas cosas, como añadir algunos contenidos y terminar el soporte de la webcam, pero, en fin, lo que siempre me resulta más engorroso, que es el look and feel ya está.

Sat, 07 Aug 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/05/09/pues_hoy_me_caso__venga.html https://inigo.katxi.org/blog/2004/05/09/pues_hoy_me_caso__venga.html <![CDATA[Pues hoy me caso, venga]]> Pues hoy me caso, venga

Venga, lo he decidido… me he levantado hace unos pocos minutos y, como tampoco tengo nada mejor que hacer, pues me caso, hala.

Sun, 09 May 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/05/08/_6.html https://inigo.katxi.org/blog/2004/05/08/_6.html <![CDATA[-6]]> -6

Es muy complicado, sinceramente.

Algoritmos de optimizaciónn de la satisfacciónn general no son suficientes, pues el nivel de bienestar de cada persona ha de tener un nivel aceptable (superior al de los demás, me atrevería incluso a asegurar). Y en este último punto reside el problema, ¿cuál es el nivel aceptable para cada uno?

¿De qué hablo…? del reparto de los comensales en las mesas para la boda. Hay multitud de variables, la mayoría de ellas no se manifiestan hasta cuando uno cree que ya tiene una distribución que contentará a todo el mundo…

…pero no, como siempre, la realidad es mucho más tozuda… y luego resulta que la tía Fermina, que lleva 50 años sin hablarse con el tío Pascual, se enfada porque no está en su misma mesa; o que no-sé-quién quiere estar con Txema pero resulta que Txema no quiere estar con él ni se lo quiere decir tampoco; o que tal otra persona quiere estar al lado de los servicios o que… y así hasta 107 preferencias (una o incluso más por persona)… si hasta cuando les pones donde te dicen, te llaman al cabo de unas horas para comentarte que lo han pensado y que tal vez sería mejor que… vamos, cómo no, cada persona sabe (o cree saber) cuál es la mejor manera de distribuir a todos los demás; pero claro, qué demonios le importa a uno que otro no esté a gusto rodeado de personas 30 años mayores… recordéis lo difícil que era de críos hacer los equipos para jugar al fútbol, pues lo mismo pero elevado al infinito…

En fin, tras horas y horas de jugar sobre la mesa del salón con recortables, nombres escritos en trocitos de papel y las mil y una posibilidades, las cosas han quedado tal que así:


Espero que nadie más se enfade en exceso, pues os aseguro que en ocasiones se hace muy complicado cuadrar todo, y nosotros lo hemos hecho con la mejor voluntad posible. Creedme.

[NOTA: razones de sorpresa y confidencialidad no me ha sido permitido publicar ésto hasta hoy. Fue escrito el pasado lunes.]

Sat, 08 May 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/04/25/fotos_despedida_de_soltera_de_montse.html https://inigo.katxi.org/blog/2004/04/25/fotos_despedida_de_soltera_de_montse.html <![CDATA[Fotos despedida de soltera de Montse]]> Fotos despedida de soltera de Montse

Como consecuencia de la Despedida de Soltera de Montse de anoche, están las siguientes fotos. Y para prueba, la siguiente:

../../../_images/pict0093a.jpg ]]>
Sun, 25 Apr 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/04/24/_15.html https://inigo.katxi.org/blog/2004/04/24/_15.html <![CDATA[-15]]> -15

Bueno, pues ya estamos a 15 días del GAS (Gran Acontecimiento del Año).

Acabo de enviar un link de la iglesia a la lista de correo para que la vayáis conociendo.

Y dando un giro de 90 grados al mismo tema, ayer estuvimos Montse y yo en la Boda del Albert y la Laia… estuvo bastante bien… son buena gente, tanto ellos como sus colegas… Si de hecho me tocó en la cena al lado de su madre… ¿y qué puedo decir? todas las madres son iguales, en cualquier parte… jejeje (“Albert, no fumes, que te harás pipi en la cama”).

Por cierto, que ahora están las amigas de Montse preparándola para marcharse de despedida.

En fin, a 15 días, y descontando…

Sat, 24 Apr 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/04/06/recordando___.html https://inigo.katxi.org/blog/2004/04/06/recordando___.html <![CDATA[Recordando…]]> Recordando…

Estaba escuchando algo de música al azar mientras programaba absorto en mis cosas cuando nada más oír los primeros acordes del Deltoya de Extremoduro un recuerdo se ha apoderado de mi mente… aquel verano de hace unos 5 ó 6 años que el vecino y yo nos lo pasamos prácticamente entero borrachos, escuchando una y otra vez la cancioncilla… Dulce nostalgia…

Tue, 06 Apr 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/04/04/i_m_getting_old___.html https://inigo.katxi.org/blog/2004/04/04/i_m_getting_old___.html <![CDATA[I’m getting old…]]> I’m getting old…

I’ve decided to stop compiling GNOME by myself.

Why? Yesterday I spent 6 hours compiling v2.6, just to discover Evolution (v1.4.x or v1.5.x) and Control Panel didn’t work.

As I share the computer with Montse, I can’t afford to have an unstable desktop… so at night I spent other 6 hours to recompile v2.4 to come back to a completely working environment.

I’ve decided to wait for Fedora Core 2 to use Gnome 2.6. Nevertheless I will now have more time to code (or I’ll have to look for other excuses).

I wish yum suport metapackage as apt4rpm does…

Sun, 04 Apr 2004 00:00:00 +0200
https://inigo.katxi.org/blog/2004/04/02/la_vida_es_bella.html https://inigo.katxi.org/blog/2004/04/02/la_vida_es_bella.html <![CDATA[La vida es bella]]> La vida es bella

Pues sí, chicos, la vida es bella.

../../../_images/vida_bella.jpg ]]>
Fri, 02 Apr 2004 00:00:00 +0200