I just decided to release all the code for my Settlers 1 clone to GitHub. You can find more info here. It’s working, and semi-playable, but still pretty far from the full experience. I don’t know if I’ll ever get time to finish it, but at least now someone also can pick it up and hopefully do something nice with it.
Tag Archives: open source
Redshift 1.7
I finally had some time to throw a new release of Redshift together. The most important change, for most of you, is probably the Geoclue location provider by Mathieu Trudel-Lapierre. The old GNOME clock location provider has stopped working for many, as Ubuntu no longer includes a clock applet in the unity desktop. This is fixed now with this new location provider, which should work right out-of-the-box on Ubuntu Natty systems.
Other news are:
- Allow brightness to be adjusted (-b).
- Provide option to set color temperature directly (Joe Hillenbrand).
- Add option to show program version (-V).
- Add configure.ac option to install ubuntu icons. They will no longer be installed by default (Francesco Marella).
- config: Look in %userprofile%/.config/redshift.conf on windows platform.
- Fix: w32gdi: Obtain a new DC handle on every adjustment. This fixes a bug where redshift stops updating the screen.
More free software to flattr

So you’ve just created a Flattr account and now you can’t find anything to flattr? Are you using free software every day? Raphaël Hertzog (of Debian fame) is running a monthly Flattr FOSS newsletter where he recommends free software to flattr. You can see all the previous newsletter posts here.
If you don’t know what Flattr is, have a look here.
AccurateRip tools
I have made some tools for calculating AccurateRip checksums as described here available here: http://github.com/jonls/accuraterip-tools. There is also a tool in the repository for calculating the kind of CRC32 that is included in EAC log files.
- ar_crc: Calculate AccurateRip checksums the naive way (for one offset) and for frame 450.
- ckcdda: Calculate AccurateRip checksums for all offsets (only offset 0 is actually printed).
- eac_crc32: Calculate EAC CRC32 both with and without silent samples.
The code is the documentation, but it should be easy enough to follow. The tools read raw CD audio data from stdin. Track lengths must be given in sector size.
<raw audio output> | ar_crc <offset> <track 1 length> .. <track N length> <raw audio output> | ckcdda <track 1 length> .. <track N length> <raw audio output> | eac_crc32
The raw audio output can for example be produced from FLAC files in the following manner:
flac --decode --stdout --force-raw-format --endian=little --sign=signed Track*.flac
Redshift 1.6 released
- Support for optional configuration file (fixes #590722).
- Add man page for redshift written by Andrew Starr-Bochicchio (fixes #582196).
- Explain in help output that 6500K is the neutral color temperature (fixes #627113).
- Fix: Handle multiple instances of the GNOME clock applet; contributed by Francesco Marella (fixes #610860).
- Fix: Redshift crashes when VidMode fails (fixes #657451).
- Fix: Toggle menu item should not be of class gtk.ImageMenuItem (fixes #620355).
- New translations and translation updates: Lithuanian (Aurimas Fišeras); Brazilian Portuguese (Matteus Sthefano Leite da Silva); Finnish (Jani Välimaa); Italian (Simone Sandri); French (Emilien Klein); Russian (Anton Chernyshov).
Looking forward to 1.6.1
I hope to release Redshift 1.6.1 before the end of the month. It will include some small bug fixes, updated documentation and updated translations, but for this to happen I will need your help:
- Please help get the translations finished for 1.6.1 if you are fluent in one of the languages that Redshift has been translated to. The text strings will not change before 1.6.1.
- Are you familiar with writing man pages? Please help document the configuration file syntax (#662632).
Configuration file
Redshift will look for a configuration file in “~/.config/redshift.conf” (or in XDG_CONFIG_HOME if that has been set). A different configuration file can be loaded with the command line option “-c”. Here is an example:
; Global settings [redshift] temp-day=5700 temp-night=3500 transition=1 gamma=0.8:0.7:0.8 location-provider=manual adjustment-method=vidmode ; The location provider and adjustment method settings ; are in their own sections. [manual] lat=55.0 lon=12.0 ; In this example screen 1 is adjusted by vidmode. Note ; that the numbering starts from 0, so this is actually ; the second screen. [vidmode] screen=1
Redshift 1.4 released
I’ve released redshift 1.4 today. The source is available from the launchpad project page as usual. Packages for Ubuntu Lucid are available in the PPA. There’s lots of exiting new stuff in this release thanks to several contributors: Francesco Marella, Dan Helfman and all the translators.
- Command line options for color adjustment methods changed. Procedure for setting specific screen (-s) or CRTC (-c) changed. See
redshift -hfor more information. - Automatically obtain the location from the GNOME Clock applet if possible.
- Add application indicator GUI (by Francesco Marella) (fixes #588086).
- Add reset option (-x) that removes any color adjustment applied. Based on patch by Dan Helfman (fixes #590777).
configureoptions for GUI changed; seeconfigure --helpfor more information.- New translations: German (Jan-Christoph Borchardt), Italian (Andrea Amoroso), Czech (clever_fox), Spanish (Fernando Ossandon), Finnish (Ilari Oras).
UPDATE: 1.4.1 released. It includes mono icons for Ubuntu (by Joern Konopka); the status icon toggles to show whether Redshift is on or off; and it has updated translations: Spanish (Fernando Ossandon), Russian (Чистый).
Simple flex flip book for WordPress
I wanted to show one of those flash flip books on a web site I maintain. There is a wealth of commercial solutions but they seem to be expensive and, at the same time, not very flexible. I needed flexibility because I wanted a particular effect where the flip book is displayed as an overlay on the web page (think a cross between a flip book and lightbox) and I wanted to integrate it into a wordpress plugin. Fortunately I found an excellent open source flip book solution by Ruben Swieringa.
Flex flip book
The flip book is written in Adobe Flex and released under the CC BY license. It supports embedded images and flash movies, text labels, transparent pages and much more. I just needed a way to show a preview of some static PDF files so I adapted the code code for this purpose:

Flip book overlay on a web page
- Load book pages from XML description file (one image per page; only image files supported).
- Allow web page javascript to flip the pages.
- Random bug fixes…
The modified source code is available here: flipbook-20100308
WordPress integration
The wordpress plugin is still lacking a lot of features and probably has a load of bugs; but it is usable. The plugin uses the shortcode API to allow easy insertion of books into wordpress posts and pages. It is available here: book-20100308.
When you install and activate the plugin, it will create the necessary database tables to handle the books you upload. You need to manually create the folder on your web server where the uploaded pages will reside. The folder must be in the uploads folder and must be called book (usually wp-content/uploads/book/). It should have the same permissions as the uploads folder. There is currently a bug that will mess things up if you haven’t set the uploads folder in settings > miscellaneous, so you have to set that even if you use the default folder.
There is no admin interface for managing books but there is an HTTP API for creating books that is really easy to use. The database will have to be manipulated manually if you need to edit an existing book. A new book is created with the HTTP interface in wp-content/plugins/book/manage.php. You can for example use the utility cURL that is available on many linux systems (line breaks inserted for readability):
$ curl -F log=USERNAME -F pwd=PASSWORD -F name="Name of the book" -F "page[]=@page-1.jpg" -F "page[]=@page-2.jpg" example.com/wp-content/plugins/book/manage.php
This will create a new book in the database with the specified name and pages. You can upload as many page images (as either png or jpg) as you want. The example above won’t really be a book because it will only have two pages. USERNAME and PASSWORD should be the ones that you use to log in to your wordpress site. When the pages have been uploaded and the book created, the script will return the text “Success” followed by the id of the book that you will have to enter in the shortcode.
The shortcode is called book and has the following required parameters:
- book: the id of the book as returned by the manage.php script (it can also be found in the database manually).
- pdf: link to PDF version of the book.
- The content text will be the name of the book.
Next you should customize the CSS for the book display. Here’s an example of how it might look (text is in danish).
Creating image files from PDF documents
You need your book pages as image files for the above to work. Often times I find myself with PDF documents that I want to convert to images. I decided to use the poppler library for this conversion as it has the best rendering of fonts of the solutions I tested. I created a python script that does the conversion automatically. It is a command line utility that depends on the python-poppler bindings. Example:
$ pdftopng.py document.pdf output 420 595
#!/usr/bin/env python
import sys, osimport popplerimport cairo
if __name__ == '__main__': uri = 'file://%s' % os.path.abspath(sys.argv[1]) prefix = sys.argv[2] width = int(sys.argv[3]) height = int(sys.argv[4])
doc = poppler.document_new_from_file(uri, None) for i in range(doc.get_n_pages()): page = doc.get_page(i) page_width, page_height = page.get_size() surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) cr = cairo.Context(surface)
cr.translate(0, 0) cr.scale(width/page_width, height/page_height) page.render(cr) cr.set_operator(cairo.OPERATOR_DEST_OVER) cr.set_source_rgb(1, 1, 1) cr.paint()
surface.write_to_png('%s-%u.png' % (prefix, i+1))This will create output-1.png, output-2.png etc. for each page in the PDF document. The images will be 420×595 in the example above. You can easily convert these to JPEG with imagemagick in linux if you want to save some bandwidth:
$ for f in output-*.png; do convert -quality 90 "$f" "${f%%.png}.jpg"; done
When you have a satisfactory JPEG file for each page you can upload them as a book with the cURL method above.
f.lux for Linux
I have been using f.lux for some time now and it is a really nice tool. It adjusts the color temperature of the screen at night to a more reddish tone which greatly reduces the strain on the eyes. It takes a while to get used to the red tint but now there is no going back.
When I learned that there is a version for linux (xflux) I had to get that for my Ubuntu laptop. I was quite disappointed, however, when I discovered that not only does it not feature a sleek GUI like the windows version, it also simply does not work at all on my laptop. f.lux throws this message at me: “Sorry, we only support 24/32-bit displays right now” which must be a bug because I am running in 24-bit mode with the open source radeon driver.
Other features that are present in the windows version seem to be missing as well in xflux, like setting the daytime temperature. Ultimately I decided to code my own tool to adjust the color temperature. The result is an open source program called Redshift.
Please post comments here.
