Download as pdf or txt
Download as pdf or txt
You are on page 1of 106

Issue 22

Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Issue 22
By admin
PUBLISHED: 2008-05-22

In this issue of Free Software Magazine Terry Hancock interviews the amazing engineers involved in the
OpenHardware project. Gavin Baker casts doubts on the effectiveness of the GPL In today's web-oriented
world where applications are less and less "desktop". Scott Nesbitt's article on Prism, which helps people to
bring web applications to the desktop couldn't be more timely. Steven Goodwin then tries to awaken the
hacker in all of us with his fantastic piece on home automation, and Mitch Meyran talks about creating web
pages the "right" way.

Columnist Gary Richmond talks about Hotwire, a fantastic GUI-oriented command line, and Michael Crider
talks about using Mail Merge in OpenOffice. Mitch Meyran comes back talking about how to configure
mobile devices in GNU/Linux, and Maurice Cepeda talks about the underestimated potential of HTML
editors. Then, for the fans of the command line, Yousef Ourabi talks about writing device drivers for
FreeBSD, Dmitri Popov introduces Mindquarry and Michael Reed talks talks about DOSBox. Finally, Sloan
Miller explains how to configure a professional firewall based on FreeBSD using pfSense. That's quite a
mouthful... enjoy!

Source URL:
http://www.freesoftwaremagazine.com/issues/issue_022

Issue 22 1
Issue 22

2
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


GNU/Linux and free software are unstoppable
By Tony Mobily
PUBLISHED: 2008-05-26

When I first saw GNU/Linux (the kernel plus the utilities) in 1994, I was amazed. I started using GNU/Linux
as a server system, rather than a desktop machine, and I just couldn’t stop thinking: “This will only keep
better and better. There is no limit. This is simply unstoppable. Everybody will be using this, and only this, by
the year 2000”. Remember that the year 2000 seemed really quite far off… and that I was being genuinely
optimistic.

While I was wrong about timing (it’s 2008, and most people are still using Windows, although their number
are declining), I was right about one important factor: GNU/Linux (along with free software) really is
unstoppable.

And right now, its adoption is skyrocketing.

Rather than looking at the past (which can be rather boring), let’s have a look at the present and—even
better—the near future.

About the present, Ubuntu Linux is one of the most extraordinary desktop systems anybody could ever come
across. It’s a complete: comes with a fully functional office suite and every program you might possibly
want—and more. It’s easy to configure, and it’s only getting better at every release. The Linux kernel seems
to be reaching the point where no grand revolution is necessary: it does pretty much anything anybody could
possibly want (from a toaster system to a supercomputer), and—guess what—it’s only getting better at every
release. Server-wise, Apache… well, it doesn’t even need a mild introduction, since it’s “the” web server
which runs the Internet. Amazingly, I am only covering the very tip of the iceberg; there are countless
announcements (Sun’s Java to be released completely, for example) which, although major, are overshadowed
by more “glamorous” events.

What about the future? Well, first of all, there is the invasion of Linux mobile devices brewing. It started very
timidly with the Nokia N800. Google then entered the mobile war, with much noise and a lot of development
power: the result, Android, takes Linux Mobile to the next level. Things are still a little fragmented right now,
but it won’t be long before Linux’s invasion of the mobile market is tangible and avalanche-like. The desktop
world is changing as well: I cannot whine anymore every time I buy a laptop, and more and more people are
switching—and will switch—to GNU/Linux after losing their battle against spyware and viruses. Even on the
server side, GNU/Linux is getting better and has a fantastic company—Red Hat—backing it in the best
possible way for those who want, or need, commercial contracts.

The future looks bright, at least for GNU/Linux and free software. Microsoft & Co. realise that at least from a
technical point of view it’s a lost battle; that’s why Bill Gates, who once hated the idea of software patents,
suddenly fell in love with them. The technical side is lost, and the new fighting arena is in the legal world.
However, even in that respect, it would be simply insane to “make GNU/Linux illegal”, because it’s being
used by too many people and because the main opponent is a convicted monopolist. Plus, software patents are
not exactly “thriving” in the legal world.

For one thing I was right back in ‘94: GNU/Linux and free software are unstoppable, and a new era of
computing has finally started. The 80s and 90s will be seen as the modern IT infancy, where “proprietary
companies tried their best to grab market share and eventually failed”. The IT world is now maturing into

GNU/Linux and free software are unstoppable 3


Issue 22
something that is based on standards, protocols, networks, free software, new development models, and much
more.

So, sit back, and relax. It’s going to be good.

Biography
Tony Mobily (/user/2" title="View user profile.): Tony is the founder and the Editor In Chief of Free Software
Magazine

Copyright information
Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided
this notice is preserved.

Source URL:
http://www.freesoftwaremagazine.com/articles/gnu_linux_and_free_software_are_unstoppable

4
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Group interview: a graphic view of the open hardware
movement. Part 2: technical and social issues
Open Hardware project management through the lens of the
Open Graphics community
By Terry Hancock
PUBLISHED: 2008-05-29

The tools and techniques for creating hardware designs are very different from those used for software; and
because of this, developing open hardware is a significantly different and greater challenge than creating free
software. In the second part of my interview with the developers of the Open Graphics project, I wanted to
explore these factors and the solutions this one open hardware project has found.

Timothy Normand Miller: “I had about eight years of experience with graphics driver development
and about four with graphics chip design, so I figured if I got enough other experts together, designing
a completely open graphics solution would be feasible” (Photo by James Dinan)

There is a great deal of free software infrastructure for creating free software which today we tend to take for
granted: the gcc compiler, the glibc standard libraries, the CVS (and now Subversion, Bazaar, and other)
version management systems, the internet itself, email, usenet, the world wide web, internet relay chat, bug
tracking software, listmail managers, online forums, and even massive integrated project management
services like gForge—all available for free, with very few strings attached; this is mainly thanks to the GNU
General Public License, the GNU project, Linux, X11, and the hard work of countless free software
developers.

But for a moment, rewind to the world of the 1980s, when the GNU project began, before all of that
infrastructure was created.

That’s exactly where hardware design still is today.

“Just as it took the pioneering work of the GNU project to change the world into one in which free
software innovation is easy and natural, it will take bold initiatives to pioneer open hardware”

Group interview: a graphic view of the open hardware movement. Part 2: technical and social
5 issue
Issue 22
And, just as it took the pioneering work of the GNU project to change the world into one in which free
software innovation is easy and natural, it will take bold initiatives to pioneer open hardware. In the
meantime, like the early GNU project which ran on proprietary Unix operating systems (that being the only
ones available), we cope as best we can.

In this second part of the interview, I spoke to project founder Timothy Miller (TM), open hardware board
members Lourens Veen (LV) and Attila Kinali (AK), as well as Timothy’s Traversal Technology partner Andy
Fong (AF) and physicist Dr. Petter Urkedal (PU) who designed a “nanocontroller” for the Open Graphics
architecture.

Abbreviations
The alphabet soup surrounding electronic engineering can be pretty thick. Here’s a guide to the expressions
used in this article:

ASIC An “Application Specific Integrated Circuit” is a large-scale integrated circuit designed to do a


particular job.

BGA “Ball Grid Array” is a package technology which uses balls of solder on the base of a chip carrier to
make electrical connections, rather than pins.

DIP “Dual Inline Pins” is one of the oldest chip package designs, with pins on either side of an epoxy or
ceramic container in which the chip is embedded. These are what most people think of when they say “chip”.

DDR A “Double Data Rate” device acts on both the rising and falling edges of the clock cycle, so as to
squeeze in two transfers per cycle. Usually refers to memory.

EDA “Electronic Design Automation” is computer-aided design software designed specifically for electronics
work which incorporates several different layers of abstraction. There is a free software “GNU EDA” or
“gEDA” which is not one package, but several, forming a fairly complete suite of electronic design tools.

FPGA A “Field Programmable Gate Array” is a combinational logic chip which contains a large grid of gates
whose function can be altered by a downloadable datastream (like flashing a PROM chip).

HDL “Hardware Definition Language” is a program-like textual description of a digital logic circuit. Verilog
and VHDL are particular HDLs. Verilog syntax resembles C/C++.

PCB “Printed Circuit Board” is a component for holding electronic components with etched metal traces to
make the electrical connections between components. Modern PCBs may be made of multiple layers of plastic
and etched metal traces (the OGD1 board has ten layers).

Q. Because Application Specific Integrated Circuits


(ASICs) must be manufactured in bulk, the TRV10
chip that will be developed for the Open Graphics
card (OGC1) is a major cost-driver for the final
product. What kind of volume is that going to require,
and how do you expect to attract that level of
customer interest?
TM: In 2005, we computed that we could do a 100,000 chip run for $2 to $3 million. This would be like
$30/chip at cost. Add cost for the PCB, other components, packaging, margin for failures, marketing,
engineering, overhead, and a reasonable profit margin, and we’re looking at at least $100 per board in low
volume. However, in that time, the economics will have surely changed quite a lot. We’ll still need millions,
but we don’t know the pricing structure.

of volume
6 is that going to require, and how do you expect to attract that level of customer interest?
Issue 22

Q. Even if you do believe the customers are there,


will Traversal Technology be able to find the capital?
TM: There are lots of people who don’t want to put out any cash yet, because so far, we’re a big risk without
any proof that we’re a good investment. Once we’ve proven that we can make real hardware, many people
who are “waiting and seeing” will recognize that we’re a good risk.

Q. What technological changes have led to the recent


boom in open hardware development?
AK: There are two things that made open hardware possible: the possibility to cheaply produce electronics (A
PCB that would have cost $100 twenty years ago can now be produced for $10, even in low quantities); and
the availability of powerful computers in every home to run EDA software without the need of special
workstations.

Q. How does the much greater cost of replication and


derivation make things harder for hardware than
software?
AK: If open hardware wants to use the same methods that FLOSS profited from, building hardware must
become a lot cheaper. Note that I do not speak about producing hardware as this can not get cheaper than a
certain level. But if we would be able to use some hardware building blocks that are mass-produced just to put
together a new device, we could use the same hardware over and over again to build new devices, just like
software uses the very expensive computer it runs on to build new “devices”.

Open Graphics Project Abbreviations


OGP The “Open Graphics Project” is a community of developers working on replacing proprietary 3D
graphics acceleration cards (a major obstacle to Free Software operating systems on the desktop) with
community-designed open-hardware boards which will be free-licensed from the hardware definition
language for the chip through the printed circuit board layouts and of course to the drivers.

OGA The “Open Graphics Architecture” is the gate-logic design of the Graphics Processing Unit (GPU)
being developed to run on the OGD1 and later on the OGC1 cards.

OGD1 The first “Open Graphics Development” card is designed to allow testing of the OGA in an FPGA
device onto which new hardware designs can be loaded by special software. This is the card which will go on
sale this Spring.

OGC1 The first “Open Graphics Card” will be an ASIC-based, consumer-targeted graphics card that will be
developed using the OGD1 as a testbed.

TRV10 The ASIC chip that will be created for the OGC1 and also sold for embedded uses by Traversal
Technology.

TT Traversal Technology is a company founded by Timothy Miller, Andy Fong, and Howard Parkin, which
will actually design, manufacture, and sell Open Graphics cards.

OHF The “Open Hardware Foundation” is a non-profit organization founded to aid OGP (and eventually
other projects) in handling community funding for prototyping and manufacturing costs as well as other
activities to promote Open Hardware.

Q. How does the much greater cost of replication and derivation make things harder for hardware
7 th
Issue 22

Q. What about Field Programmable Gate Arrays


(FPGAs)? How has that technology specifically
affected development?
AK: The development of FPGAs were mostly driven by the non-recurring engineering costs of ASIC
manufacturing and the first-time-right problem. When FPGAs first became popular 10 years ago, they
immediately replaced smaller ASICs or ASICs in low volume production, and helped to increase the speed of
development by spending less time on thinking about how the device might be used in future and more on just
implementing what is needed now and adding functionality later.

Andy Fong: “I graduated with a computer engineering degree focusing on VHDL, digital design, and
microcontrollers. My work was mainly programming in C/C++”

Q. What is in the Open Graphics codebase? What


sort of files does Open Graphics consider to be the
“preferred form of the work for making
modifications” to electronic hardware designs?
TM: The OGP codebase in our Subversion repository, is comprised of a number of major and minor HDL
sub-products, documentation, and software tools. These things include a PCI controller, a microcontroller, a
DDR memory controller, a video controller, documentation on some of these things, an assembler for the
video controller, and a C-language model of the Open Graphics Architecture.

As for the PCB, there is presently no `preferred format’. Due to the complexity of our 10-layer board, we had
to use commercial tools. At present, the best we can do is publish PDFs. If someone thinks they can convert
Veribest files into something more open, we’d be happy to let them try.[1]

AF: Ideally, we should be using gEDA, but we are not. The reason is that any experienced electrical engineer
already has a set of tools they are familiar with, and gEDA is just not one of them. PCB layout is an art by
itself. Many times we have to contract it out and you just can’t find anyone using gEDA for that. However, I
like gEDA a lot, and I did try to use it at the beginning, and it worked pretty well for the schematic capture. I
also asked on the gEDA list to see if there were any professional PCB layout services out there that were
using gEDA. A few people (with pretty good gEDA skills) replied and offered the service at very reasonable
rates. So, gEDA is definitely an option in the future.

PU: Fortunately the task of coding the Open Graphics Architecture can be be split up among developers in the
spirit of how free software is developed, and Andy Fong has already written a C++ model of the graphics
pipeline.

ider to be
8 the “preferred form of the work for making modifications” to electronic hardware designs?
Issue 22
Dr. Petter Urkedal: “I have a PhD in theoretical physics, which I am most happy about as it has been
an excellent background for understanding technology in general”

Q. Is the textual nature of HDLs (Hardware


Description Languages) essential to the success of
open hardware designs?
AK: The textual nature of HDLs isn’t essential just to the success of open hardware. It is essential for any
complex logic design. It is impossible to handle more than a certain, low level of complexity with schematic
input. Anything over that has to be done with textual input.

“The textual nature of HDLs isn’t essential just to the success of open hardware. It is essential for any
complex logic design”

LV: One advantage of hardware description languages over graphical formats is that you can use the existing
infrastructure for software. I do not believe that that is essential however: tools can be written, and even
without them work can often be done, if a bit less efficiently.

Open Hardware Foundation


Recognizing that a project like Open Graphics will need various kinds of material support including
marketing and fund-raising; Patrick McNamara proposed the need for a non-profit foundation to manage these
activities. Since these needs applied to all open hardware projects, and not just Open Graphics, McNamara
and fellow founding directors James Dinan, Terry Hancock (author), Attila Kinali, Hamish Marson, Timothy
Schmidt, James Richard Tyrer, and Lourens Veen formally established the Open Hardware Foundation early
in 2007 with a mission statement addressing support for all open hardware projects.

Although the organizations are obviously closely-allied, the OHF receives no direct material benefit from
Traversal Technology, and thus avoids potential conflicts of interest that might arise from Traversal
attempting to fill this role on its own. OHF is free to represent the open hardware community’s interests and
Traversal is free to pursue its profit motive, without conflicts.

As one of its first formal tasks, the OHF will review developer proposals to determine who should get the
limited number of “developer discount” OGD1 boards to help with Open Graphics development.

Q. What is the significance of the Open Graphics


Development card (OGD1) itself as a tool and as
technical achievement for Open Graphics?
TM: With OGD1, we’re taking a huge step towards being able to put real free-design hardware into the hands
of as many people as can afford it. We already have prototypes, and we’re on the verge of being able to hand
the finished design to a fabrication house. OGD1 is a very interesting product and tool in its own right. A
community will grow up around it and its descendants, regardless of anything we do specific to graphics or
with ASICs. At the same time, it’s also our way to raise funds so we can develop more open hardware.

“With OGD1, we’re taking a huge step towards being able to put real free-design hardware into the
hands of as many people as can afford it”

AK: Besides this, Open Graphics is able to give the field of open hardware more publicity and demonstrate to
a lot of people who have never heard about Open Hardware that it exists and is an active field of development.
Hopefully this raising of awareness will continue and make it easier for future projects to get the necessary
software and hardware tools.

PU: I think OGD1 has a value apart from its use to test the Open Graphics Architecture. One issue currently is
that the specifications for programming the FPGAs are to my knowledge closed. I hope this will change.

Q. What is the significance of the Open Graphics Development card (OGD1) itself as a tool9and as
Issue 22

Attila Kinali: “I studied chip design at the university and have a great interest in how things in my
computer work down to the transistor level”

Q. Any advice for future open hardware projects on


how to manage the above resources? Is it really any
different from software projects?
AF: It is very different from software. For software, all you need is Vim; for hardware, a lot of tools are
proprietary and they are not cheap. You can simulate to a certain degree, but when the actual hardware is here,
you need some expensive equipment plus many years of experience to troubleshoot it. This will prevent you
from working together unless you are really physically together. The challenge is then the huge start-up cost
when developing hardware. So, if you can partner with a company which can provide these kinds of
resources, it will make it a lot easier.

“What seems to be lacking is tool support”

LV: I think that technically there is not all that much difference between a hardware design and the source
code for a piece of software. Both are a collection of files that are modified collectively to create different
versions and branches. What seems to be lacking is tool support. We have tools that let you browse a
Subversion repository online and compare different versions of the source of a piece of software. That will
work for HDL as well, but it will not work for a board layout. Another example of something that we need
software for is a fail safe part number registry.

Q. Is there a problem finding enough people who are


technically qualified to work on an open hardware
project like Open Graphics?
TM: There is a small handful of people with the OGP who actually know chip design or how to write HDL.
It’s a very specialized thing that even the smartest people take many years to learn, so it’s hard for new people
to just jump right in. Thinking about everything happening in parallel is something that takes a lot of getting
used to.

AF: As I said earlier, not only there are less hardware people, but also many times, you really need to sit
together and stare at the problem and try to come up with a solution. However, I think people are out there.
Look at the gEDA mailing list and OpenCores.org.

Traversal Technology, LLC


Without the considerable investment of time and energy represented by Timothy Miller’s company, Traversal
Technology, Open Graphics would not be producing hardware, and thus would not be getting anywhere.

ough people
10 who are technically qualified to work on an open hardware project like Open Graphics?
Issue 22
Miller originally presented his idea to his employer, Tech Source, which develops specialized graphics
hardware for Unix workstations used in such applications as medical imaging and air traffic control.

Colleague and computer programmer Andy Fong says, “Later on the company decided to move the focus onto
other projects instead, so a group of us decided to carry on with the project.” In the end, Miller, Fong, and
printed circuit board designer, Howard Parkin started Traversal Technology LLC to commercialize the
project.

Q. Has education of new participants been a priority


for the OGP?
AF: One of the main purposes for the mailing list is for people to learn and I think Tim has done an excellent
job in answering people’s questions and with several practical Verilog lessons. Many others are also
contributing information on the wiki to educate others. That’s whole point of open source.

TM: One by one, people with HDL experience have been trickling into the project. If this keeps up, I expect
we’ll reach a critical mass at some point where enough experienced people will be available at one time so
that newbies will find Open Graphics mailing list to be the place to go if they want to ask HDL questions and
get good at chip design.

Lourens Veen: “I have held a soldering iron before and even designed a few simple digital circuits,
but I would not consider myself a hardware engineer by any stretch of the imagination”

Q. Is Open Graphics more of a ‘Bazaar’ or a


‘Cathedral’? Is it driven mostly from individual needs
and contributions or by the vision of the founders?
LV: The Open Graphics Project is very much driven by Timothy’s efforts and the hard work of his Traversal
Technology colleagues Howard and Andy. They form the core of the project, especially with respect to the
development of OGD1. However, there have also been quite a lot of others who have contributed significant
parts, especially beyond OGD1. The most important thing I think is that there is an atmosphere of open
collaboration. Timothy has from the beginning asked for advice, and listened to it. The goals we set ourselves
for OGA for example were very much influenced by the community.

PU: The goal of the project is to produce a specific device, and there is a limited set of features which can fit,
given the time to develop and the part costs of Open Graphics cards. That said, I think people will find that
fresh ideas and criticism are well received on the Open Graphics mailing list.

Q. Is Open Graphics more of a ‘Bazaar’ or a ‘Cathedral’? Is it driven mostly from individual11needs a


Issue 22

Open Graphics Community


Attila Kinali, who is primarily responsible for running the project’s Subversion repository, offers some
statistics on the size of the project and the involvement of project developers:

Measure Number
People subscribing to mailing list about 570
People posting on the mailing list about 260
People having SVN write access 11
People regularly committing code 6
Commits to SVN repository 188
Lines of C code about 5,000
Lines of C++ code about 30,000
Lines of Verilog code about 10,000
Size of the Open Graphics Project

The project uses a highly flexible Content Management System (CMS) called TikiWiki with a wiki as the
central metaphor. The installation, management, and hosting of the website and mailing list are donated by
project member Russell Miller (no relation to Timothy) who says he saw the project on Slashdot and wanted
to help out.

Q. How do the necessary skills for the Open Graphics


project affect its social makeup and character? Is it
just another free development community, or are
there fundamental differences?
AK: While most FLOSS and open hardware projects start out small and often stay small, Open Graphics was
highly visible from the beginning and drew a lot of attention of a big and highly interested community. The
challenge was to channel the discussions on the mailing list into actual contributions. There were a lot of
questions that either required a very specialized or very broad knowledge of the problem.

Thus discussions often side-tracked to the easier points and from there off to something completely unrelated.
The main problem behind this might be that there are actually very few electrical engineers and graphics
programmers with the kind of knowledge these questions required in the FLOSS scene. And I think that
attracting these people or training new people to this kind of knowledge will be one of the major difficulties
Open Graphics will face in the future.

“If you give a programmer a buggy editor as well as its source, she will fix the editor. If you give a
hardware developer a buggy schematic capture tool, he will find something else to work on”

LV: Perhaps a key difference between hardware and software projects is that most hardware developers are
not software developers, and the required tools mostly consist of software, not of hardware. If you give a
programmer a buggy editor as well as its source, she will fix the editor. If you give a hardware developer a
buggy schematic capture tool, he will find something else to work on. In a software project, creating the
needed software tools is half the fun, in a hardware project it is a hurdle to be overcome, unless it is a
hardware tool such as OGD1!

TM: Due in part to the fact that there are a lot of both tech-savvy and art-savvy people on the list and our
general awareness that we’re going to have to market ourselves in a way that other projects don’t, we have
organically formed our own publicity and marketing oriented crew. Some of our favorite computer makers
from the 80s failed due to lousy marketing—I don’t think that’s our weakness here.

nd character?
12 Is it just another free development community, or are there fundamental differences?
Issue 22

Timothy Miller: “In fact, the hardware hacking community has never gone away; it’s just adapted to
the changes in technology” (Photo by James Dinan)

Q. Is the recent boom in open hardware more about


the increased need of consumers for control of their
hardware, or about the increased ease in designing
and producing hardware?
TM: Open hardware has always been around. The Apple I was built by hand by Steve Wozniak, and he and
Jobs were members of the Home Brew Computer Club. Those tinkerers have never gone away. But back in
the 70s, electronic end products actually contained large circuit boards with discrete ICs. You could see the
logic. As circuit integration grew, however, we ended up with more and more black boxes that people
couldn’t learn from or hack, and they certainly couldn’t afford to make their own.

This manufacturing gap, you might call it, has been discouraging to the hardware hacker, because the guy
with a breadboard full of 74138s can’t compete in any way with the guy with the chip fab. Still, in the 70s and
80s, there were lots of black box chips, like CPUs. But at least you could stick one on a breadboard. The shift
from DIPs to surface mount and particularly BGAs has made it impossible for the enthusiast to put common
off the shelf chips into a custom design, unless they can make their own custom PCBs with 1/100 inch
precision.

However, as certain kinds of hackable devices—like FPGAs, microcontrollers, and boards like the
Arduino—become cheap and plentiful, a new breed of hardware hackers has arisen. In fact, the hardware
hacking community has never gone away; it’s just adapted to the changes in technology.

——

[1] Veribest is a proprietary PCB design format (now associated with Mentor Graphics.

Biography
Terry Hancock (/user/5" title="View user profile.): Terry Hancock is co-owner and technical officer of Anansi
Spaceworks (http://www.anansispaceworks.com/), dedicated to the application of free software methods to the
development of space.

Copyright information
This article may be re-published under the terms of the [Creative Commons
Attribution-ShareAlike](http://creativecommons.org/licenses/by-sa/3.0/ )license, version 3.0, with the
following as attribution: "Terry Hancock, Originally published in [Free Software
Magazine](http://www.freesoftwaremagazine.com)". The photographs used in this article are PR photos from
the participants in the interview and may be subject to additional restrictions if reused in a different context.

Q. Is the recent boom in open hardware more about the increased need of consumers for13
control of
Issue 22

Source URL:
http://www.freesoftwaremagazine.com/articles/group_interview_graphic_view_open_hardware_movement_part_2_technical_a

ers for control


14 of their hardware, or about the increased ease in designing and producing hardware?
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Free software vs. software-as-a-service: Is the GPL
too weak for the Web?
Preserving software freedom in the era of Web applications
By Gavin Baker
PUBLISHED: 2008-05-27

You’ve read the GPL’s preamble, you can name the Four Freedoms, and you do your best to keep proprietary
bits off our computers. But what’s the future of free software in the era of Flickr, Google Apps, and
Facebook?

What it means to be free


The term free software was defined by Richard Stallman. We know Stallman as the founder of the GNU
Project, the author of the General Public License, and founder of the Free Software Foundation. Stallman
defined free software this way: not by the price of the software, but by the freedoms it accords to its users.

Specifically, users of free software are free to:

• Use the software for any purpose


• Study how the program works
• Change the software, modifying the source code to meet the user’s needs
• Redistribute the software, with or without modifications—to share the software.

Free software is also known as open source. Access to the source code of a program is a precondition of the
aforementioned freedoms—specifically, the freedoms to study the program and to modify it.

So what are the characteristics of free software? Here are some of the more familiar claims:

• Free software is technically better: it’s better code.


• Free software lowers production costs by reducing unnecessary duplication of effort.
• Free software is more secure, because with many eyes, all bugs are shallow.
• Free software is more customizable, because every user has the tools to adapt the program to their
needs.
• Because free software is produced in the open, where everyone is free to share and build upon the best
work, competition is fierce and switching costs are low.

By now, these facets of free software are familiar enough to sound clich?Let’s dig a bit deeper: what else does
it mean to be free?

You’re in control
Digital restrictions are incompatible with free software. Effective DRM depends on preventing the user from
circumventing restrictions; you can’t do that when everyone can see the code.

In addition, the ways that free programs store and exchange data are open. As with DRM, the developer can’t

What it means to be free 15


Issue 22
hide anything from the user, because she has the source code. So, by its very nature, free software uses open
formats and open protocols. (Of course, published specs make interoperability easier, but that’s another story.
In the worst case scenario, a developer wanting to interoperate has to dig through confusing code; that’s still
better than having reverse-engineering as the only recourse.)

This is the social importance of free software

The picture I’m painting is a world where users have control of the software they use and the data they create.
This is what’s attractive about free software—the principles beyond mere pragmatism.

Consider the crucial role of software and data in the modern world:

• To economic vitality and innovation;


• To formal education as well as lifelong learning;
• To information about our communities—about our government, environment, and schools;
• To culture and creativity;
• And to our personal and social lives—as an extension of our selves, and a tool to connect with those
around us.

Seen this way, what user wouldn’t want to have ultimate control of the device they use for all these deeply
important purposes; and what user wouldn’t want control of the data they create with it? This, beyond any
questions of technical merit or fiscal penny-pinching, is the social importance of free software.

Your data, their machine


Most users of GNU/Linux and free software already understand this—at least in a vague, gut sense. But our
understanding (if not the principle) is based on an unstated assumption. The assumption is this: We are
ultimately talking about our devices, right?

What does it mean to have control of software if it’s not running on my machine? What does it mean to have
control of my data if it’s stored on someone else’s computer? These are the questions raised by the rise of
Web applications.

To preserve the freedoms we value, we have to reconceptualize user control

Figure 1: places like this are where much of our personal data are now stored

Services delivered over the web which perform a function which interacts with the user—in some cases, even
duplicating the functionality of programs we’re accustomed to running on the desktop—are increasingly
common. It’s been called software as a service, or more cheekily, Google OS. If we as a community are going
to preserve the freedoms we value in the era of software as a service, we have to reconceptualize user control
of software and data, and look at the new context we’re in.

16 Your data, their machine


Issue 22
In a sense, the “new” context of Web applications is not new at all. Text terminals, thin clients: there’s plenty
of history of users running programs that live somewhere else. But for the most part, we still think of the
software as being close to the user (for example on the same LAN). To run software whose administrator you
don’t know and with whom you have no contact, on machines that are not part of your organization and may
well be located on the other side of the globe—there is something qualitatively new about this.

Web applications actually make it easier for users to switch from proprietary OSs

Before confronting the challenges of this environment, I’ll consider the opportunities as well. The prominence
of Web applications actually makes it easier for users to switch from proprietary operating systems, such as
Mac OS and Windows. You don’t have to worry about how to use Outlook, or how to migrate, if your email
client is Gmail. You don’t have to learn a new address book if Facebook is your Rolodex. You don’t have to
switch to a new photo management suite if your vacation snapshots are all on Flickr. In fact, retail giant
Walmart recently began selling GNU/Linux PCs by Everex, whose gOS distribution adds icons for common
Web applications like Gmail and Facebook right on the desktop. Koolu, the low-cost thin clients promoted by
Jon “maddog” Hall, bundles Google Apps for its customers. These cross-platform applications provide
familiar faces for new users making the switch.

Challenges of Web applications to free software


There’s no reason that Web apps can’t be free software—and many prominent Web apps, such as WordPress
and MediaWiki, are. But there’s a loophole which slows the growth of free software among Web apps: a
loophole in the GPL, the most important free software license.

The GPL has a well-known reciprocity clause, or copyleft: if a developer modifies a GPL-licensed program,
pastes a bit of code from it into his own program, or links with it, that developer is now obliged to “share
alike” by licensing his contributions under the GPL. This is the quid pro quo under which users are granted
the freedoms of the GPL. But the condition of reciprocity only becomes active upon the act of
distribution—and there’s the loophole.

If I distribute a GPL-licensed program, with or without my modifications, I have to extend the GPL’s
freedoms to users who receive the program from me. But if I run a GPL-licensed Web app on my server,
offering public access to the application over the Internet—but never redistributing it—I am under no
obligation to share the code with its users.

If you think that the GPL’s “share alike” clause has helped spur the growth of free software (and I do) then
this should be troubling to you. In a world where software is never distributed to users, but only run on server
farms, authors of free software have no mechanism to ensure that downstream users will be free to use, study,
modify, and adapt their software.

AGPL closes the distribution loophole, but adoption seems slow

At least, they had no option.

A company named Affero thought of this problem a few years back, and received the FSF’s permission to
modify the GPL, adding a clause to require reciprocity for users accessing the program over a network. The
FSF considered adopting this clause into GPLv3, but dropped it during the revision process. However, they
did adopt the Affero GPL as a new FSF license, updating it with the improvements in GPLv3 and making it
possible to link AGPL-licensed programs with those licensed under the GPL. Unfortunately, adoption seems
to be slow: a few Web apps have begun using the AGPL, such as Wikidot and the FSF’s own stet, but the
most prominent free Web applications haven’t converted to the AGPL, at least not yet.

Software freedom in the age of software-as-a-service


There are other considerations for user control in the era of software-as-a-service. Even GPL-licensed Web
applications have no obligation to divulge their mechanisms for storing data or communicating with other
applications, since the source doesn’t have to be public.

Software freedom in the age of software-as-a-service 17


Issue 22
However, let’s presume that you do have the source code for the program, due either to the admin’s generosity
or to the AGPL. You can install a copy of the program and run it on our yown machine. You can learn how
data is saved, and how the application talks to other programs. There’s just one problem: you don’t have your
own data.

When you store information on a remote server, there’s just one problem: you don’t have your own
data

In this example, you have been using the hosted version of this software, be it Gmail, Facebook, or
Launchpad. Now, you can run it and control it. What you lack is oyur data. That’s right: your data, which you
created—and from which the host has likely been profiting, by targeting advertising to you—is not available
to you. You can ask the FBI what information they have about you, but you can’t ask Facebook what
information they have about you. More precisely, you can ask, but they won’t give it to you. (Yes, I have
asked. “Unfortunately, the feature you are requesting is not currently available,” Chad the customer support
representative informed me.)

Not everybody operates this way. WordPress, for example, makes it fairly simple to export your data. But too
often, this is not the case.

Let me clarify: why does this matter? Services like Facebook have a tremendous network effect. Similar to
software with proprietary file formats, users are locked in because all their friends use the same platform. So
you we don’t have data portability, the opportunity for meaningful competition is slim—which means one
company controls our destiny. Meet the new boss, same as the old boss.

Conscientious consumers
So if you’re being conscientious consumers when deciding where to spend your ad views and personal
information, what should you demand?

1. Free license: You should ask that our Web apps be freely licensed, as you would for programs on our
own computers.
2. Source available: Because you can’t rely on traditional copyleft clauses, you should demand that the
source actually be available to users. Preferably, the authors should use the AGPL, to preserve the
freedoms of downstream users.
3. Data portability: Before you entrust anybody with our precious data, you should make sure that you
can take it with you.

Credits
Image: “Server Room : 0” by John Tregoning. Copyright © 2007; used under the Creative Commons
Attribution 2.0 license.

Thanks to GatorLUG and Florida Linux Show, where presenting on this topic helped me to refine my ideas.

Biography
Gavin Baker (/user/45127" title="View user profile.):

Copyright information
This article is made available under the "Attribution" Creative Commons License 3.0 available from
http://creativecommons.org/licenses/by/3.0/.

Source URL:
http://www.freesoftwaremagazine.com/articles/free_software_vs_software_service

18 Credits
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Prism: bringing web applications to the desktop
A nifty way to blur the lines between your computer and the web
By Scott Nesbitt
PUBLISHED: 2008-07-08

Are you still using a web browser to access your favourite online applications? Why not do things the easy
way, and make those applications part of your desktop with Prism.

Introduction
Web-based applications—ranging from office suites to communications tools to wikis—have become
immensely popular in the last two or three years. Of course, getting to those applications means launching a
browser, navigating to a URL, and logging in.

What if you could start those web applications in the same way that you would an application that is installed
on your computer? That’s where Prism comes in.

Prism enables you to create desktop shortcuts that open web applications in their own windows—just like you
would OpenOffice.org Calc or The GIMP. And you don’t have to worry about all the distractions that exist in
a browser window.

What is Prism Anyway?


Prism is a project from Mozilla Labs and is, obviously, based on the Firefox web browser. Prism was
originally called Webrunner, and was a tad difficult to use. You had to run it from the command line with a
URL. Not the most user-friendly way of accessing your favorite web applications! Now, Prism has a graphical
user interface (albeit a simple one) and makes it easy to bring web applications to your desktop.

Since it’s based on Mozilla, Prism will work with just about any web application out there. Keep in mind,
however, that some web applications require Flash or Java. If you have Flash and Java installed, then Prism
will use them.

Prism makes it easy to bring web applications to your desktop

I’ve found that Prism is especially well suited for use with the following types of web applications:

• Web-based email;
• Online productivity tools like word processors or spreadsheets;
• Task management tools;
• Wikis.

Of course, those are personal preferences based on the way I use the web. You really need to try Prism out
with as many web applications as you can to find out what works best for you.

What is Prism Anyway? 19


Issue 22

Why Use Prism?


So, why use Prism instead of bookmarking sites in a web browser, or putting links on your desktop? A few
reasons. First, Prism loads a web application faster than just about any web browser. My main computer is a
ThinkPad T41 notebook, with a 1.6 GHz processor and 1 GB of memory. I compared the start times of
various web applications launched in Prism against the launch times of several web browsers, including
Firefox and Opera. In every instance, Prism loaded faster by several seconds.

On top of that, you don’t get all of the clutter that you find in a web browser. No tool or menu bars, or
anything else to distract you. All you see are the controls for whatever web application you’re using. As I
always stress, working with Prism is a lot like working with your favourite desktop software.

Downloading and Installing the Software


You can’t install Prism using the Synaptic Package Manager or, to my knowledge, any other Linux package
management system. At least, not yet. You need to get the software the old fashioned way, by downloading an
archive. Once you’ve downloaded it, all you have to do is extract the contents of the archive somewhere on
your computer using the GNOME archive manager, or whatever utility that you use to created and
decompress archives.

Where to the Prism software is up to you. I installed it in a directory named /bin' in my /home’ directory.
That’s probably not the recommended way to do this; many Linux users prefer to install software in
directories like /usr/local' or /opt’. I just don’t like having to deal with all the potential permission
problems that come with installing software by hand into system directories.

Next, put a shortcut to Prism on your desktop. This is an optional step, but I find it convenient to double-click
a desktop icon whenever I want to install a web application. In GNOME, right-click on the desktop and select
Create Launcher from the menu that appears. On the Create Launcher dialog box, type Prism in the Name
field, and then click Browse to search for the directory in which you installed the software—for example,
`/home/scott/bin/prism/prism’. Then, click OK.

Figure 1: adding a shortcut to Prism to the desktop

Now, you’re ready to go.

Adding Web Applications, the Hard Way


When I say hard, I don’t mean that adding web applications is difficult. It’s not. You’ll just have to do a bit of
work yourself. An easier, though less flexible, way of adding links to web applications is discussed later in
this article.

To get started, double click on the Prism icon that you added to your desktop. A dialog box appears.

20 Adding Web Applications, the Hard Way


Issue 22

Figure 2: adding a link to a web application

There are really only three items that you need to fill in on this dialog box. The first, obviously, is the address
of the web application that you want to use. The second is the name of the application—say, Gmail. This will
be the label of the icon on your desktop. The third is to click the Desktop option to add the shortcut to your
desktop.

The other options on the dialog box may or may not be useful to you. Clicking the Show location bar option
displays the URL of the web application at the top of the window. To be honest, I find this quite distracting.
The Show status messages and progress option adds a progress bar to the bottom of the application window.
Again, it’s a bit distracting. On the other hand, a number of web applications have keyboard shortcut keys
which, for example, enable you to move to the next message or to quickly page up or down. If you use these
shortcuts, then click the Enable navigation keys option.

Once you’ve set up the web application, click OK. The icon appears on your desktop. To launch the
application, just double click a shortcut and the application opens in its own window.

Figure 3: a web application launched from the desktop

Adding Web Applications, the Easy Way


That’s quite a bit of work. Why do all of that when you can take advantage of pre-packaged links?

The folks behind Prism call these packages bundles, and they’re simply a set of configuration information and
icons for a particular web application collected in a small archive.

With bundles, you set up a web application quickly and easily

To use a bundle, just download it and copy it to your desktop. Then, double click on it. With many Linux
distributions, the Prism bundles (which have the extension `.webapp’) should be automatically associated with

Adding Web Applications, the Easy Way 21


Issue 22
Prism. You experience might vary from distribution to distribution. I wasn’t able to, for example, get any
bundles to work under Xubuntu.

As of this writing, there are only a small number of Prism bundles available. Most of them are for popular
web applications like Gmail, Facebook, Bloglines, Twitter, and Flickr. This list is gradually increasing in size.

Tips, Tricks, and Gotchas


There are a few things that you can do with Prism to make your experience with it even better. And there are a
couple of things that you need to watch out for.

Changing the desktop icon


You may notice that after you install a web application, the desktop shortcut uses the default Prism icon: a
blue globe. Not that it’s a bad icon, but you probably want an icon of the logo of a particular web application
or one that indicates the function of the web application that you’re using — for example, an envelope for a
web-based mail application.

It’s easy enough to change the icon. Just right-click on shortcut and select Properties from the menu that
appears. When the Properties dialog box opens, click the application icon in the upper left. Then, navigate to
the directory `/usr/share/icons’, which is the default location of system icons in GNOME. You’ll have to
navigate through a few directories to find an icon that you like.

Figure 4: choosing a new icon

The set of icons that comes pre-installed with GNOME (or any other window manager) may not be quite what
you’re looking for. However, you can find icons for a variety of web applications by doing a search using
Google or your favourite search engine. When you find the icons that suit your needs, just copy them to a
folder in your /home' directory and the point to that directory instead of
/usr/share/icons’.

22 Tips, Tricks, and Gotchas


Issue 22

Figure 5: custom Prism icons on the author’s desktop

Make Logging In Easier


A lot of web sites and applications use splash pages, which are introductory pages that you have to navigate
past in order to log in. I don’t know about you, but I find splash pages annoying. When setting up your Prism
shortcuts, you can bypass a splash page by specifying the address of the log in page rather than the site or
application’s main page. For example, I use an online photo editor called Picnik which has a splash page. The
log in page is `http://www.picnik.com/app’. When I set up Picnik as a Prism shortcut, I pointed directly to the
log in page.

For better or for worse, Prism doesn’t pass your user name and password to the web application to which
you’re connecting. If you don’t want to continually enter your user name and password when launching an
application in Prism, click the option that enables the web application to remember you. This could be
labelled Remember me or Keep me logged in depending on the application. Not all web applications support
this feature, and it doesn’t always work with Prism.

Hitting a Couple of Snags


While Prism is a fairly solid application, you may run into problems while using it. I’ve consistently run into
the following two.

Prism, while solid, does have a few problems

First, when using a web-based mail application or an online word processor I’ve found that I can’t edit the
body of a message or whatever it is I’m writing. If Prism hasn’t hung, I’ve found that the best way around this
problem is to save my work, close the Prism window, and then restart the application. It doesn’t always work,
though.

You can run two or more applications at the same time using Prism. But every so often, you may get an error
message complaining that another copy of Prism is running. When this happens, wait a few seconds and then
try launching the application again. if the problem persists, you’ll have to resort to drastic measures. Open a
terminal window, and then type ps -u user_name, where user_name is your user name. A list of all
the processes that are running on your computer appears. Note the number beside Prism, and then type kill
followed by the number. That will shut down all running instances of Prism, so use the kill command with
extreme care.

Conclusion
With the web becoming such an integral part of our lives, it’s only natural that many of our computing needs
are moving to the web. With Prism, you can seamlessly access and use your favourite web applications in the
same way that you do the software that’s installed on your computer.

Conclusion 23
Issue 22

Biography
Scott Nesbitt (/user/44665" title="View user profile.): Scott is a writer of various things -- documentation,
articles, essays, and reviews -- based in Toronto, Canada. He's been using Linux for work and play almost
exclusively since 1999.

Copyright information
This article is made available under the "Attribution-NonCommercial-NoDerivs" Creative Commons License
3.0 available from http://creativecommons.org/licenses/by-nc-nd/3.0/.

Source URL:
http://www.freesoftwaremagazine.com/articles/prism_bringing_web_applications_to_the_desktop

24 Conclusion
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Home automation in GNU/Linux
Or how to email your light switch with free software
By Steven Goodwin
PUBLISHED: 2008-07-03

Home Automation is anything that your home does for you automatically to make living there more enjoyable
or productive. It covers many areas, including remote and timed control of lights and electrical home
appliances, distributed media services, and communication. Over the last 10 years, many hardware
manufacturers have presented their own proprietary solutions to these problems. Unbeknownst to them, a
groundswell of developers from around the world has been providing similar solutions to the free and open
source community.

In this introductory article, I will carry out a high-level review of a number of these projects to see what is
already available.

Appliance Control
One of the most impressive features of an automated smart home is the ability of a computer to control your
lights or to operate the power socket attached to the kettle. Naturally, this requires the addition of hardware,
and the most prominent example here (with a good trade-off between cost, longevity, and flexibility) is called
X10.

X10 is a protocol that places specifically-formatted high frequency power bursts onto the mains power line.
Since the mains cables are connected to every light bulb and power socket in the house, a signal placed onto
the power line in one place is seen across the rest of the mains supply. Consequently, a special X10-enabled
power socket is able to watch for these power bursts and switch itself on or off, accordingly.

To place these X10 signals onto the mains requires a peripheral, such as the CM12U (see figure 1) which also
contains a serial plug (either RS232 or USB) that is inserted into your PC. To receive these signals you can
use either:

• An appliance module that will turn a socket on or off. You simply plug this unit into the wall, your
appliance into the other side, and switch the wall socket on. The appliance (such as a kettle) is then
controlled by a remote X10 signal. One such unit is shown in Figure 2.
• A light bulb attachment unit, as seen in Figure 3. It is placed in series with a conventional bayonet
light socket, and acts like an AND gate. It can only be controlled through remote X10 signals.
• Or a special light switch that replaces your existing switch and will control the light to which it is
attached. This control is either by the switch itself, or remote X10 signals. This can also function as a
dimmer switch, and shown in Figure 4.

Appliance Control 25
Issue 22

Figure 1: This is the CM12U that transfers X10 signals between your computer and the power line

Figure 2: This listens for X10 signals and controls whatever appliance is plugged into it

Figure 3: Fitting directly into an existing light socket, this is the easiest way to add lighting control to
your home

26 Appliance Control
Issue 22

Figure 4: This replaces an existing light switch, and is the most effective way of controlling a light

Each of these devices is given an address. This comprises of a house code (A-F) and a unit code (1-16) for the
individual appliance. The house code is necessary because the mains voltage to your house is often fed from
the same supply as that of your neighbour, meaning your appliances would see their X10 signals and
vice-versa. It is possible to buy an X10 suppressor to stop your X10 signals leaking out, but the current take
up of X10 is not universal enough to be a problem—unless you live in a block of flats inhabited by geeks, it’s
unlikely to be a problem in the near future.

A question of countries
NOTE: The mains voltage and frequency varies according to country, so specific devices are needed
depending on where you live. Check the vendor websites carefully. The codes given in this articles are for UK
devices.

Sending suitable X10 signals (through the CM12) requires software, and the current favourite is heyu. This is
not truly open source, but close enough for most purposes. It exists as a simple command line utility (with
configuration in /etc/heyu/x10.conf) that lets you control the lights with commands such as,

heyu turn bedroom_light on

and

heyu dim studio_light 2

These commands can be triggered from a web site, script, crontab, or command line. As an alternative to cron,
you can also upload a program containing a sequence of on/off messages directly into the CM12 as this allows
you to specify a set of timer events that will execute, even when the computer is off.

The CM12 gives more control over the lighting sequences in your house than a traditional timer switch, and
allows you to program more realistic scenarios. For example, you can program a sequence whereby the unit
switches the landing light on, waits one minute, turns the downstairs light off, waits one minute, and then
turns the upstairs light on. This subtlety gives the impression of someone walking up the stairs, and switching
the lights on and off as they go, which is the mark of a human, not a machine.

Since these commands can be placed in a bash script, it’s trivial to produce a make_a_cuppa script which
switches on the appliance module connected to the kettle (E5 at my home), waits until the kettle has boiled (3
minutes 35 seconds, for 1.5L of water, for example), then announces (via the speech synthesizer, Festival)
that the kettle has boiled, and switches the appliance off again. A video of this in action can be found on the
zdNet site, as part of their Homebrew competition. All you need to remember is to fill up the kettle after each
use.

Other devices you can handle with X10 include curtain rails, motion sensors, and water valves.

Appliance Control 27
Issue 22

Cosmic Control
In addition to receiving signals, there are several X10 devices that can send them, such as the HR10e, in
Figure 5. This is an RF to X10 transmitter, which sends on, off and dimmer messages to the RF receiver
(Figure 6) and places an appropriate signal onto the mains power line. Normally, these messages would go
straight through to the appropriate X10 device, but with a GNU/Linux machine and a CM12 we can listen for
these signals and do something different.

Figure 5: An RF transmitter

The heyu software I described previously is capable of listening to all X10 messages on the power line, and
triggering a command whenever they arrive. So, by adding the following lines to your configuration file:

SCRIPT e1 on :: /usr/local/minerva/bin/mixer default dec master 10


SCRIPT e1 off :: /usr/local/minerva/bin/mixer default inc master 10

You can vary the volume of whatever music is playing on your machine.

Figure 6: The TM13UAH listens for RF signals, and places the X10 command onto the power line

I use the standard X10 RF transmitter (shown in Figure 5) to send signals to this receiver, and have split the
controls into three main areas:

1. Common handling. Volume change, mute and pause are used so commonly, they deserve to be
present in all modes.
2. Mode-specific functions. The central 8 buttons.
3. Common system. These change the mode, and report on the general status of the system.

As you can see from the picture, this device has no output. Therefore feedback must be given aurally to
indicate to the user than their request is underway, gently reminding them to stop pounding the buttons. The

28 Cosmic Control
Issue 22
feedback in use at my home is a simple chime sound plus the speech synthesizer, Festival. This allows for
arbitrary text to be spoken and includes the alarm clock, weather reports, and information from the train’s live
departure boards.

The software I use is part of the Minerva home automation suite, and called Cosmic. The default modes in use
are:

• Multimedia: CD playing, MP3 jukebox control


• Timer: Start a timer for 5 minutes, and a voice will remind you at the appropriate time.
• News: Basic status information, such as weather, news, and calendar events.

Media Control
For many people, the start (and end) of their home automation experiments involve media distribution. This
can vary from a simple file server or NAS providing their mp3 collection to their PC, up to a full set of DVR
machines for every room in the house. There is no correct solution here, it varies according to the amount of
time, money, and expertise you’re willing to lavish on the problem.

File Servers and NAS


At the bare minimum, you will need a server. This can be as complex as a series of rackmounted machines in
their own location (called node 0 by HA geeks), or an NSLU2 (a.k.a. Slug) hidden under the stairs with some
USB hard drives attached. Whatever approach you take, having your media available on Samba shares gives
the most expansive scope for automation, as it makes the data accessible to almost all flavours of operating
system, as well as several custom pieces of hardware such as the Slingbox.

DVRs and PVRs


To some, having a GNU/Linux machine running MythTV is the height of home automation. Not so! There
are many free alternatives available, and many configurations possible.

To begin, MythTV itself provides two separate components, the backend and the head box, known as
mythfrontend. This allows one machine to record and encode the TV programmes in a central location
(such as node 0) that can then be played back to any front end in the house. This has the advantage of a central
store with all your media accessible to every room in the house, along with the physical benefits of being able
to use heavy iron in a remote location where the necessarily loud fans will not disrupt your viewing.

Any machine placed in a living area, such as the bedroom or lounge, should ideally be fanless because
the noise of a standard PC will annoy you during the quiet bits of a film and at night

Staying with TV solutions briefly, old games players with an Xbox gathering dust may be able to put it to use
by installing XBMC (Xbox Media Centre), although the fan is quite loud.

Additionally, you should investigate alternative solutions such as DVR, Video Disk Recorder and FreeVo.
There are also projects, such as MVPServer that can serve content directly to the (proprietary) Hauppauge
MVP. Since this is a silent head box, it’s worth considering.

Media and MP3 Jukebox


Once your MP3’s are located on a central server, you have three methods of streaming that music around the
house.

Local Operation
Use a PC in each room to stream the file across the network, and decode the music locally. This doesn’t need
to be very powerful (a Mini-ITX is more than enough) and there are even hardware solutions, such as the
aforementioned Slingbox. Also, you can use any media player and operating system for this, since you can

Media Control 29
Issue 22
simply mount your media server as a normal drive.

Streaming Server
Set up a streaming server in node 0, and use VLC to distribute the music across your wired, and wireless,
network. There is also a plug-in for Firefox that allows you to stream VLC data directly to your browser. It is
also possible to stream using Shoutcast and Darwin.

If video-only is all that’s required, as it is with CCTV footage, then camserv is a possibility. This produces
streaming Mjpeg images through a specific port with its own in-built web server, allowing you to view the
camera output from any compatible web browser.

Remote Operation
Put a soundcard in the server, and run audio cables from here to other amplifiers around the house. This
requires some physical work, but it is not hard. From here, you can set-up some simple MP3 jukebox software
on your server, and control your songs’ playback through a web browser.

I have personally adopted the third approach since I can use the same approach to also control my CD player
(through cdcd), the volume (using aumix) and FM radio (present on most TV cards, controlled through the
fmtools package). In each case, I use Bearskin (part of the Minerva project) to abstract the underlying
software, so should the best tool change I don’t need to update any of my scripts or web pages.

TV Bonuses
There are two features, often overlooked, once you have a TV card inside your PC. The first is infra-red
remote control. While some many use the supplied remote to switch channels on the TV card, many will be
impressed by the LIRC project which can watch these IR signals and perform other, more interesting tasks, by
triggering arbitrary scripts on the host PC. It can also function as a mouse if you’re running X. Even if you’re
without a TV card, the LIRC website details simple circuits you can make yourself.

The second “hidden” function of TV cards is its ability to retrieve Teletext data. This is what the Internet
would look like if we were all still on dial-up connections. Consequently it is very low bandwidth, making it
perfect fodder for screen scraping the lesser frequented pages, such as the holiday competitions and quizzes.
Tools, such as Alevt can be run overnight to cache the pages for review in the morning. An entire day’s worth
of teletext is so small it can fit on most mobile phones.

Communication
When you have a house functioning as a peripheral to your computer there is a significant paradigm shift, in
much the same way that broadband brought about a change more substantial than simply faster and
continuous downloads. So having your own home server running 24-7 is more important than the ability to
check your email without tying up the dial-up phone line.

When you have a house functioning as a peripheral to your computer there is a significant paradigm
shift

Being able to connect to your home at any time to check up on a document on your home server is an obvious
benefit, and one GNU/Linux users, through SSH, have enjoyed for many years. But with HA solutions, you
can also check up on the CCTV feeds, or listen to your on-line baby monitor. Both can be serviced through
the same streaming technology (such as vlc) as your MP3 server, thereby eliminating any extra work.

It is not too difficult to extend this idea and roll-your-own security systems, similar to the expensive
proprietary solutions, such as Comfort. Within this example, a simple doorbell and intercom becomes a
significant improvement in household security, as the intercom’s audio can be routed (via Asterisk ) to your
desk at work, or mobile phone if you’re on holiday. Any caller can then be made to believe you’re indoors,
but bedridden, thus limiting the possibility of a subsequent burglary.

30 Communication
Issue 22
But VoIP is not the only phone-based interface available. There are a number of mobile phones in use that are
compatible with utilities such as Gnokii, Gammu and gsmlib. These allow your suitably-equipped
GNU/Linux machine (you’ll need an extra cable) to listen to SMS text messages, and trigger scripts according
to their content. These scripts can include controls for your lights, or setting the PVR to record something you
didn’t previously know was on. It can also text you alerts without relying on an external (and expensive)
server, so reminders about the last train, or wake-up calls are easy.

Similarly, since everything is run by a GNU/Linux server, it is trivial to add your own mail server into the
mix, and control the other technologies (radio, video, lighting) by email. I have emailed my light switches at
home on many occasions, just because I could! More practically, you could email your kettle when you’re
leaving the office, and because it knows how long it takes to boil the kettle, and the commute duration, it can
have a fresh brew ready for you the second you step through the door. Or you could use procmail to
monitor the “where are we meeting tonight” thread and SMS you of anything marked with “change”, or
otherwise deemed important. Because this is home automation, you don’t need to use on sophisticated
technical solutions to this, as you can rely on the social bond between all those using the system to not abuse
it.

I have emailed my light switches… because I can

Advanced users may also use Bluetooth to detect the owner’s mobile phone coming into range and use this as
a remote control to switch lights on, and start playing music.

Web Life
While discussing current projects with a friend of mine, he happened to remark that “every project of yours
starts with a web page”. He was right! This is because the web browser is a ubiquitous piece of technology,
and provides a uniform interface across most devices, making no distinction whether I’m at home or work, or
working on a PC, PDA, or mobile phone. There is consequently no difference between what I can do at home,
and at work, and since my data is stored on my own server I’m happily in charge (and control) of it. This is a
feature that most commercial solutions have thus far overlooked.

Preparing a home server is easy, since we need only an Apache web server and a rudimentary ability with any
of the ‘P’ programming languages (Perl, PHP, Python, or, er, Ruby!) With this we can provide access to
Google Calendars, manage our contacts lists, and handle the home notice board. These are accessible from
anywhere in the world, and each PC in the house.

the web browser is a ubiquitous piece of technology

This also provides a common place to store bookmarks for all the family’s common web pages, such as those
with the TV listings, weather, or train departures. We already have a number of commonly accessed pages,
each personal to ourselves. For example, we might always read the news from Slashdot, and check our diary,
while we eat breakfast. So gathering this information and unifying it into a daily personal digest–either on a
web page, or transferred to your mobile or PDA–is a useful task, and easy to do with free software.

the fridge is the focal point for many families, so having unified access to all data here is a boon to living

Apart from the standard Apache installation, it can be pleasant to setup dynamic DNS so you can access your
home server with http://my.homelinux.net, for example. One service to provide this is DynDNS. You will
naturally have to provide your own security, perhaps with SSL, but there are many documents available on the
web detailing this. It is even possible to require SSL for remote access, but not for local traffic. After all, all
local traffic can only come from your house, where any “cracker” already has physical access to the machine,
your fridge, and TV set. Such attacks can be dealt with by sending the perpetrator to bed early with no dinner!

Data Sources
What separates a home automation server with any other common-or-garden server is the home-oriented
information present. Conversations and matters of general life such as “will it rain this afternoon” and “I hope
the train’s on time” are more important to domestic life than how many web pages your Apache installation

Data Sources 31
Issue 22
can serve. That is, content is king and localized. Consequently, we need to know from where this data
originates, and how to present it.

In all cases web services would appear to be the answer. However, since many content providers are either
unable (or unwilling) to provide their information in a simple and direct manner we have to often get our data
from second hand sources utilizing glue software.

TV Guides
Being able to list today’s TV shows that feature Freddie Mercury (I don’t consciously remember to look for
them, but I’ll watch every one that’s on!) is a very useful home-oriented feature. Naturally, a server is the best
place for this because the information can be collated locally, and distributed remotely to whichever machine
you’re working at. (Unlike the programme guides found on many digital TV boxes which remain routed to the
physical machine, or magazines which remain under the couch!) For this to work you need a generalized
source of TV information, which because they vary between areas, must be sourced locally.

For those in the UK, the best online TV guides I use come from Bleb. This is a fantastic service which
provides details for the next 7 days in an easily parsable XML format. I use this to generate automatic
schedules everyday by searching the title and programme description for keywords that are specific to me. It
is also the source used in the Minerva TV Guide applet, shown in Figure 7. Other sources no doubt exist for
other countries.

Figure 7: My personalized TV guide

The only problem with this data source is that the ITV channel is not available. It seems that the BDS
(Broadcasting Data Services) are deciding to play hardball, and stopping people from re-distributing the TV
listings. So the only way to get them is to pay the licensing fee, or scrape them from the ITV web site directly.
This is amusing since ITV gladly include the listings from other TV stations!

Radio guides are not, alas, as well supported. There are several possibilities as to why (no market, too
localized) but at least the station can generally be identified because all broadcast frequencies are controlled
by the governing body in each country. For the UK, this means OFCOM, and they have information listing
each station, its frequency, and grid reference on their web site. This is available as an Excel spreadsheet or in
RadioML format.

Live Departure Boards


Many train stations are getting dragged into the 21st Century by providing their train information to the public
via its web site. This makes it trivial to produce an HTML GET request to their server, providing a simple
bookmark feature detailing the status of your train home. Clever coding also allows you to write a
computer-controlled alarm clock which varies the wake-up time, based on the punctuality of the train. Greg
McCarroll gives an example of this.

32 TV Guides
Issue 22

The Weather
Both my parents and grandparents had a barometer, which gave an indication of the weather based on changes
in atmospheric pressure. Before they went out, they would tap the barometer to see how the needle moved,
and take their umbrella with them if it moved to the left.

I have an Internet connection and an RSS feed to Yahoo! Weather. This is updated everyday, so my computer
performs a simple,

wget -q http://weather.yahooapis.com/forecastrss?p=UKXX0088 -O cache/weather.xml

And then processes this XML into a simple description through an XSL stylesheet. The UKXX0088 reference
is an indication of your worldly physical location, so it can get the right forecast for you. This resultant text is
then rendered onto one of my web pages, and spoken (through “Festival”) over the speakers as part of my
alarm call. All this code is available for free within the Minerva Home Automation suite, but is easy enough
to write yourself.

For more advanced weather reports, some people have their own weather stations at home. These can be
bought from most gadget shops, and are relatively inexpensive. However, most of them function only as
electronic barometers because they can’t interface to a computer.

If you can’t interface with it – you can’t automate it

Audio CDs
Most people will know this already, but FreeDB contains the track listings of several million CDs. This can be
incorporated into CD playing applications to provide a nicer interface. The web interface for the CD player
applet, for example, lets you click on the song name in order to play it (see Figure 8) instead of the track
number. Similarly, instead of the rather bland “07” track readout present in the 1980’s, this can be rendered to
a web page, Jabber tag line, Twitter, Facebook, or whatever the cool-du-jour happens to be this week!

Figure 8: Playing a CD from the web

What’s Next?
FLOSS provides many possibilities to enhance existing HA installations, and in some cases they surpass the
current commercial offerings, but there’s always room for improvement in both software and hardware.

Embedded systems are still required in many areas, to reduce the carbon footprint of full-blown PC’s in each
room. One such benefit would be a stand-alone kiosk browser. This would run on basic hardware featuring a
network socket, speaker, microphone, a touch-screen display, and nothing else. With this, you have a remote
control that may be placed anywhere in the house giving you full access to everything (including streaming
video, VoIP, and lighting control) to give the house a truly futuristic feel.

What’s Next? 33
Issue 22
Additionally, more software services are hoped for. A common and accessible method is necessary to provide
HA-data to everyone that wants it. Currently, data is made available for only personal use, which means you
need to be at least slightly geek-oriented in order to understand it. Free software can help lower this barrier to
entry by providing ready-made solutions to the masses.

There are many forums, shops, and web sites about home automation. And you can learn about most of them
on the Minerva home automation page. So get reading, and happy hacking HA hacking!

Biography
Steven Goodwin (/user/39" title="View user profile.): When builders go down to the pub they talk about
football. Presumably therefore, when footballers go down to the pub they talk about builders! When Steven
Goodwin goes down the pub he doesnâ’ t talk about football. Or builders. He talks about computers.
Constantly... He is also known as the angry man of open source. Steven Goodwin
(http://www.bluedust.com/blog/) a blog that no one reads that, and a beer podcast
(http://www.thebeercrate.com) that no one listens to :)

Copyright information
This article is made available under the "Attribution-NonCommercial" Creative Commons License 3.0
available from http://creativecommons.org/licenses/by-nc/3.0/.

Source URL:
http://www.freesoftwaremagazine.com/articles/home_automation_in_linux

34 What’s Next?
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Creating web pages, the right way
Web scripters: take care of your pages' code!
By Mitch Meyran
PUBLISHED: 2008-07-01

Have you ever felt that warm fuzzy feeling of knowing that your code is error-free and complies with the
latest standards? In terms of programming skill, web authors are too-often seen as the bottom of the barrel
(you will notice I didn’t call them ‘web programmers’) due to the apparent forgiveness and limitations of the
platform. However, they are required to cover a large array of programming expertise and, even worse, they
must ensure that their code runs the same on various platforms–something “real” programmers consider a
challenge.

The “bottom of the barrel” indeed!

During the first browser war, from 1997 to 2001, being a web coder was interesting, with the gap between
Internet Explorer (IE) 4 and Netscape Navigator 4. The former used “advanced” CSS (how things have
changed!) while the latter had interesting scripting capabilities (but its frequent releases were so quirky that
they discouraged developers from using them).

But when Netscape was sidelined, web authors were required to write for a single platform (IE) which had a
proprietary model–and this sad state of affairs lasted for half a decade. During that time, web coding required
you to know very little: Visual Studio (or Frontpage, or Dreamweaver) and the twisted view of the Internet
that IE 5/6 gave you.

Recently though, due to the rise of “alternative” browsers (such as KHTML/Webkit-based Safari, Mozilla
Firefox, and Opera), writing code only for IE would make any website automatically loose 20% (or more) of
the market; and this trend isn’t reversing (even IE, with version 7, is getting slightly more
standards-compliant). So web authors must change their habits and code for more platforms. And what’s
common between most of these alternatives? Conformance with standards.

Which, authors find out, are quite a challenge to use correctly.

Now, some web authors may try to keep creating “tag soup”. It is perfectly possible to output atrocious code
that all current rendering engines will treat the same way–or choke on similarly. However, one may very soon
find out that actually creating “good” code is much less of a hassle than tinkering with “tag soup” is.

It is perfectly possible to output atrocious code that all current rendering engines will treat the same
way–or choke on similarly

Creating good mark-up


The basis of a web page still is hypertext mark-up language (HTML). It has seen several variations, with
HTML 4.01 and XHTML 1.0 (each further divided into Transitional, Frameset, and Strict versions) being the
most interesting to look at. The main difference between these two is that XHTML 1.0 is equivalent in
functionality to HTML 4, but makes use of XML syntax instead of HTML.

Creating good mark-up 35


Issue 22
Moreover, while HTML 4.01 doesn’t care about the case of tags and parameters, XHTML is case sensitive: all
tags and parameters must be in lowercase. In the present document, when talking about a specific tag, I will
write it uppercase for easier reading. However, they will be written in lowercase inside code samples.

The three sub-divisions are the same for both languages:

• Transitional takes HTML 3.2 (the Frankenstein’s Monster of web specifications) and tries to give it
some order: several duplicate functionalities are removed, and some parameters are unified. It is also
the first HTML specification that allows you to build a standardized Document Object Model (DOM).
• Frameset removes most of what made HTML 3.2 a Frankenstein language: anything that is geared
towards making HTML something other than a mark-up language was removed (specific style
options, tags that required actions from the browser, etc.), apart from frames. Those used to be useful
for early “dynamic” websites, and were kept for a time.
• Strict is similar to Frameset, but removes frames from the specifications. Indeed, they are actually
redundant and harmful since frames break navigation models and can be advantageously replaced
with more generic OBJECT tags (except that those are still not correctly supported under IE 7).

Strict versions of XHTML and HTML are the easiest to learn, and the most similar–but I would personally
recommend the use of XHTML 1.0 Strict for authoring your pages because several web browsers are, now,
able to notice incorrect code and report it directly.

Once you are done, you’ll be better off (at least for now) with HTML 4.01 Strict–which requires very little in
terms of modification over XHTML 1.0 to validate: indeed, making XHTML code into valid HTML code
merely requires slashes (/) to be removed from self-contained tags (like BR), and image maps (rarely used
nowadays) to change their syntax slightly (and this was, actually, an error when establishing XHTML
syntax–most browsers today use the HTML 4.0 syntax for image maps on XHTML 1.0 documents anyway).

For example, while in HTML 4.01 a horizontal ruler (HR) could be written as <HR> or <hr>, in XHTML 1.0
it must be written as <hr/> (or <hr />; note that extra space, so that browsers like IE 4 or Netscape 4 can
still understand it).

Validation, why it will help you


What is validation? Well, it is ensuring that no tags are used that don’t belong into the document type. Here
follow a few notable examples:

• FRAME is no longer allowed in Strict documents; this tag allowed you to load another HTML
document inside a frame. It wouldn’t appear in the browser’s history, and implied a graphical
representation. The OBJECT tag is more versatile, as it can open HTML documents, but also images,
movies, and applets. It can also be nested so as to provide fall-back content. For example, if a browser
can’t open a movie; it might try to open a Flash applet; and if Flash is not supported, it might open an
animated SVG; and if that’s not supported, then it might open an animated GIF, and so on.
• MARQUEE is no longer allowed in Strict documents; this tag allowed you to put a lot of content and
have it scroll inside a block element. Parameters defined how fast the scrolling went and in what
direction. This required HTML to describe actions, which is contrary to the format’s purpose. It can
be replaced with CSS and JavaScript.
• The target parameter inside anchors (A) is no longer valid in XHTML 1.0: instead, you must use
rel (which defines the relationship of the anchor’s href designated document in relation with the
current document). Opening a new window must be made specifically through JavaScript, making
target="_blank" illegal. However, due to its heavy use, target will remain part of HTML 5.

To generalize, elements that entail an action from the browser or that have more efficient alternatives are
being phased out of HTML.

Elements that entail an action from the browser or that have more efficient alternatives are being
phased out of HTML

HTML 5, which is in the planning stage, will use HTML 4.01 Strict as a basis. Thus, it is worth your while
learning about HTML 4.01 Strict. But this is only one advantage of validation. Next comes proper tag

36 Validation, why it will help you


Issue 22
chaining and proper tag nesting.

What’s wrong with badly nested tags? Well, here’s an example:

<b><i>some stuff</b>
some other stuff</i>.

The correct form would be:

<i><b>some stuff</b>
some other stuff</i>

Nothing too hard! However, you may sometimes want text styled like this:

<b>bold text
<i>italicized and bold text</b>
italicized text</i>

And what’s wrong here? Well, it is very troublesome.

The DOM is supposed to be a tree. This means that an element can contain several elements, but elements
can’t overlap. In the example used above, closing the bold tag should make the italic tag automatically close
(and the closing tag </i> is, thus, a coding error), but since italics must be explicitly closed, we have here two
coding errors: an unclosed italic tag, and an unexpected italic closure.

How do browsers deal with this wrong mark-up?

• Mozilla Firefox/Gecko considers that bold and italics are closed at the same time on a DOM level, but
may apply CSS styles until it reaches the italic closure tag. This helps to get the required appearance
and creates a valid DOM tree, but makes some styled elements unreachable through the DOM
• KHTML/Webkit acts pretty much the same way as Gecko
• Opera closes both tags when the bold node is closed, but then opens a ‘phantom’ italic node until it
reaches the italic closure. This creates a valid DOM tree and applies styles similarly to Firefox, but
creates unnamed nodes
• IE makes the tags overlap: italic is considered both a child and a sibling to bold. This makes any
recursive operation on the DOM tree circle endlessly

Of all, Opera’s is probably the closest to the ‘proper’ solution’:

<b>bold text
<i>italicized and bold text</i>
</b><i> italicized text</i>

You could also do:

<b>bold text</b>
<b><i>italicized and bold text</i></b>
<i> italicized text</i>

for a more semantically correct display.

You could also use CSS for styling (the STYLE tag must be in the document’s header). Remember, I’m using
uppercase letters to name tags in my explanations, but writing them in lowercase in actual code. Writing them
in lowercase is recommended in HTML 4 and CSS, and you must do so for XHTML:

<style type='text/css'>
.fat {font-weight:bold}
.bent {font-style:italic}
</style>
...
<span class='fat'>bold text </span>
<span class='fat bent'> italicized and bold text</span>
<span class='bent'> italicized text</span>

Validation, why it will help you 37


Issue 22
That’s the cleanest implementation I know (notice that there are only 3 nodes, all on the same tree level, and
that the second one uses multiple CSS classes). Instead of spans, you could also use EM and STRONG tags,
allowing screen readers to change voice intonation for disabled users.

Obviously, properly nesting tags removes a lot of headaches–and explicitly closing all tags (as required by
XHTML) helps to remove a great deal of confusion over tag scopes: there’s no more need to remember what
tags must be explicitly closed, as all of them must be.

Now, nobody is safe from making mistakes. Generating content (as when you use PHP, ASP, Perl, Python or
Ruby to generate web pages) can make predicting a page’s structure difficult. I won’t deal with these
languages here; I will just say that following the guidelines and advice herein may help you organize your
generated documents better, and make the process clearer.

One very simple way to prevent problems is to ensure that as much content as possible is generated as
complete nodes, for example by generating mark-up starting with an opened tag and ending with that same tag
closed, or insert generated content inside a properly closed tag.

Then, while testing, XHTML on a modern browser will make errors stand out right away (provided said
XHTML is sent with a proper MIME-type: application/xhtml+xml): browsers will ask for explicitly
closed tags all the time; will require tags and parameters to be case sensitive; and will demand a correct DOM
tree. Once a browser detects no more structural errors, you can send the code to a validator that will ensure
compliance of the code with its header’s signature.

In short, this will make sure that you’re not using Frankenstein-ish HTML 3.2 code in an XHTML 1.0 Strict
document. One of the best validators out there is the W3C’s automatic validator: http://validator.w3.org.

A validator will also ensure that your document’s encoding matches its header’s encoding (great for testing
that your server does respect your encoding instructions, which can be a pain if your content includes
non-ASCII characters).

Validating your page has, at the very least, the advantage of ensuring the least discrepancy between browsers:
if browsers don’t deal with incorrect mark-up in the same way, they at least mostly agree on how to interpret
correct code. Since XHTML 1.0 Strict has stronger syntax requirements than HTML, it leaves even less room
for misinterpretation.

If browsers don’t deal with incorrect mark-up in the same way, they at least mostly agree on how to
interpret correct code

Structuring, why it throws you


I previously mentioned proper tag ordering: some tags can only contain some other tags, and some tags must
have a specific parent before they can be used. The most obvious case is, for example, that a table row (TR)
must be inside a table (TABLE); and a table cell (TD), inside a table row. Less well-known, the table header
(THEAD) and table footer (TFOOT) must be located before the table body (TBODY).

In the same vein, a table must not be in a paragraph (P), and a division (DIV) can’t be inside a list element
(LI); a list element can only be found inside an ordered list (OL) or bullet list (UL). Validators will pick up on
these, and also on missing attributes: most famously, an image (IMG) must include all of these to be
considered valid:

• src or “source” (that seems obvious)


• height and width (they allow document layout tracing before the image is loaded)
• alt for alternative parameters (for disabled users, text-only browsers, or broken source)

Harder to spot (but some validators, especially accessibility-oriented ones, will help), headings (H1, H2 etc.)
must be properly ordered. This brings us to a point that seems like mere nitpicking, but is actually at the crux
of today’s problems.

38 Structuring, why it throws you


Issue 22
Many web authors seem to have forgotten that HTML isn’t a presentation language: it’s a mark-up language,
used to give sense to elements. But since H3 tags (for example) are usually displayed by browsers as written
in a bigger font and as a block element (meaning, an element that is represented with a carriage return before
and after its content), they sometimes use it to mark big text paragraphs instead of paragraphs containing
styled SPAN or (semantically better) STRONG tags.

Similarly, using tables with 1px-wide images as spacers to center some content on a browser’s window, is not
what HTML is for–and not all browsers will deal with such tricks in the same way! Not to mention the
overhead on download time! Since tables contain lots of mark-up and you need an external element (with an
HTTP request) for this trick to work, it makes pages unnecessarily bloated and, even worse, unreadable to
screen readers.

How should you do it, then?

If you want to change the appearance of a web page, first structure it correctly: use headings to mark heading
levels—and chain them correctly! No H4 right after an H1, use tables to present tabular data, use lists for
enumerations; and DIVs to divide data into significant blocks (content, menu, etc.), instead of table cells.
You’ll use CSS later on to position them.

Now, even though those Strict guidelines seem restrictive, many tags exist that allow you to structure your
page very precisely, and at the same time make it easier and more clear to navigate: heading levels, address
blocks, field sets, table heads and foots linked with table bodies and captions, column groups, option groups,
and so on. Merely using these when appropriate will make your page easier to read–especially with a screen
reader (like Orca), so accessibility benefits from this work (and, incidentally, some search engines enjoy well
structured pages, and give them a slight bonus).

One thing that happens quite often, for example, is using tables to present forms: input on the right column,
input label on the left column. What many web authors seem to forget, is that forms and inputs have a set of
tags that work much better:

• Group inputs with a FIELDSET, which gets labelled with a LEGEND tag
• Dedicate a LABEL to an identified INPUT: this allows better selection, since a click on the label will
select the input (useful with hard to hit check boxes)
• Use lists and sub-lists on those field sets, you can organize them in a tree fashion, making them more
readable. Numbered lists also allow you to keep your hands off said numbering
• With a few CSS tricks, you can also make certain that all inputs remain aligned

With a content generator, a well-structured page is essential. Since all elements are given a place and a level
in a document’s flow, changing any part of the page is reasonably dynamic: content will flow as ordered
without any unpredictable behavior.

However, non-styled tags look a bit dry (think “word processor” dry), so you may want to style these so as to
make your page look nicer–and that’s the role of CSS.

Living in style
Content (or “Cascading”) Style Sheets are the most-used means of giving style to your page, and date back to
Netscape 3, while IE 4 and 5 were off to a very good start with them. Using them makes stuff like FONT tags
or “border” parameters pretty much useless, and bases itself on an elegant method: in a correctly organized
HTML document, the significance of an HTML element should be pretty much self-explanatory, so all you
have to do is say “all paragraphs should be written in a bold, serif font with a 16-point font size” and that’s it.

Still, you may require a bit more control than this.

Paint a target
CSS is based on classes and identifiers. The more precisely you refer to an object, the more likely it will get a
style applied. CSS is case sensitive: steer clear of uppercase letters for minimum trouble (even though IE up to

Living in style 39
Issue 22
7 doesn’t respect case sensitivity at all).

‘Generic’ classes are simply the tag’s name. For example,

p {font-weight:bold}

will write all paragraphs in bold, wherever they are on the document. However,

div p {font-weight:bold}

will only style paragraphs located somewhere in a DIV. Even better,

div > p {font-weight:bold}

will only write paragraphs which are direct children of DIVs in bold. ‘>’ is called a “selector” here.

But, what happens if you want to style both paragraphs and list elements (LI) the same way?

p, li {font-weight:bold}

will do that for you. If (even better) you want to style only some of these, you could also create classes (as
we’ve seen before):

p.fat, li.fat {font-weight:bold}

which will apply only to those P and LI tags that have a class='fat' parameter defined. A shorter way to
write this previous rule would be:

.fat {font-weight:bold}

Finally, if you have given a unique identity to an element on your page (say, a <DIV id='menu'>), you
could also target it directly with:

#menu {font-weight:bold}

Or, if you want to ensure that only DIVs identified as ‘menu’ get the style, you can use:

div#menu {font-weight:bold}

Which can be useful if your pages’ structures are different, and you want to keep the same style sheet across
all your pages.

Now, these are merely examples of how to style text, but CSS allows you to deal with element padding,
borders, colors, decoration, font spacing, margins and positioning, document flow, layer positioning, layer
depth, display media, backgrounds, generated content, and even some basic events.

If you have two conflicting rules (for example, two rules defining a paragraph’s border), the priority is defined
like this:

• The best-identified description gets precedence (p.fat has precedence over .fat)
• On identical identification, the rule written last in the style sheet has precedence (you may get a
warning on CSS validators that a property has been redefined)
• Depending on browser, !important after the rule overcomes the preceding rules

CSS does have some strict rules, coming right from how HTML elements are defined: for example, an in-line
element should not contain a block element, a proportional size is always calculated versus its parents’
dimensions, you shouldn’t have the same color for font and for background. It also has a strict syntax–so, you
should validate it too.

But syntax and design isn’t CSS’ biggest problem: while most modern browsers handle basic CSS (also
known as CSS 1) very well, they all present unique behaviors; may not support a property or all of its options;

40 Paint a target
Issue 22
or may deal with some lack of precision in later CSS specifications (currently 2.0 and 2.1) in a way that
doesn’t agree with another browser’s behavior.

Misfires!
Of all currently supported browsers, Mozilla’s Gecko engine is fairly well regarded (version 1.9, coming with
Firefox 3, improves CSS support in many ways and makes it on par with Presto), Opera’s Presto is pretty
much a reference implementation (although not quite perfect), KHTML/Webkit is very good, W3C’s Amaya
can at least understand advanced CSS without getting too distracted, and as you guessed, IE chokes (though
version 7 does a bit better and version 8 may just work—let’s hope it gets better after its first beta!).

IE can be made to behave with some proprietary syntax and layering bugs one on top of the other:

• IE 5/Win32 has a faulty box model: it doesn’t handle block and in-line elements correctly; it deals
with overflow in a non compliant manner; and it uses incorrect dimensions when dealing with
element width and height. You can however use conditional comments and parsing errors to pass it
settings other browsers won’t see. Quite often, it’s a matter of using one bug to correct another
• IE 5/Mac OS was very good at the time, but it has been discontinued
• IE 6 supports some ‘Strict’ CSS parsing that solves the box-sizing problem. Yet, most problems found
in version 5 remained unfixed, meaning you can still stack bugs to obtain the desired results
• IE 7 deals with the most obvious IE 5/6 bugs and limitations, and adds support for some selectors,
along with some unique bugs, and retains the infamous hasLayout property that makes HTML
objects behave differently from one second to the next
• IE 8 should be a great improvement, though. It currently passes the Acid2 test and supposedly gets rid
of hasLayout. My own tests done on Beta 1 were far from conclusive though: with a design I’m
working on it shows no real support for pseudo-elements, and introduces a bunch of weird positioning
bugs

I won’t make a more complete list of those bugs: ( http://www.positioniseverything.net is a great resource,
and Dean Edward’s IE7 script makes IE 5/6 almost standards-compliant). Even Microsoft has recognized that
its Trident engine sucks eggs when parsing CSS 2.

Validate objective

Image 1: Firefox does find some CSS properties that don’t really seem correct on FSM’s main page…

Firefox’s developer toolbar contains a CSS debugger, but the most complete CSS validator out there is the
W3C’s CSS validator: http://jigsaw.w3.org/css-validator will not only tell you if your code is valid, but also
give you notices on where it is correct but may be troublesome. If sent along with the document to which it
should apply, this validator can also tell you what otherwise correct rules are not valid in the document’s
context. In this case though, you should load the page twice: sometimes the validator misfires on some
elements on first load, but will then read them correctly on the second.

Misfires! 41
Issue 22

Image 2:…but IE seems to think everything is perfect.

Using external style sheets is an excellent way to ensure that your whole web site has a consistent appearance.
Allied with similarly-structured HTML documents, it makes maintaining a complex website with many pages
quite easy, even with only a text editor, and reduces overall download times by reducing page sizes. Indeed,
external CSS files are often well-cached by browsers. Thus integrating style in the page’s content isn’t always
the best solution.

Some browsers are also able to apply different style sheets depending on media, making ‘printer-ready’ or
‘hand-held ready’ versions of your pages redundant (this is done through the media parameter of the STYLE
tag. For example, specifying media='screen' will make the printed page look very dry in Firefox and
Opera). You can also create alternative CSS files, and allow ultimate customization for your user (a ‘large
size’ file for near-sighted people, an elevated contrast one, or just different looks).

CSS can also be used to present users with simple behaviors: small pop ups, hover effects, roll-over menus,
pseudo-frames, and so on can be made with some CSS and absolutely no “active” code–making your website
quite safe and perfectly usable with a browser that has JavaScript disabled (and many people, in these days of
Trojans and worms, do disable JavaScript).

Still, if you want to give more user interaction on your web pages, you’ll need to start scripting.

JavaScript, Jscript, and ECMAscript


When I mention web pages scripting, I do mean client-side interaction programming. While a lot of scripting
happens server-side and actually represents the most basic way to create web sites that allow interaction,
client-side scripting is stuff that is run directly in the browser: opening a new window, automatically
correcting a form field’s content, starting complex behaviors depending on user actions or on server events
(think AJAX), showing or hiding page elements depending on mouse or keyboard events, or providing some
page animation. All of this requires some form of client-side programming.

Historically, client-side programming has been done through two methods: integrated applets running in
virtual machines which manipulate the document’s content or direct manipulation of the page’s content by the
browser itself, through the use of a script.

The former method is the category into which Java applets, ActiveX controls, and Flash objects fall. They are
powerful in their own ways, but require virtual machines. Since not everybody has Java or Flash installed,
they are not reliable for a broad audience. ActiveX controls are IE/Win32 only.

The latter method is basically the realm of ECMAscript, also known as JavaScript (all W3C-friendly browsers
use this name) or Jscript/Active Scripting (IE). Luckily, VBscript was put to death some time ago.

The HTML document is your base of operation: while it is perfectly possible to create page elements purely
through scripting, it is often tedious, performance-killing, and much heavier than creating a complete (and
correct) HTML document that you will then modify through scripting. The same thing applies to styling:

42 JavaScript, Jscript, and ECMAscript


Issue 22
creating different classes for the different appearances an element may take and using scripting to switch an
element’s class is faster, lighter, and simpler than rewriting an element’s style through scripting.

Here is an example:

var paragraph = document.getElementById('test');


paragraph.onmouseover = function(){
paragraph.style.font-size = '12px';
paragraph.style.font-weight = 'bold';
paragraph.style.color = 'red'; }
paragraph.onmouseout = function(){
paragraph.style.font-size = '8px';
paragraph.style.font-weight = 'normal';
paragraph.style.color = 'black'; }

This would make a paragraph identified as test become red, bigger, and bolder when the mouse cursor
hovers over it, and return to the original black, slim, and small appearance when the mouse cursor leaves it.

Although it would be perfectly valid to look up test every time you use it (with
document.getElementById('test')), it would be very wasteful—just as if you were to close a book
after each page you’ve read and look for the next page by counting from the beginning of the book.

Even without the redundant lookup (herein avoided through the use of the paragraph variable), though,
you’d still get a rather large CPU spike, and (on slower machines) some display lag caused by several direct
DOM manipulations.

Or, you could create two CSS classes:

.bigred {font: 12px bold; color: red}


.normal {font: 8px normal; color: black}

and have these lines of script to switch them:

var paragraph = document.getElementById('test');


paragraph.onmouseover = function(){paragraph.className = 'bigred';}
paragraph.onmouseout = function(){this.className = 'normal';}

This would behave identically to the first example, but use radically less CPU time (around 75% less!) and
take effect without delay. Also, in case the user has disabled the use of CSS, you don’t need to disable the
JavaScript part to prevent strange happenings: it will merely switch a class that does nothing to a class that
also does nothing.

You may notice that I used the this keyword for the second option; I could have used it for the first too, and
saved a few bytes.

Note that, for this particular example, no JavaScript is actually needed, as CSS knows a few events like
hover, select and visited. Indeed, you could declare your CSS like this:

#test {font: 8px normal; color: black}


#test:hover {font: 12px bold; color: red}

However, this approach wouldn’t work with IE 6 or lower without the use of some glue if #test isn’t a
link with an href parameter. You may want to, for example, add or remove some text from #test or use a
different event, which CSS doesn’t cover.

This works in most situations, and even in the rare case where you want to specify your CSS through
JavaScript (because said style is dynamically generated, for example), the first situation is still valid when you
modify only one style property. However, if you have to set up two or more, another method is preferred:

paragraph.onmouseover = function(){
paragraph.setAttribute('style','
font: 12px bold;
color: red');}

JavaScript, Jscript, and ECMAscript 43


Issue 22
paragraph.onmouseout = function(){
paragraph.setAttribute('style','
font: 8px normal;
color: black');}

This is the W3C-friendly method. While IE doesn’t throw an error, it doesn’t apply styles when set this way.
However, a proprietary property (which doesn’t disturb other browsers) is object.style.cssText (this is, if you
want, the CSS equivalent of innerHTML). As you may guess, it works the same way:

paragraph.onmouseover = function(){
paragraph.style.cssText='
font: 12px bold;
color: red';}
paragraph.onmouseout = function(){
paragraph.style.cssText='
font: 8px normal;
color: black';}

With these methods you can thus specify inline-level CSS styles with a single DOM operation, achieving the
same effect as lengthy direct DOM modifications.

To recap on HTML and CSS correct use and validity: if your HTML is correct, you will have less trouble with
different Document Object Model interpretations from one browser to another (IE’s unique ability to graft
DOM tree branches back onto badly nested tags has created enough endless loops as it is). If you have already
created classes and styled them well in CSS, changing the appearance of a page element will require a single
line of script code instead of a long, complex, risky, and CPU-intensive DOM manipulation.

An eventful document
For those of you already familiar with JavaScript, you must have noticed that I used the legacy Netscape event
model in the previous example. It is the best supported of all, with the lowest overhead, and is really easy to
use for simple actions. Basically, you take an object and (after the ‘.’) add on plus the name of an event to it,
and associate a function to this method. Easy, fast, simple. It is, however, a bit limited:

• you can’t associate several functions to the object unless you group them inside another function
• you can’t manage these multiple functions dynamically
• you can only use predefined event listeners
• and even when you use the grouping trick, functions will only start sequentially

More advanced event management, like dynamically associating several actions to the same event listener and
firing them all simultaneously, can be done in two ways:

• W3C’s event model: it expands upon both Netscape’s and IE’s models and uses the addEventListener
method to add one or several actions to different events happening to an object. It detects events on
both capturing and bubbling phases
• Microsoft’s event model: it relies on a proprietary property to the window object, called
window.event, to capture events happening to the page. Its structure is similar to the W3C’s method
(which was created before), but it detects events on the window’s level, not the targeted object’s,
making it effective only on bubbling phases (very annoying when you want to keep an event active on
an element that contains other elements, or for detecting the event’s origin).

What’s “bubbling” and “capturing”? Simply put, when your mouse hovers over an element, it also hovers
over its parent.

Capturing means that the browser takes the event through all children’s ancestors up to the window level (if
an element handles the event, it can “capture” the event and prevent it from going higher up the DOM).

Bubbling happens when an event starts from an object (either from having gotten up to the window object in
capturing phase) and goes down through all its children. For a very complete explanation, look at
http://www.quirksmode.org/js/events_order.html and http://www.quirksmode.org/js/events_advanced.html.

44 An eventful document
Issue 22
Opera supports both models, as does KHTML/Webkit. Gecko supports only W3C’s, and IE supports only its
own.

The biggest problem with IE’s method is when you want the event to trigger a function to be run on the object
(such as making a button blink when the mouse hovers over it). Let’s look at some pseudo code:

ON myButton WHEN mouseover DO paintItRed

where myButton is the object, mouseover is the event, paintItRed the function. Some CSS first:

isRed {color: #F00} /* don't you love those shortened hexadecimal color values? */

The legacy model would put it this way:

function paintItRed(){this.className = 'red'; }


myButton.onmouseover = paintItRed;

The W3C model would put it this way (previous function remains identical):

myButton.addEventListener('mouseover', paintItRed, false);

And IE would need it to be written this way (and also the function will need to be changed):

function paintItRedIE(){window.event.target.className = 'red'; }


myButton.attachEvent('onmouseover', paintItRedIE);

This is a simple example. For bigger functions, having to duplicate them all is a Bad Idea (TM). In practice,
people wanting to use the advanced methods create a ‘wrapper’ function that detects the model in use,
switches to a code path depending on the situation, and passes the target object as a parameter to the function.
They then call the wrapper function on the object every time they want to attach an event listener to it.

However, using this method makes removing event handlers tricky.

Scripts and variants


JavaScript was first created as a cooperation between Netscape and Sun, to make a browser interact better
with a Java applet. It then took on a life of its own. Very soon, several browser vendors started creating
half-compatible versions of JavaScript, and in an effort to unify these, the ECMAscript norm was
created–with version 3 finalized in 1999.

Version 4 is still being reviewed. With IE having frozen the browser landscape for five years when Netscape
went belly up, there was less incentive to keep improving it. Now however, AJAX is pushing the limits of
ECMAscript 3, and older engines have started to have trouble with it:

• Mozilla’s JavaScript engine used to leak memory a lot. Things have gotten much better with later
revisions though, and its DOM engine is the most compliant of all. It has the best JavaScript
debuggers out there, and it’s fast, but it doesn’t implement many of IE’s proprietary elements
• Adobe currently uses two Javascript Virtual Machines (JSVM): KDE’s Kscript (in Safari) and
ActionScript (in Flash). The latter is now in Mozilla’s custody, so we’ll see consolidation in free
JavaScript engines
• Opera’s version is (arguably) a bit slower than Mozilla’s, and slightly less stable. It adds most of IE’s
proprietary DOM elements (like its event model) on top of the W3C’s
• IE’s Jscript engine is mismatched with the browser’s DOM engine, creating orphaned nodes all over
the place. It’s also unstable and limited: its garbage collector requires supervision bordering on
hand-holding, prevents direct memory management, and leaks (see Drip and sIEve)

That’s why passing off as much work as possible to correct HTML and CSS can help: it means less JavaScript
to type–and less Jscript “glue” to nanny IE.

Scripts and variants 45


Issue 22
Performance-wise, the less you directly manipulate the DOM, and instead use existing HTML and CSS
constructs, the faster your web application will get. Joseph Smarr of Plaxo, Inc. does a very good
demonstration in his OSCON 2007 presentation. Manipulating the DOM is so expensive, in fact, that it is
recommended to cache as many DOM manipulations as you can and apply them only when they really are
needed: for example, instead of:

document.write('<p>adding a paragraph!</p>');
document.write('<p>adding another paragraph!</p>');
document.write('<p>adding a last paragraph!</p>');

you’d be better off using:

var domAddition = '<p>adding a paragraph!</p>';


domAddition+='<p>adding another paragraph!</p>';
domAddition+='<p>adding a last paragraph!</p>';
document.write(domAddition);

This is all well and good for making your JavaScript work, but is it enough to make it run well?

Tighten your scripts!


Here comes trouble: while HTML is a mark-up language, and CSS is a styling language, web scripting falls
into the category of programming languages–with typing trouble, variable vindication, and memory madness.

Now, you should simply forget about using IE to debug your script: its debugger is barely able to find out
DOM errors and is simply unable to raise programming problems. Moreover, it is awkward to use, and its
interface is a Windows 95 reject.

Image 3: Developer tool bar (small icons version) and Firebug (bottom) under Firefox 2

Mozilla Firefox is more solid here: the “Web Developer” tool bar gives an easy access to the JavaScript
console (which has helpful error and warning messages), and debuggers like Venkman or Firebug make it
easy to find programming errors and analyze a complete document. They are able to monitor variables and
objects, and use breakpoints.

Opera also comes with valuable debugging tools, but their interface is not as intuitive (“your mileage may
vary”) and add-ons are still considered Alpha quality.

46 Tighten your scripts!


Issue 22

Image 4: Opera’s JavaScript log window

None of these can help you with wrong programming or dumb mistakes (like creating a global variable due to
mistyping).

I like fast–fast is good


Depending on how and where you call objects, you can slow down a script to a crawl!

JavaScript is an interpreted language. As such, any mistake or badly-thought-out construct can have dire
performance implications: depending on how and where you call objects, you can slow down a script to a
crawl! And on the other hand, a single line of code, strategically placed, can make your code run many times
faster. In all, several guidelines often come forward:

• Defining the complete path to an object finds it much faster than merely looking it up by name. For
example, calling “input1” is much slower than calling
document.forms.nameOfForm.input1
• Assigning a variable to an often-used object or property removes the need to look it up
• Local variables are looked up before global ones are. Within functions, declaring your variables as
local boosts the function’s execution time (on top of preventing memory leaks)
• Comparison with zero is faster than comparing with any other number, a nice boost can thus come
from using reverse counters
• Comments are evaluated too, so don’t put comments in areas that are often parsed, like loops

For example, if you have a form named myform and want to go through all of its inputs, logically this is what
you’d do:

for ( i = 0; i < myform.elements.length; i = i+1){


miscellaneousStuff = 15;
myform.elements[i].value = miscellaneousStuff/i; //do some stuff to an element
myform.elements[i].property = other_stuff;
}

Here, you have one useless global: miscellaneousStuff. Its value won’t be freed once the loop is over.
Even worse, it will be reset on every loop. Moreover, you ask the browser to look up your form’s elements
length on every iteration of the loop. And finally, you ask the browser to parse your comment on each and
every loop.

You’d get a faster loop by doing this instead:

var miscellaneousStuff = 15;


var currentInputSet = document. myform.elements;
for(var i = currentInputSet.length-1; i >= 0; i-- ){
var currInput = currentInputSet.i;
currInput.value = miscellaneousStuff/i;
currInput.property = other_stuff;

I like fast–fast is good 47


Issue 22
}
// do some stuff to all elements inside myform

First, the counter: we only look up the length of the form’s elements array once. Then, we compare with zero
(which is faster than comparing with any other integer). Finally, we don’t have to refer to i, then operate on
i, then change i; instead, we directly change i. Please note, however, that you have to shift i’s value range
one rank back if you intend to use it inside the loop: the initial construct started with i=0 and ended at
i=max value, not performing the action for the latter. Thus you have to start one step lower (i=max-1), then
allow the action to proceed one step further (i >=0).

About the comment, an even better location would be inside a PHP, Perl or ASP comment: that way, it
wouldn’t even be downloaded by the client; for example: <?php /* add comment here */ ?>.

Of course, this is possible only if your JavaScript is generated rather than a static file.

I kept the external variable (because it might be used later on). By caching the form data in
currentInputSet, we avoid having to look up every form and then all its elements. Also, we directly
access the object we want to use instead of going through all of its parents.

To make it even better, you could access it all at once, and group all properties and methods assigned to the
object in one go:

currInput = {value: miscellaneousStuff/i, property: other_stuff } ;

but the current solution is generic enough to be readable. Now, it would be nice to find a way to evaluate all
those objects, just to be sure that said unruly globals don’t hang around unattended. And here comes “JSLint”.

Clean up after use

Image 5: JSLint’s main interface and settings.

JSLint is a JavaScript-based JavaScript validator: it will read JavaScript code you submit to it and raise
warnings or errors on constructs that are not in themselves incorrect, but which can lead to unpredictable
behavior:

• incorrect use of carriage returns, spaces, and commas


• potential type mismatches and false positives or false negatives
• awkward or non-optimal syntax
• globals invasion
• dangerous reliance on default settings

How those may impact your scripts isn’t apparent at first, so let’s look deeper.

Incorrect use of carriage returns: JavaScript allows you to end a statement with a comma or a carriage return.
However, the carriage return can sometimes be considered a space. Only the comma unequivocally delimits

48 Clean up after use


Issue 22
statements: JSLint tells you where you should put these.

JavaScript is a typed language that performs automatic type conversions as often as it can; sometimes
though, this automatic conversion may fail

JavaScript is a typed language that performs automatic type conversions as often as it can. Sometimes though,
this automatic conversion may fail.

Incorrect use of comparison operators


• ’=’ means that you associate an element with another, or with a value
• ’==’ means that you compare any two elements’ values
• ’===’ means that you evaluate two same-typed elements’ values

Obviously, the last will return false whenever the two compared elements are of a different type. While 1 ==
'1' is true, 1 == 'two' is too (the first is a number, while the second is a non-null character string,
automatically converted to ‘true’ which is worth 1). The expression 1 === 'one' would fail, and so would
1 === '1', but 1 === 1 would be true.

Because of the previous point, you will have to explicitly convert types; parseInt and parseFloat
would then be used quite often, allowing you to do stuff like 1 === parseInt('1') with success.

It’s good, because it helps prevent any goofy result you’d get when comparing variables and inputs in a
domain you don’t always control. It’s also bad, because it requires some extra code, yet your code would be
much more robust. But then, JSLint would complain that you didn’t include the radix. Huh?

Simply put, numbers can be represented differently on a computer: you have “human” base ten (0 to 9), but
also hexadecimal (0 to F) and binary (0 to 1).

Now, what happens when you do parseInt('015')? It will consider the leading 0 as an indication that
you’re going hexadecimal, and instead of a base-10 value “15”, you’d get a base-16 value worth “15”, which,
in base-10 is 21.

The radix is the optional parameter for parseInt that gives it its basis: correct use of parseInt would
thus be parseInt('015',10) which would be 15. One thing you can do, is create a small function that
takes care of the radix: say,

function getDec(val){return parseInt(val,10);}

and use this instead of parseInt. Now, not everything is perfect, and you will get a performance impact. I
iterated all three solutions 30,000 times on a string starting with a non-zero digit, marking start and stop time
on all four browsers, then ran them a dozen times and noted average results:

• with no radix, Firefox takes the lead; Opera and Konqueror are 10% slower. IE 7 trails a further 20%
behind
• specifying the radix makes Firefox “as slow as” Opera and Konqueror. IE 7 stays slow
• Using the wraparound function adds a 40-50% overhead to Firefox and Opera, and more than doubles
the execution time on IE and Konqueror.

Overall, just specifying the radix has the least impact for the safest approach; use the function only if you are
very space-constrained.

Regular expressions
JSLint can check regular expressions (RegExp) and prompt you for non-escaped characters. While it can’t
second-guess you, it can detect when special characters are in a context where they must be used literally, thus
they should be escaped.

Incorrect use of comparison operators 49


Issue 22
Some more tips can be given by JSLint, such as not using Perl/PHP-like collection['identifier']
syntax, but collection.identifier instead (Gecko’s debugger also hints that it converts the former
into the latter on execute, you may want to save it the trouble). This is not absolutely required, but this
particular example shows how one can complicate one’s life and code for nothing.

Globals
Finally, JSLint will count all global objects used in your script. Using an object before it is declared is bad, as
it requires the whole script to be parsed before being interpreted. Declaring a function before using it has it
interpreted first, then called and executed (instead of having it called and then interpreted and executed):
interpreting adds some lag that can be noticed by the user.

What is absolutely frowned upon though, is using a variable without declaring it first: you need to create it
with the var keyword, and then use it. The location of the var keyword defines its scope.

Unfortunately, not using var will make the variable completely global. In a main loop, it’s not too much of a
problem, but calling it inside a function will make it keep its value across runs of the function. If the variable
were a counter, things could go very bad, very fast.

In terms of performance, globals are not good either: most garbage collectors have trouble dealing with them.
Abusing globals may thus create memory leaks all over the place.

For that matter, although the consequences are less dire, using a function before declaring it is bad: JSLint will
report it, and the solution is very simple: make it a habit to put all your global variables at the top of your
JavaScript, then declare all your functions, then start your main program loop.

You know, like when you program Pascal or C.

Personally, I found that the harrowing work of tightening my code yielded good results

It is very discouraging to read “too many errors–parsing stopped at 4%” the first time you feed JSLint your
otherwise perfectly running code. Personally though, I found that the harrowing work of tightening my code
yielded good results:

• it made me spot potential and real bugs


• it helped me make it more simple and slightly boosted its execution speed
• increased stability prompted me into adding a few features I didn’t feel confident about adding before
• tighter type checks helped me remove some other clumsy manual checks I had to do

On something as slow as interpreted code, code clean-up really helps. If you’re worried about your code size,
just tell yourself that an extra 10% line length may save you some full lines later on, won’t alter code
compressibility (for gzip encoding) and will give your code up to a 50% boost on execution. Moreover, since
the most basic syntax is the one most browsers agree upon, keeping it simple will strongly reduce the time
you’ll spend debugging this or that browser.

Conclusion
Making your web code extremely strict and tight is not a waste of time. On the contrary, making it high-grade
will allow you to cut debugging time to a minimum and reduce testing and compatibility-gluing a great deal.
It will also provide basic optimizations and reduce the need for redundant checks.

Moreover, maintaining this code becomes a real pleasure: adding a new page, revamping menus, improving
appearance, or adding functionalities becomes so easy (provided you stick to those resolutions) that you won’t
hesitate any more to add stuff just for the fun of seeing it work perfectly on the first (OK, maybe second) try.

50 Conclusion
Issue 22

Bibliography
http://www.quirksmode.org/js/events_advanced.html is a complete overview of event models.

http://www.positioniseverything.net describes advanced CSS techniques, and several hacks and techniques
one can use to make IE 5/6 behave.

http://blogs.msdn.com/ie/archive/2007/12/19/internet-explorer-8-and-acid2-a-milestone.aspx report on an
internal build passing the Acid2 test.

http://home.earthlink.net/~kendrasg/info/js_opt provides some more advanced programming tricks geared


towards improving JavaScript performance.

http://www.miislita.com/searchito/javascript-optimization.html contains several other, much more common,


performance tricks.

Biography
Mitch Meyran (/user/17379" title="View user profile.): Mitch is a professional computer abuser. He started on
this peculiar kink when he got a 8088-based PC, and soon found out that tinkering with computers is almost
as fun as using them - provided the OS lets you do it.

Copyright information
Code samples included in the article, due to their simplicity and very nature, can be copied without need for
any credits, under the terms of any license you may prefer, such as (but not limited to) GPL, LGPL, MPL,
Apache or BSD.

Source URL:
http://www.freesoftwaremagazine.com/articles/create_web_pages_the_right_way

Bibliography 51
Issue 22

52 Bibliography
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Hotwire: a combined terminal/GUI for GNU/Linux
A suitable peacemaker between command-line purists and
pragmatists?
By Gary Richmond
PUBLISHED: 2008-06-24

There is nothing more guaranteed to ignite a bad tempered, incandescent flame war that an outbreak of
hostilities between the rival Gnome and KDE camps. Well, except perhaps a slanging match between the
champions of the GUI and the command line. Enter stage left the compromise candidate which might just
unite the warring factions: Hotwire.

Whenever I first stumbled across upon Hotwire (released under the GPL 2 for the user interface and a
permissive MIT-style licence for everything else), certain childhood rhymes sprang irresistibly to mind: Jack
of all trades, master of none, Jack Spratt could eat no fat, his wife could eat no lean, amongst them. The
problem is actually trying to give a pithy and accurate definition of Hotwire without tripping up yourself, so
who better to describe it than its developer, Colin Walters of Red Hat, who has described Hotwire as “an
object oriented hypershell” and “a modern Python-based extensible crossplatform shell environment”.
Walters’ inspirational cue was the less powerful Windows Powershell and to make Hotwire a better, rich
visual interface without recourse to yet another new scripting language. It leverages Python.

Now, you are probably thinking that GNU/Linux needs another shell about as much as it needs another patent
trolling predator, but you just might be wrong because what Hotwire tries to do is to unify the GUI and CLI in
one powerful, unique and productive application which gives the user, both novice and advanced, the best of
both worlds. It does this by using Python and GTK to render an interface which has familiar elements of a
GUI but with the granular power of the command line.

Get it. Install it


The target platform of Hotwire is primarily GNU/Linux and Gnome but it will run happily on KDE too. The
major dependencies are Python version 2, Sqlite3 and Python Gnome VFS bindings; so, you will either need
to upgrade to those versions either via your distro’s package manager or upgrade your distro to the next
version which does support it. I installed Hotwire on Ubuntu 7.10 with no complaints about dependencies. If
installation throws up any missing dependency messages then simply install them from your comfort of your
package manager. As of the time of writing, version 0.700 seems to be out and it offers more bug fixes and
improved features (version 0.700 once again will support Python 2.4). For a list, see the the Hotwire
changelog.

Although Hotwire is described as alpha software, it is very stable and I was unable to crash or freeze it. The
only sense it will it can be described as alpha software is that, as even its creator admits, it does not yet match
the full feature set of Bash - but it is about eighty per cent of the way there and every update should be inch
ever nearer to feature parity.

Binaries or source?
Despite being described as alpha software Hotwire is already available in binary form for a number of distros:

Binaries or source? 53
Issue 22
Fedora 8, OpenSuse, Debian, Ubuntu, Mandriva, Archlinux and Gentoo. You can get them here. Just follow
the links. (Followers of PClinuxOS can install from the repositories but the version is 0.44 which is rather out
of date.) Binary is best for ease of installation and removal, as well as installing Hotwire in the Start menu,
with the option to create a desktop shortcut. A Debian binary for Ubuntu (version 0.620) is available at the
Getdeb website. Debian packages are also available for download at Linux App Finder. If you cannot get an
RPM for your distro you might get some mileage using Alien to convert the Debian package.

If you are having problems with locating a binary for your distribution the solution is simply to download the
source code from the above link. The version to look for is 0.620. Download to the directory of choice and
extract it. Cd to where you extracted it and run the following in a console: python ui/hotwire & (and
you could always set up an alias for this to reduce typing). The ampersand is optional—I added it to run
Hotwire in the background and free up the terminal for other tasks. That’s it. Extract and run the Python
script. No ./configure, make and make install and if you decide you don’t like it, uninstalling is
as simple as deleting the extracted folder. For binary installs, removal is either by the GUI of the package
manager or apt-get remove hotwire.

First run
When you run Hotwire for the first time the default screen opens with some helpful information:

Figure 1: Hotwire default screen

It doesn’t look like any terminal/console you’ve ever seen before but you’ll soon feel right at home as soon as
you type something in the box at the bottom of the screen. Let’s have a look at the contents of etc. Just type
cd /etc and hit the return key. You’re in for your first pleasant surprise. Normally, that command will
simply change your directory and if you want to see the contents you would have to follow it up with ls (and
any additional arguments). With Hotwire you have killed two birds with one stone. The cd command not only
changed directory, it also automatically listed the contents of etc —and what’s more listed them just as you
would expect in a conventional file manager complete with icons (in this case, Ubuntu defaults):

54 First run
Issue 22
Figure 2: The results of cd etc lists the contents

You might be thinking that what you see here means that Hotwire is based on XML but in fact it based on
“objects”. In a thoughtful touch for the beginner, Hotwire helpfully arranges titles for the command output by
categories like owners, permissions and size etc. Some of this is also available in a console but in a less
transparent fashion and with less information. Like a file manager, right clicking on a file will pop up a
contextual menu for viewing or editing. The nearest I have seen to this is when Konqueror is in file-manager
mode and showing a horizontally-split screen with a terminal emulator. However, there the resemblance
breaks down because while cd in the terminal follows what you click on in the main Konqueror screen (albeit
an excellent way to navigate around the the GNU/Linux file system if you hate typing and can’t always
remember the exact nomenclature of the commands) it doesn’t work the other way around.

Command history
“Conventional” consoles running in X Windows have the ability to remember the last five hundred commands
(see my article on getting the most out of the history command). Hotwire too can remember commands and
does so via an SQL database. Unlike the usual culprits, it is not necessary to actually issue the history
command. As you can see from the screenshot above the commands history is highly available and can be
reprised by either selecting one from the top of the screen or by scrolling through them from the menu at the
bottom. Nice, but there’s more. In the View drop-down menu, if you select Overview you will see a complete
list of all the commands you have use in the current session and each one represents a kind of hyperlink to that
command:

Figure 3: Overview screen listing command history

That’s a useful feature, saving the need to remember a command or constantly type history or put the up
arrow key into overdrive.

Other features
Other commands and search
The aim of Hotwire, amongst other things, is to obtain feature parity with Bash and to that end its widespread
adoption will necessitate the inclusion of the mainstream Bash command set. Most familiar and
frequently-used commands are currently supported and the best way to find out what works is simply to try
them out in Hotwire. You will not be disappointed if you type any of the following traditional Unix
workhorses: man (but in a separate tabbed terminal), cp, mv, mkdir, grep. The indispensably useful pipe
command (|) now works and rm in hotwire is reversible with the undo command from the drop-down menu,
presumably because files are “removed” to Trash (but without options, and only works in the files/directories
area where the rm command was issued in the first instance). Hotwire does not discriminate between
removing directories and files and therefore the use of the recursive -r is superfluous. A nice touch. Another
nice touch is when you are using the virtual file system proc. Any item in the output can be right-clicked to
kill it.

Other features 55
Issue 22
Devotees of the command line will be pleased to note that this utility supports Unix-like globbing. For
example, ls *.jpg will output the same content as it would in Bash. Anyone who has encountered a piece
of unrecognized hardware will have had recourse to dmesg and piping the output through grep to find
specific information on that hardware. Hotwire deals with that too.

Run dmesg to get the output of the Kernel ring buffer and then hit Ctrl+S and Hotwire will pop up a search
box at the bottom of the screen to allow you search the output of dmesg. This is Hotwire’s Filter feature
which does what grep does in a conventional console/terminal (including being case sensitive of course).
Just click on the X or hit the escape key to close the search box. The search feature does not work when you
deploy it against the output of a command that renders “iconified”, graphical directories in the main “canvas”
(display) of Hotwire. You wouldn’t tarry long in Hotwire if it increased your workload, so you will be pleased
to know that it supports the equivalent of auto-completion which is a real time saver. Those who like to work
remotely via the shell have not been forgotten either. Hotwire also includes an SSH terminal application,
hotwire-ssh, which allows the user to connect and work over a remote connection using the SSH protocol.

Term, Xterm and multiple tabs


If you find that any of your favourite commands don’t work, the good news is that the designer has thought of
that too. Want to launch a conventional console to get at those powerful commands? Simple. From within
Hotwire type term and a console will open, ready for your input. However, you will now find yourself back
in the familiar console territory, because when you cd to another directory, say etc, this is what you get:

Figure 4: Term opens a tab in Hotwire

and you will only see the contents of that directory once you have issued the ls command. Compare this to
the output when changing directory in the main Hotwire screen with cd /etc (Figure 2 above). If you want
to work as root for any reason, Hotwire will accommodate you there too. Issuing su (or sudo for Ubuntu
users) will open an interactive tab and allow you to work as root once you have entered your password. If you
prefer a free-standing conventional console, type xterm and you are in familiar territory (because Hotwire
supports embedded VTE, Virtual Terminal Emulator) and if you want to launch an application from Hotwire,
follow xterm with the name of the application. You don’t need to place an ampersand after this if you want
to free up the Hotwire dialogue box and run the application in the background because Hotwire commands are
asynchronous and run in the background by default.

Conclusion
You could use Hotwire as a shoe in or replacement for your default shell, but it does not support shell
scripting. This is no great handicap as you can write Python scripts instead (py will execute those scripts).
This means that Hotwire is extensible and customizable as its designer intended it should be.

However, Hotwire can be used “as is” and it still represents a very stable and usable piece of kit—especially
as the latest version is still an alpha release. Walters has described Hotwire, amongst other things, as being for
both beginners and advanced users. The latter have a head start of course but the beginner has the neophyte’s

56 Conclusion
Issue 22
delight in experiencing a very graphic display (no pun intended) of the relationship between the text they type
in and its graphical counterpart. It is still very much a work in progress and when it reaches feature parity with
Bash I would fully expect to see it make it into the repositories of all the main GNU/Linux distros. So, Get it,
install it, try it and add a fun and useful tool to the GNU/Linux armoury. You don’t have to abandon the
default shell. It’s not an “either or” choice and it is certainly better than a “demo toy” as it creator once
described it. You can use them both. It might offend command-line hardcore purists and disappoint some
Python enthusiasts but you should Hotwire your distro for a quick get away. You won’t regret it.

Biography
Gary Richmond (/user/3653" title="View user profile.):

An aspiring wanabee--geek whose background is a B.A.(hons) and an M.Phil in seventeenth-century English,


twenty five years in local government and recently semi-retired to enjoy my ill-gotten gains.

Copyright information
Source URL:
http://www.freesoftwaremagazine.com/articles/hotwire_a_combined_terminal_GUI_for_GNU_Linux

Conclusion 57
Issue 22

58 Conclusion
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Mail merge in OpenOffice.org
Making a complicated topic understandable
By Michael Crider
PUBLISHED: 2008-06-17

The office where I am network administrator switched most users to OpenOffice.org (OOo) back at version
1.1, and has followed the upgrade process to the current version 2.3 (a few poor users who have to exchange
documents outside the office with high fidelity are still clinging to their MS Office 97). Our receptionist does
a lot of general secretarial duties, including lots of letters, envelopes, and labels that involve mail merge.
Since this seems to be a sticking point for many people, I am putting everything I have learned from helping
her and have gleaned from various sources on the Internet together in this tutorial.

Mail merge overview


In OOo there are lots of different ways to do mail merge. It took some trial-and-error to find the best methods
for us, and that is what I will be describing here. The first choice to make is database format. Our receptionist
had always used Excel spreadsheets as data sources for MS Word, so we first tried using OOo’s Calc
spreadsheets. It turns out that this choice leads to several limitations. For example, if you find a mistake in
your data while you are doing the mail merge, you must return to the spreadsheet to fix the mistake, then
completely close OOo and open it again before continuing the merge. Also, each spreadsheet must be set up
as a new data source. I then ran across a suggestion to use dBASE files, which have been the perfect solution.

We found the dBASE file format to be the perfect solution for everyday mail merge tasks

We also made the decision to avoid the normal mail merge tools provided in OOo 1.1, which evolved into the
Mail Merge Wizard in 2.x. While the wizard may be good for limited cases, it does not handle the variety of
mail merge tasks we needed. It is actually fairly simple to go through the steps manually once you get used to
them.

Creating data sources


The first step in preparing for any mail merge task is to set up your data source. If you will be doing a lot of
mail merge with a lot of data sources, it is appropriate to plan ahead how your files will be laid out. Our
receptionist has a directory for each department. When using dBASE files as your data source, you only need
to set up one data source for each directory (as will be explained later), and can add and remove files as
needed. If you are working with existing data, you can probably convert it by opening it in Calc and saving it
as a dBASE file. This works for spreadsheets, comma-delimited (CSV) files, and any other filetype that Calc
will open. In the first row of the file, specify field names. A limitation of dBASE files is that field names can
only be ten characters—Calc will shorten whatever you put in to this length. You may also wish to specify the
field type and length. Character fields may be specified as “FIELDNAME,C,10”, and dates may be specified
as “FIELDNAME,D”, while numeric fields may be specified as “FIELDNAME,N,4,2”. On numeric fields,
the first number is the length allowed before the decimal, and the second number is the number of digits
stored after the decimal. If you do not specify these, Calc will determine the proper values based on the data in
the column. I recommend that you specify zip codes especially, either as character or as number with no digits
after the decimal, so you won’t receive any surprises when you merge. When you save the file, Calc will ask
you to choose a character set. The default “Western Europe (DOS/OS2-850/International)” has always worked

Creating data sources 59


Issue 22
for us.

After you have one or more dBASE files, it is time to set up your data source. From any OOo application,
click on File→New→Database. You will be taken to the Database Wizard. On the first screen, select “Connect
to an existing database”, and choose dBASE as the type. On the next screen, either click on Browse and locate
the directory where you stored your dBASE files, or type in the full path of the directory. Again I emphasize,
you only point to the directory, not to an individual dBASE file. If you use the file browser, click OK when
you are in the directory with the dBASE file(s). On the final screen of the wizard, leave the default to register
the database, but probably turn off “Open the database for editing”. When you click Finish, you will be
presented a Save dialog. I refer to the file saved here as a database connection—it contains only the
information for OOo to access the data, not the data itself. Give it an appropriate name and save it wherever
you wish. I prefer to designate a single directory for all of these files.

OOo database connections point to a directory of dBASE files, not an individual file

You can verify that the data source is set up properly by opening either Writer (the word processor) or Calc,
then selecting View→Data Sources (or pressing F4). The document portion of your window will split
vertically. You will see a list of your data sources on the left side of the top area (see figure 1). If you click on
the + next to the name of your new data source, and on the + next to Tables, and on the name of the dBASE
file, you will see your data on the right side. From this view you can edit the data, as well as add and delete
records.

Figure 1: viewing data sources in OOo

Using mail merge for letters


Now it is time to put the data to use. Open Writer and start your form letter. You may either type your entire
letter first and then add the fields to be merged, or you may add the fields as you go. There are (at least) two
ways to add fields. Using View→Data Sources, you may click on a column header (field name) and drag it to
the letter in the spot where you want the field. Our receptionist did not care for this approach because she did
not have as much control over where the field ended up, could not view as much of the letter at a time with the
data view at the top, and had no control over formatting of numbers, dates, etc. The other method is to place
your cursor where you want the field, and go to Insert→Fields→Other…, which opens the Fields dialog box
(see figure 2). Go to the Database tab, and click on “Mail merge fields” on the left, then open up your table on
the right and select the desired field. If any special formatting needs to be applied, use
Format→User-defined→Additional formats… (if necessary) at the bottom.

This opens the Number Format dialog used for formatting cells in Calc. For example, you can force a numeric
field to appear as currency, with two digits after the decimal and the appropriate currency symbol in front. No
formatting is available for character fields. After you have the formatting set appropriately, click on Insert,
then click on Close (or move your cursor and repeat with the next field). If you do not need to format a
particular field, you may double-click the field name instead of selecting it and clicking on Insert. At this
point you will see a tag inserted in your letter, with the field name inside brackets on a grey background (some
settings can cause the tag to appear differently). You can apply font formatting to this tag just like any other

60 Using mail merge for letters


Issue 22
character.

Figure 2: adding mail merge fields to a letter

One important question is often asked: How do I get rid of the blank lines caused by empty fields? I have
found several answers, but will only describe the method we use. As an aside, this is one area where OOo
could learn from MS Office (at least 97 has an easier method). Anyway, the key is to tell OOo to make the
line a hidden paragraph if the field is empty. Place your cursor before the tag, and go back to
Insert→Fields→Other… (see figure 3). Go to the Functions tab, and select Hidden Paragraph. On Condition,
type NOT followed by the field name (in my example screenshot: “NOT ORGANIZATI”). Click on Insert,
then Close. At this point the line will disappear unless you have marked View→Hidden Paragraphs.

Figure 3: hiding blank lines

If you think your data might have an effect on the pagination of your document, and want to check it before
you print, return to View→Data Sources. Click on the empty box to the left of a record you want to check,
highlighting that record. Find an icon in the toolbar immediately above the data with the tooltip label “Data to
Fields”, and click on it. The appearance of the icon can vary depending on what build of OOo you are using.
In figure 1, it is the second icon after the last divider (these screenshots are from OOo 2.3.0 in Ubuntu 7.10).
You may repeat this with other records, but only one record at a time can be applied (this isn’t so important on
letters, but can become an issue on labels). This method can also be used to ensure that data will be formatted
properly.

Use “Data to Fields” to check pagination and data formatting

When you are ready to merge the data, proceed as if you were printing the letter. A question will appear:
“Your document contains address database fields. Do you want to print a form letter?” Answer Yes, and the
Mail Merge dialog will appear (see figure 4). Under Records, you may choose to print all records, a range of
records by number, or records you have selected in the top part of the dialog. Again, records are selected by
clicking on the box to the left of the record. You may use shift-click to select single additional records or
control-click to select a range of records (just like selection in most GUI lists these days). Under Output you

Using mail merge for letters 61


Issue 22
may choose between sending your merged letters to a printer or to a File. If you choose Printer, clicking OK
will send you to a standard print dialog. If you choose File in version 2.3, you will then need to choose
between saving as a single document (in ODF format), or in individual documents with a naming convention
you specify (older versions do not have the single document option).

Figure 4: doing the mail merge

Using mail merge for envelopes


Depending on what printer you use with OOo, envelopes are probably the most complicated type of document
to get right. Start a new envelope in Writer by going to Insert→Envelope…, opening the Envelope dialog (see
figure 5). On the initial Envelope tab, you may lay out the Sender and Addressee portions of the envelope.
Fields are added at the cursor by specifying the database, table and field in the dropdowns, then clicking on
the black left arrow. You may turn off the Sender block if you are using envelopes with pre-printed return
addresses. On the Format tab, specify the envelope size you will be using under Size→Format. Most envelopes
I have worked with do not need any other changes on that tab. On the printer tab, it is important to tell OOo
the envelope orientation for your printer. I have never seen any difference in the top and bottom
settings—YMMV. If the current printer is correct, you may click on New Doc. Rarely if ever will you want to
Insert, which will add the envelope as a page to your current document and greatly complicate printing.

Figure 5: setting up envelopes

As an aside, how do you remove an envelope that has been added to a document? This is a common question
for people first getting used to OOo. The quickest fix is to change the page style from Envelope to Default (or
whatever page style the rest of your document uses). This can be done using the “Styles and Formatting”
dialog (opened with Format→Styles and Formatting or F11) or by right-clicking on the page style in the status
bar. Then the Addressee and Sender blocks can be cut and the blank page can be removed with a single press
of the Delete key. Undo will also remove an envelope if no further changes have been made to the document.

62 Using mail merge for envelopes


Issue 22
I have seen three common “gotchas” with envelopes. The most confusion I have seen with envelopes is from
people using printers that feed envelopes in the center. OOo handles this by creating a custom page size that
will reach from the proper location for the bottom of the envelope to the right edge of the printer, with a
margin that restricts text to the printable region of the envelope. Numerous times I have found people
attempting to change the page size to an actual envelope, and it doesn’t print correctly. In most cases, it is
important to leave the page settings alone. The second problem is that some printers don’t print the envelope
on the area where OOo intends. Most of the time you can return to the Envelope dialog and add a “shift right”
value on the Printer tab to correct this. If you must do this, click on Modify to change the envelope you are
working with, rather than create a new one. I also recommend that if you have a printer that needs
non-standard settings for envelopes, save a blank envelope and use it as a template for future envelopes. The
third problem is that, for some reason, the Envelope dialog uses line breaks instead of paragraph breaks,
which can be seen if you mark View→Nonprinting Characters. This is also true of the Labels dialog below. I
have not investigated why, although I am sure there is a very good explanation tucked away in a bug report.
What this means is that the trick for hiding blank lines given above will hide the entire address. If you need to
hide blank lines on envelopes or labels, the quickest fix is to place your cursor at the end of the line, then press
Enter followed by Delete. This will replace the line break with a standard paragraph break.

If your printer feeds envelopes in the center, the page format will appear wrong—it is not

Once the envelope is laid out, merging works just like for letters.

Using mail merge for labels


Sometimes instead of printing envelopes directly, you want to print on labels and put them on envelopes.
Even when printing envelopes, our receptionist likes to keep a sheet of “labels” printed on plain paper for
each mailing, as a record of who received the mailing. Go to File→New→Labels to open the Labels dialog (see
figure 6). Lay out the fields as you did in the Envelope dialog, and choose the appropriate labels under
Format. Since Avery is a de facto standard in label formats, whatever brand of labels you use will probably
provide an equivalent Avery number. If you do not know the number, you can browse through the list until
you find one with dimensions that match the labels you are using. It is important to note that where the
dimensions are shown, the first pair of numbers are the physical dimension of each label, and the second pair
in parenthesis gives the number of labels across and down on the sheet. In the screenshot example, Avery
5160 has 3 labels across each sheet and 10 down, for a total of 30 on the sheet, with each label measuring
2.63” x 1”. If you find a format that matches your labels, you will not need to visit the Format tab. If you need
to use it for an odd format, it is self-explanatory. On the Options tab, you will want to mark “Synchronize
contents”. You will see why shortly. You can also specify what printer you will be using on the Format tab.
When you are finished, click on “New Document”.

Figure 6: setting up labels

Other than the problem with line breaks mentioned in the previous section, the biggest problem I have seen
with labels is that there is no way to scroll within a label if the text is longer than will show on a single label.
This can be a problem if you have a lot of fields. The only solution I have found is to select the entire label
(Edit→Select All or Ctrl+A), change the font to a smaller size, do your editing, then set the font back to the

Using mail merge for labels 63


Issue 22
desired size.

Line breaks from the Envelope and Label dialogs can lead to hidden addresses instead of hidden blank
lines

If you choose to start with a blank label template and insert fields as I showed you with letters, or if you are
just curious, you might wonder how to make a different record show up on each label. Place your cursor at the
end of the label, go to Insert→Fields→Other, and go to the Database tab. Click on Next record on the left, and
the table name on the right. Click on Insert, then Close.

By now you have probably noticed a little window floating over your main window, with a single button
“Synchronize Labels”. If you make any changes to the labels after you finish the Labels dialog, you can make
your changes on the first label only, then click on the button. This will update all other labels to match the first
label.

Once the labels are laid out, merging works just like for letters and envelopes. I would highly recommend
printing a page on plain paper first and make sure the labels line up. If they don’t, you may need to use the
Format tab in the Labels dialog to make everything fit. One of the biggest problems I have found with OOo is
that you cannot modify an existing sheet of labels—you have to start over with the Label dialog and create a
new document. If anyone knows a better solution, please add it to the comments.

Conclusion
Hopefully this answers many questions about mail merge in OOo, and makes it simpler to understand the
basic steps. As I stated in another article on mailmerge recently, once you understand the basics of mail
merge, you will find yourself applying it in other totally unrelated projects.

Finally let me say, for any IT person who supports OpenOffice.org users, anything written by Solveig
Haugland is required reading. She has helped me overcome numerous hurdles, especially in early versions of
OOo that required workarounds to get normal work done.

Biography
Michael Crider (/user/46891" title="View user profile.): Michael Crider has been working with computers
since 1987, and has been using various distros of Linux since 2000. By day he is a programmer and network
administrator for a medium-sized company that runs 90% Linux on its servers and 75% Linux (using thin
clients) on its desktops.

Copyright information
Source URL:
http://www.freesoftwaremagazine.com/articles/mail_merge_openoffice_org

64 Conclusion
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Mobile devices in GNU/Linux and GNOME
Use your hand-held device under GNOME
By Mitch Meyran
PUBLISHED: 2008-06-12

You have a computer (a laptop or a desktop). Since it’s a machine you use often and don’t tinker with much, it
probably runs Ubuntu Linux. Or, maybe, another distribution (like Mandriva 2008). If it doesn’t run
GNU/Linux, I hope you’re at least using BSD. If not, stop reading right now!

You also have a brand new digital camera, or a shiny new MP3 player. And you feel the dread: are those pure
consumer oriented pieces of hardware compatible with my machine? Will I have to pay the Microsoft tax (and
the required hardware upgrades) to get all my photos from my last holidays, or to listen to Beethoven’s fifth
sung a capella by lazy llamas? Read on.

Software requirements
What exactly do you need? If you’re running a recent version of Ubuntu Linux (Feisty Fawn or Gutsy
Gibbon), you’re all set. If you’re not (like me), you’ll need the following:

• Linux Kernel 2.6.22, with HAL and hald running (pretty much standard)
• dbus 1.0.2 (also standard).

No, these are not bad words. Let’s look at what they actually represent.

HAL
HALD (Hardware Abstraction Layer Daemon) reports kernel events; when some pieces of hardware are
connected, it notifies another daemon, udev, which creates a device in /dev. The device creation event is also
picked up by FreeDesktop.org’s dbus, which then follows a set or rules (typically written by the distributor of
your flavour of GNU/Linux, stored into e.g. /etc/dbus-1 as a set of text files). Depending on your device
identification, it will start a set of actions to make it usable.

dbus
dbus usually works with your desktop manager, and is a main component of the Freedesktop.org’s
specifications: as such, GNOME, KDE and Xfce (at least) will usually use it to perform some sort of user
interface actions. One one hand, dbus notifies the window manager that a new device has appeared; dbus will
check with its sets of rules, and start whatever action is set for this action: typically, a webcam creates an icon
on the desktop linked to Ekiga, a CD/DVD disk triggers a file system browse (or if said drive is empty, ask if
you want to burn it), etc.

Let’s look at the matter at hand: both MP3 players (or more accurately, mass-storage based digital players)
and digital cameras have one thing in common: they are ultimately storage devices, and their main use is to
carry or transfer data (the fact that the camera at least can generate its own data is pretty much irrelevant
here).

Software requirements 65
Issue 22
Both MP3 players and digital cameras have one thing in common: they are ultimately storage devices

As such, they will usually broadcast themselves as storage devices: the kernel will pick up on that and,
through hald and udev, load the corresponding drive controller driver (if the drive contains some media, it
will also create the corresponding devices).

Most devices use an USB connection (or, as is the case for the iPod, an alternative IEEE1394/Firewire); what
usually happens then, is that the kernel will:

• load the usb_storage module (if it hasn’t already);


• create a device for the driver (probably /dev/sda if you still have everything in IDE, kick up the
last letter a notch for every SCSI-like drive you have installed if not)
• detect if the drive contains a media—in such case it will create partition devices (like /dev/sda1,
/dev/sda2…): usually one, but some (like the iPod) contain at least two partitions.

One sure way to know is to look at dmesg’s last lines: you’ll see the kernel detect the device, then configure
it. Use dmesg | tail to keep it legible, and that’s it. When these devices appear, dbus picks up on the
kernel event and transmits it to the desktop manager: GNOME will then, by default, ask the system through
dbus to create a mount point in /media, and mount the drive with default settings. Please note that
GNOME relies upon the generic mount command to auto-detect the drive’s settings: you may need to specify
some details, although it is very unlikely: most hand-held media use FAT or FAT32, and these simplistic file
systems don’t have lots of options (it would be another matter if some used, say, NTFS), so mount usually
gets them mounted nice and tight (you may still have trouble with files containing accented characters: look at
vfat’s character encoding mount options if that happens).

For the duration of the device’s connection, its mount settings are stored in /etc/mtab. You’re not
supposed to edit it, it merely reflects what media are mounted, like fstab does for manual mounts.

Some drives may appear directly as “whole”: my iRiver’s storage partition for example, will directly show up
as /dev/sda (and not /dev/sda1), which may make the rest of the system a bit confused if you retain an
older set of dbus rules. Don’t worry, in such cases a manual mount command will work very well:

mount -t vfat /dev/sda /media/iriver

The hardware
Now, I know this isn’t supposed to be an article about hardware: for one thing, it’s not “free”. Also, it’s not
because you use GNU/Linux that you’re a tinkerer at heart. Be at ease though, I won’t ask you to take your
device apart (it would void its warranty!).

Oh, you would anyway? Read on, then.

Media players tested


iRiver iFP 190 series

The original, boxed product uses a proprietary storage schema (it may have changed since I bought it, maybe
not): you need special software (Windows only) for it.

iRiver provides a UMS compatible firmware update which makes the player appear like a 128, 256 or 512 Mb
USB key. It can playback WAV, WMA and MP3 formats (iRiver tried for Vorbis support, but they gave up
due to hardware limitations; more recent models have Vorbis support though). Linux support is thus a UMS
firmware update away; further updates can be done without Windows by simply copying the new firmware to
the drive and ask it to update itself. It is powered by a single AA/LR6 standard battery, and connects through a
slow USB 1.1 connection cable.

Most iRiver devices get regular, official, covered by warranty, firmware updates; look those up if you have
one on the iRiver website.

66 The hardware
Issue 22
Apple iPod Mini 1st Gen

It comes with both an USB 2.0 and a Firewire connection (which can be used as the cable for the external
charger), and contains a CompactFlash/Microdrive hard disk of 4 Gb. It requires specific software to upload
the songs in a way that will have them recognized by the player. Replacing the non-standard internal battery
and drive is tricky, but well documented on the Web – it costs much less than through Apple, for better results
(switching the 4 Gb hard drive for a CompactFlash cartridge doubles battery autonomy; replacement batteries
add an extra 25% battery life).

If your warranty isn’t over yet, go through Apple for servicing though - as the above operation will void it.

I-BEAD 100 Digital Music Player

It contains soldered-in Flash RAM, and works as an USB key. Plug it in, browse it, use it. Biggest drawbacks:
easily serviceable yet non-standard battery. USB 1.1 transfer speed. Not much else to say, your run of the mill
media player.

Plug it in, browse it, use it. Not much else to say, your run of the mill media player

Cameras tested
Kodak EasyShare DX6340

This 3.1 Mpixels camera was well liked at the time it came out: on top of its optical zoom and microphone, its
optical viewer allows its owner to switch off the external screen, making it last ten times longer on its twin
AA/LR6 battery cells. It includes 16 Mb of internal RAM, as well as a standard SD slot. It connects to your
PC with a USB cable. Since it started selling, a firmware update has appeared: apply it for a more stable
experience.

Biggest drawback: it is not detected as an UMC drive, so you need to use an application that uses
libgphoto2, like F-spot. But then, it can be excruciatingly slow and hang very often depending on your
version of libgphoto2. If it does, update libgphoto2 (version 2.4.0 works very, very, well).

Samsung Digimax 301

This 3.2 Mpixels camera is small, at the cost of an optical zoom. It is powered by a pair of AA/LR6 sized
cells, and contains a SD card. It connects with a USB cable, is detected as an UMS drive (Full Speed USB,
equivalent to USB 1.1) as well as a camera. GNOME knows its directory layouts, and will thus see it as a
camera anyway.

HP Photosmart R707

This 5.1 Mpixels camera is a bit special as it is a dual mode camera; by default, it presents itself as a camera,
but it can be configured to work as an USB drive. Note that this camera must use its latest firmware for safe
operation: the battery charge manager doesn’t work on firmware versions lower than 2.0.24, and must be
updated (available on HP’s website), otherwise you’ll soon have a non-working battery, or worse, a blown-up
one. Now, the new firmware is provided as a Windows .EXE file, but Wine can unpack it easily, and then you
merely need to copy the resulting file to a freshly formatted SD card to proceed. Thus, Windows is not
mandatory.

If you already fell victim to this problem, generic batteries model no. CS-NP60FU, 1050mAh, 3.7V work
very well with it.

Back to the camera itself: not only can it work as a generic USB drive, gphoto2 knows how to handle it too.
For some reason, it doesn’t always work as an UMS device: switch it to `camera’ mode, and it’ll happily work
through gphoto2. So, it is pretty much trouble-free once its firmware is updated.

Apart from iPods, pretty much all devices benefit from a firmware update

Media players tested 67


Issue 22
As a general rule, always check if your device has an updated firmware, and use it if possible. Apart from
iPods, pretty much all devices benefit from an update.

Playback your music


The easy way
Most models of MP3 players out there allow you to manage them easily: plug them in, put files in a format
they support on them, unmount them, unplug them: done.

You can do that as you’d manually manage files, or use your favourite media player software to do that for
you: Rhythmbox (for GNOME), Amarok (for KDE), Banshee, Audacious, XMMS (of course, in the latter
case, usability is extremely limited: you’d be better off using a file manager)…

In some cases though, using these software is mandatory: iPods for example require their specially crafted
database to be updated while a file is uploaded in order to play them back. If it isn’t, then it won’t play.

Of those, Rhythmbox (and Amarok) are recommended: they are geared towards handling connections of
external devices, and are the default applications for GNOME and KDE.

Rhythmbox
Rhythmbox is an all-around music player based on gstreamer: it handles podcasts, webradios, local files in
many formats and also external devices.

To use it, just plug your media player in, let Rhythmbox autodetect it, and then it’s just a matter of dragging
and dropping titles from your library (podcasts included) back and forth with your device. Once you’re done,
unmount the device, and that’s it.

Figure 1: Rhythmbox right after importing my music collection

Rhythmbox’s main window is divided into two main zones: the left task-bar conditions what you do with the
application. At the top, the library is divided into the playlist (you set up what you actually listen), your local
music, then podcasts, then error notifications (failed import, unrecognised file format, loss of sync… In my
case, it couldn’t playback WMA files, and just couldn’t deal with Amiga modules) and web radios.

Following those, you have shops (here, Magnatunes and Jamendo), then your playlists and—if you have it
connected—your mobile media player (here, it detected my iPod as `gtkpod’, but you can rename it).

Rhythmbox is an all-around music player based on gstreamer: it handles podcasts, webradios, local
files in many formats and also external devices

Depending on the functionality you choose, the right-hand part of the window can have up to four

68 Playback your music


Issue 22
subdivisions. The most complex one is for `Music’: it allows you to sort your music collection by author,
album and song title. Upon importing music, Rhythmbox parses the file’s tag (ID3 for MP3 files, embedded
comments for Ogg, etc.) and sorts them into their relevant categories. It also allows fast sorting of your files,
in case there are discrepancies in your ID3 tags.

Right beneath the program’s main window in Figure 1, you can see the icon for the mounted iPod.

The hard way


To do it the “hard way, just copy your file to the player. You’ll need to ensure by yourself that this model can
handle the file you feed it, though:

• many small players can’t handle high bit-rates: 192 Kbps is very often the upper limit, sometimes
anything past 160 Kbps is too much. Remember the MPEG1-2 Layer 3 specifications don’t cover
bit-rates above 320 Kbps;
• Some players can’t handle variable bit-rates: while they are supposed to support variable bit-rate as
part of the format (as VBR/ABR is nothing more than stretching the format specifications a bit), it is
sometimes quite tricky to implement reliably on small pieces of hardware;
• MP3 is the most used format (only some old Sony devices don’t understand it); however, some
players can play back WMA, AAC and some can playback AC3, Vorbis and FLAC. But not all.

This method doesn’t work with players that require a special way to access them, like all Apple iPod models.

You’ll need to ensure by yourself that this model can handle the file you feed it

The Geek way


Some of these players are far more powerful than their manufacturers let you believe: several projects exist to
make them run more than just a playback engine.

For you iPod owners, there is iPod Linux: take the µLinux kernel, and adapt it to the iPod. You can then run a
bunch of bona fide GNU/Linux applications (including a music player) on your iPod. Note that this way
allows you to playback file formats the original firmware can’t. It has some drawbacks though: as it is a full
operating system, it is quite demanding on the hardware, and will suck the battery dry faster than the original
firmware.

It doesn’t work on the most recent models either, due to an encrypted boot sector. Older models may run fine,
but I’ll advise you to stop updating your iPod’s firmware: Apple keeps making things more difficult, and
won’t release iTunes for Linux any time soon.

Another way is to use RockBox: that one is a real replacement firmware for many hand-held music players
(not just the iPod). As such, it is more fit for everyday use than iPod Linux, and it comes with several of its
advantages: much better customization of the hardware, several applications have been ported to this platform,
to the point it can be considered a small computer. Yes, Doom runs on my iPod mini, with Rockbox; if you
ever wondered what Doom would have looked like on a Nintendo Gameboy (the original), this is it.

Please note: if, for one reason or another, you are afraid of destroying the firmware, making the device
unbootable, read as much as you can about restoring factory state from the Rockbox website, or from the
manufacturer’s - most iPods for example, include a hard-wired restore mode that will wipe the disk clean,
connect with iTunes and ask it to reinitialize the device with the latest official firmware. Instructions,
testimonies, How-To available at Rockbox’s.

Doom runs on my iPod mini, which qualifies it as a computer

It is quite easy to install (detailed instructions for your player are available on the Rockbox website) and
works very well. It is also constantly updated.

The easy way 69


Issue 22
Both of these options will allow you to play back more formats (Vorbis, AC3, FLAC, etc.) than before, and
you won’t need an extra application to transfer files to your iPod any more.

I tried taking pictures of my iPod Mini 1st generation running Id Software’s Doom shareware, but it was far
too small to be useful.

Get to your pictures


Use the F-spot, Luke
When you connect your camera to your computer, GNOME asks you if you want to import your photos (if
you always want to do that, check the option marked `always do this action’ the first time GNOME asks). It
will then open F-spot, which downloads the thumbnail previews, and ask you what images you want to copy
to your computer. At this stage, you can select the images you want to take, and what tag you will give them.
The next stage, is the actual downloading of the images: be patient.

Figure 2: the import dialogue right along F-spot’s main window. If you really strain your eyes on the
full-size image, you’ll see that the imported photos are of the iPod running Doom. Don’t hurt
yourself.

Next up, ordering your pictures. You can tag them on import, but also later on, then edit them through the
GIMP (F-Spot doesn’t provide editing functionalities past image orientation and colour adjustment, which are
merely EXIF settings edition, not actual image editing)

Gphoto2 is both a library and a command line utility

Gphoto2 is both a library and a command line utility. The former is used by applications such as F-spot (for
GNOME) or DigiKam (for KDE) to access some cameras that don’t use UMS. It can access both serial port
and USB connected cameras. The list of supported models can be seen with gphoto2 --list-cameras.

But the list is long, so you’d be better off filtering the list with gphoto2 --list-cameras | grep
<your camera model/brand>.

Some are marked as TEST, others as EXPERIMENTAL. If yours is, too, try updating to a more recent version
from http://www.gphoto,org , or through your distribution’s updates (backports, upgrade your distribution…).

Switch to manual
However, you may want to proceed faster than, or you’re just too `old school’ for F-spot: do not fret, as
copying files from an UMS enabled camera is no more difficult than doing so from a USB key. You can open
Nautilus, Thunar, Konqueror, Dolphin, or whatever, and just copy the images from one place (the camera) to
another.

70 Get to your pictures


Issue 22
You can be even more rad, and do that through a terminal window with cp or mv, or with Midnight
Commander, emacs, or… Whatever rocks your boat.

If, however, your camera doesn’t work as an UMS device, things can get tricky. If your camera is supported
by gphoto2, try the following commands:

gphoto2 --auto-detect

This may return:

$ gphoto2 --auto-detect
Model Port
----------------------------------------------------------
Kodak DX6340 usb:
Kodak DX6340 usb:001,012

Other useful commands are:

-n: gives the number of files on the device

--storage-info: describes what your camera has for storage (internal RAM, SD card…)

-p <range>: get images inside specified range

-P: get all files on the camera

Use gphoto2 --help for a more comprehensive list of options, or man gphoto2 for the whole
resource. Gphoto2 also provides a shell, which may prove more useful than passing options all the time.

Gphoto2 also provides a shell, which may prove more useful than passing options all the time

If you just can’t deal with gphoto2 or it doesn’t work for you, get an SD card reader, and re-read the part
about manual file copy.

However, be extra careful: some cameras take liberties with the FAT partition format, and may panic if you
feed them SD cards they didn’t format themselves: thus, avoid formatting your SD card with your
distribution’s partition manager: use the camera’s built-in functionality instead if you want to wipe out your
card. Moreover, while extracting the SD card may allow you access your pictures with the camera powered
off, I recommend you don’t do that often: those cards (and their contacts inside the camera) are not made to be
removed and plugged back in all the time.

Conclusion
I hope I tried enough different devices (sorry, I couldn’t get my hands on a COM port connected camera) to
give a comprehensive article. Still, a repeated word of warning: if your device doesn’t work properly, first
check its firmware (get the latest version, provided it doesn’t add `functionalities’ like an encrypted boot
sector), then your library versions (hald, udev, dbus, gphoto2, libgpod…), and before you despair, make sure
that you don’t have a moody USB controller.

Once you’re up and running, enjoy–Free tools are powerful enough to fit any requirement you may have about
them, and many times leave competition in the dust.

I mean, it’s not Apple that turned my 10-hours battery life iPod into a 20 hours running game console…

Bibliography
I pretty much wrote this article through trial and error; still, you may want to look at the following resources:

• the gphoto2 man page (man gphoto2) and website

Conclusion 71
Issue 22
• make your iPod your own with Rockbox and iPodLinux
• dbus at Freedesktop.org
• For udev and hald, have a look at their man pages (man 8 udev, man 8 hald).

Biography
Mitch Meyran (/user/17379" title="View user profile.): Mitch is a professional computer abuser. He started on
this peculiar kink when he got a 8088-based PC, and soon found out that tinkering with computers is almost
as fun as using them - provided the OS lets you do it.

Copyright information
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General
Public License, Version 2 or any later version published by the Free Software Foundation. A copy of the
license is available at http://www.gnu.org/copyleft/gpl.html.

Source URL:
http://www.freesoftwaremagazine.com/articles/mobile_devices_linux_gnome

72 Bibliography
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Composer, a potential HTML based word processor
Composer: word & document processor
By Maurice Cepeda
PUBLISHED: 2008-06-03

Rosalyn Hunter writes about using Composer as a stand-in word processor. I too, have used it in this fashion
on OS X. I like it for various reasons. For instance, I’m quite familiar with it, as I’ve used it for website
authoring numerous times. It creates HTML files. I’ve come to the conclusion that HTML is not a bad
“language” to use for a word processor, considering that it already allows for basic editing features—and then
some. If it isn’t obvious, Composer is an HTML editor that was part of the old Mozilla suite.

Although the suite development officially ended a while ago, a resurrection project called SeaMonkey
continues in its place, which includes Composer. There are also the stand-alone Nvu, and its fix called
KompoZer. Both of the latter projects are at a standstill: Nvu’s main developer, Daniel Glazman, will
eventually finish the next generation Composer (don’t hold your breath).

Composer features
The following are reasons why Composer makes a decent stand-in word processor. Keep in mind that these
features are not revolutionary, but the point is that users don’t need to resort to overblown word processors to
get these features: Composer really can be used as a temporary replacement word processor, and that it makes
a good basis upon which to develop a full fledged one. Here are its features:

• supports basic formatting (indenting, paragraphs, bulleting);


• supports a variety of fonts;
• supports tables;
• supports images;
• has a spell checker (dictionary);
• supports hyper-links.
• real time spell checker (if configured)- it’s instant rather than having to run the cursor over every
word before it kicks in.

As far as HTML goes:

• it supports multiple character encodings, the near universal UTF-8 and my past favourite ISO-8859-3
for southern European languages. It even allows for a quick and simple conversion from one encoding
to another;
• HTML is a markup language that’s humanly understandable, if you want to read it. It allows low level
hacking under the source tab. Don’t try to read any other word processor source after opening it up in
a text editor;
• supports FTP, allowing the transferring/saving of documents onto ftp servers;
• documents created in Composer can easily be integrated into HTML-based emails. Just copy and
paste;
• lastly and perhaps most importantly, HTML files can be viewed by any browser on any operating
system. Imagine putting a stop to friends and colleagues saying, “I can’t open your file. Can you send
it to me using (the latest and expensive) Word?”.

Composer features 73
Issue 22
HTML files are viewable in any browser (even text based ones), giving you a powerful format for
communication

To elaborate on the economical size of HTML files, as with Scribus, Composer does not save images within
the HTML files it produces. This allows you to create small documents. File size savings can be leveraged by
placing images—meant to be viewed in documents—on ftp servers to have documents link to them for
viewing. Pathways from HTML documents to images need to remain constant, though. Otherwise, images
will not be found to be where expected and consequently not shown.

Figure 1: Composer at work writing this article

Reasons why composer is not ordinarily used as a


word processor
So why hasn’t Composer been extended into a word processor? I’m not sure. Maybe it’s because Microsoft
Word won the most mind share. Also, OpenOffice.org (OOo) and even Abiword are well established as
FLOSS alternatives. There is also NeoOffice (NeoO) for OS X, a Java based porting of OpenOffice.org. In the
end, I usually find these slow (NeoO), to be huge file downloads (NeoO and OOo), and buggy (NeoO). Unlike
free counterparts, Word on Windows starts quickly, but I recall that the trick to this is that Windows keeps big
portions of Word in ram at all times —a wasteful and inefficient use of resources. This is not to say that
Composer doesn’t have its own issues, but given the slow start-up times, overall sluggishness, viewing
problems (Abiword for OS X), and memory use of the established programs, why not use Composer?

On the other hand, a Composer shortcoming is that it misses layout capability. That is, it’s difficult to see
what is going to hard-print beforehand. Another short-coming is that it prints a pathway header, which is
undesirable and unsightly. A work around (on OS X) is to print from a PDF obtained from Shiira 2.0 b2,
which doesn’t insert the header. If I recall, the print options for SeaMonkey stable but not KompoZer, Nvu,
nor suiterunner (Seamonkey unstable) also allow to opt-out this header. The selecting of paper size and
WYSIWYG implementation would bring Composer to a respectable basic processor status.

What about LaTeX?


There is another reason why no one has taken this HTML processor idea up. There already is a markup based
writer’s program and its been around for decades, although accompanied with a steep learning curve. It’s
called LaTeX, and it provides professional quality results. Unfortunately, it’s limited to academia because it
has never won avid support among laymen. It’s also a nuisance to install, with numerous and sizeable files
coming from various sources with various licenses. For instance, to get a working install, you must have a
front-end, but front-ends do not provide the plethora of back-ends needed for a simple run of the mill install.
Another problem again is interoperability; common programs, such as internet browsers, are not able to render
LaTeX files. On the other hand, I don’t think HTML renders mathematical equations or is entirely
WYSIWYG compliant as LaTeX. But then again, most of us don’t need to display equations, nor do we need
ultra-high WYSIWYG fidelity.

74 Reasons why composer is not ordinarily used as a word processor


Issue 22
To shortly recap the development of word and document processors as I recall their development, word
processors format words, while document processors —such as LaTeX— format documents (the latter are
therefore “document orientated”). Early on, word processors (and document processors) differentiated
themselves from text editors in that they added styling to the ordinary and basic Roman numerals —that is
alpha-numericals, essentially the basic Roman alphabet without diacritical marks. Where the two camps
diverged was at which point of the writing process there should be adding of “style” (or markup) to the basic
text. Document orientated supporters have always criticised the word processor “edit as you go” idea because
it interrupts the writers train of thought with secondary concerns of presentation. All the while, these
supporters believe the document oriented approach frees the writer to “just write”, preoccupying himself with
content and not presentation.

I could be accused by comparing apples and oranges, and this is a correct assessment. But both concepts are
not lost on me; an application such as Composer potentially allows both approaches. That is, while Composer
easily allows word processing, the stylisation of individual or groups of words, CSS (Cascading Style Sheets)
could allow for a document orientated take. That is, CSS could work as templates, thus freeing the writer from
formatting, and perhaps implementing the template afterwards (and thus avoid interruptions of thought); the
writer, if if need be, could even implement the template at the same time by simply plugging words into it.

As for the typical critique of HTML presentation inconsistency, CSS increases uniformity. Add the cross
platform universality of HTML and the fact that HTML files are viewable in any browser (even curses based
ones), and you have a powerful communication format. As should be obvious by now, Composer needs
development to make it the word/document processor envisioned herein, but the basis—in terms of both html
and program features—already exists.

CSS could allow for a document orientated take … as templates … increasing uniformity of
presentation

Scribus, an XML markup page layout attempt


Moving away from the envisioned HTML editor, there is a free (as in freedom) program that offers the layout
elements missing from Composer. It’s a page layout program called Scribus. An OS X port is available
(Scribus/Aqua). It’s fairly easy to install and has just a few dependencies. The learning curve is not steep, just
different from word processors. Last I checked, the OS X port was a little rough around the edges (it was slow
and the key-bindings didn’t always work) but it’s workable (with occasional crashes). The port is sure to
stabilise in the future as work progresses and a native Intel port is eventually released. Even so, the problems
are OS X specific (as it flies on GNU/Linux). It produces its own XML based .sla file format, without
self-contained images (keep image pathways constant). As you might already have deduced, .sla documents
are not viewable with most other programs, but Scribus can convert .sla into universal PDF and EPS files with
great resolution (but which are undoubtedly larger than HTML files). Setting aside file size issues, I still
prefer the HTML approach because HTML files are easier to edit than PDF or EPS files. Lastly, to the best of
my knowledge, you can’t render images remotely with .sla as you can with HTML, either.

Other HTML word processor attempts


There are and have been a few attempts at a HTML word processor. FLWriter and EZ editor fit the bill (the
latter also does equations); and GWP (GNOME Word Processor) may have had similar aspirations (hard to
tell as their site is really slow and hasn’t been updated since 1998!). It seems that out of this lot, only
FLWriter is currently developed —and it’s in alpha stage.

On the other hand Composer is mature and is the natural candidate onto which, in my opinion, add page
layout capability —and create a dual purpose word and document orientated processor. Most of it is already
written after all…

Composer editors

• SeaMonkey (contains Composer)


• Nvu
• KompoZer

Other HTML word processor attempts 75


Issue 22
Other editors

• EZ editor
• FLWriter
• GWP
• Scribus/Aqua

LaTeX Front-ends

• TexShop
• Texmaker

Other LaTeX info or implementations

• Lyx
• LaTeX and Mac
• McTeX

Biography
Maurice Cepeda (/user/49345" title="View user profile.):

Background
Recent Activity
As of late, Maurice teaches English as a second language for the University of Concepción in Chile. Therein,
he authored complementary e-texts consisting of dialogues and accompanying voice work to Steven J.
Molinskyâ’ s series, Side by Side.

While employed at the Universidad Adventista de Chile, he taught an university level English literature class
that delved into Lessig's Free Culture and Stallman's Essays. This was an attempt to discover the sometimes
subtle differences between plagiarism and legitimate authorship based on previous works.

He maintains a blog at http://mauroandres.wordpress.com/ where he posts on a variety of topics, from


mundane diary entries to "straight to the grain" HowTos.

Academic Training
Maurice Cepeda attended the University of Alberta, where in 2005 he obtained a degree in Comparative
Literature & Sociology. He also holds a teaching English as a second language certificate.

Personal Interests
Maurice was a member of the (now defunct) LSD (Liberating Students Digitally), a University of Alberta
student group dedicated to increasing Gnu-Linux and *BSD awareness among computer users. There he
pro-actively participated on the philosophy committee authoring advocacy flyer content. Presently, he has a
strong interest in Gnu, Gnu-Linux, BSDs, Stallman's writings, and Lessig's Free Culture.

Sport Related Interests


He cumulatively trained 15 years in western boxing and martial arts. He taught recreational boxing at Wind
Warriors Boxing in Edmonton, Canada. Much of this was as a sparring partner to professional and amateur
competitors, mostly within western boxing but also Muay Thai.

76 Background
Issue 22

Copyright information
This article is made available under the "Attribution-NonCommercial-Sharealike" Creative Commons License
3.0 available from http://creativecommons.org/licenses/by-nc-sa/3.0/.

Source URL:
http://www.freesoftwaremagazine.com/articles/composer_potential_html_based_word_processor

Sport Related Interests 77


Issue 22

78 Sport Related Interests


Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Writing a kernel module for FreeBSD
FreeBSD hacking 101
By Yousef Ourabi
PUBLISHED: 2008-06-19

FreeBSD 7.0 has already been released. If you are a real hacker, the best way to jump in and learn it is
hacking together an introductory kernel module. In this article I’ll implement a very basic module that prints a
message when it is loaded, and another when it is unloaded. I’ll also cover the mechanics of compiling our
module using standard tools and rebuilding the stock FreeBSD kernel. Let’s do it!

Getting Started
There are some prerequisites for this article. I assume you have a little bit of C programming knowledge,
though nothing too fancy. If I reference a pointer or a structure, I expect you to understand those concepts
without much explanation. I also expect you to be familiar with UNIX-like operating systems and know your
way around basic shell usage.

The first thing to do is make sure the development environment you’ll be working in includes everything and
is configured properly. I’m going to assume you already have FreeBSD installed and running. If you don’t,
and would like some guidance, you can read my article: Secure emails servers with FreeBSD. I’ll be doing a
few things differently; so, I would recommend just using it as a resource for the installation, which is identical
in both scenarios.

You will also need to make sure the sudo utility is installed and configured for your main user account. This
is required to run as “root” the utilities kldload and kldunload. The FreeBSD port for sudo is in
/usr/ports/security/sudo.

cd /usr/port/security/sudo
make install && make clean

Now su to root and run the visudo utility. Visudo uses the EDITOR environment variable to determine
which text editor to use. If you don’t like the default one, override it with setenv EDITOR vim if you are
using the default CSH, or export EDITOR=vim if you are using bash. Then simply re-run visudo.

su
visudo

The visudo utility does basic sanity checking on the syntax and makes sure no two people edit the sudoers file
at the same time.

# Look for this line, copy it and change the "root" user to your main users name.
root ALL=(ALL) SETENV: ALL
yourabi ALL=(ALL) SETENV: ALL

Your first kernel

Your first kernel 79


Issue 22
As I mentioned in my recent article Review of FreeBSD 7.0, the ULE scheduler brings a new level of
performance and multi-processor scalability to FreeBSD. Though it is now considered stable and ready for
prime-time, it will not be enabled by default until the 7.1 release. A good litmus test of your setup will be
compiling a custom kernel with the ULE scheduler enabled.

If you are on an x86 based machine, the kernel is located in the /usr/src/sys/i386 directory. For
amd64 machines, simply replace i386 with amd64, which becomes /usr/src/sys/amd64. The kernel
configuration file is located in a directory called conf. Enter that directory and create your own custom
kernel configuration file by copying the “generic” default configuration to one of our own naming.

cd /usr/src/sys/amd64/conf
cp GENERIC CUSTOM

Now it’s time to enable the new ULE scheduler. The new ULE scheduler brings improved performance and
scalability compared to the legacy scheduler and also serves as a good demonstration of building and
installing a custom kernel.

Open the “CUSTOM” file with your text editor of choice and find the line enabling the legacy 44BSD
scheduler and replace it with ULE. In the stock kernel configuration file this should be around line 30 (at the
time of this writing).

options SCHED_4BSD # 4BSD scheduler


# BECOMES #
options SCHED_ULE # ULE scheduler

Now build your new kernel and reboot so it takes effect. FreeBSD has an elegant, simple build system using
the standard “make” utility. Simply change directories to the source tree and invoke the make file with the
“buildkernel” and “installkernel” targets. If you call them without any parameters, the GENERIC (default)
kernel will be built and installed. Since you want your custom kernel, pass in the KERNCONF flag with the
name of the target kernel. In this case, it will be the name that you just copied the generic kernel to: CUSTOM.

cd /usr/src
make buildkernel KERNCONF="CUSTOM"
make installkernel KERNCONF="CUSTOM"
reboot

Congratulations! As the system boots up, it will run the new custom kernel with the ULE scheduler enabled.
You have now verified that you are able to compile and install a kernel, so it’s time to take on your next task:
writing a simple kernel module.

When running FreeBSD in VMWare make sure to lower the kernels timer frequency

Note: If you are running FreeBSD in VMWare there is one very important performance tweak to make to your
system to follow this article. The kernel’s timer frequency needs to be lowered from ‘1000’ to ‘100’ ticks per
second. Edit /boot/loader.conf with your favorite editor and add the following line.

echo kern.hz=100 >> /boot/loader.conf

Kernel Hello World


As you may have noticed, FreeBSD makes efficient use of the make utility for building and installing kernels
(and the rest of the operating system). What you may not know yet, but will come as no surprise, is that the
FreeBSD developers have also developed make files to ease part of the difficulty of kernel module
development.

An in depth look at make files and the make utility are beyond the scope of this article. However, two points
of immediate relevance are the bsd.kmod.mk make file and the ability to include other make files within
each other.

80 Kernel Hello World


Issue 22
The bsd.kmod.mk makefile resides in /usr/src/share/mk/bsd.kmod.mk and takes all of the pain
out of building and linking kernel modules properly. As you are about to see, you simply have to set two
variables:

• the name of the kernel module itself via the “KMOD” variable;
• the source files configured via the intuitive “SRCS” variable;

Then, all you have to do is include <bsd.kmod.mk> to build the module. This elegant setup lets you build your
kernel module with only the following skeletal make file and a simple invocation of the “make” utility.

The Makefile for our introductory kernel module looks like this:

# Note: It is important to make sure you include the <bsd.kmod.mk> makefile after declaring the

# Declare Name of kernel module


KMOD = hello_fsm

# Enumerate Source files for kernel module


SRCS = hello_fsm.c

# Include kernel module makefile


.include <bsd.kmod.mk>

Create a new directory called kernel, under your home directory. Copy and paste the text above into a file
called Makefile. This will be your working base going forward.

Creating a module
Now that you have a clue about the build environment, it’s time to take a look at the actual code behind a
FreeBSD kernel module and the mechanisms for inserting and removing a module from a running kernel.

A kernel module allows dynamic functionality to be added to a running kernel. When a kernel module is
inserted, the “load” event is fired. When a kernel module is removed, the “unload” event is fired. The kernel
module is responsible for implementing an event handler that handles these cases.

The running kernel will pass in the event in the form of a symbolic constant defined in the
/usr/include/sys/module.h (<sys/module.h>) header file. The two main events you are
concerned with are MOD_LOAD and MOD_UNLOAD.

How does the running kernel know which function to call and pass an event type as a parameter to? The
module is responsible for configuring that call-back as well by using the DECLARE_MODULE macro.

The DECLARE_MODULE macro is defined in the <sys/module.h> header on line 117. It takes four
parameters in the following order:

1. name. Defines the name.


2. data. Specifies the name of the moduledata_t structure, which I’ve named hello_conf in my
implementation. The moduledata_t type is defined at line 55 of <sys/module.h>. I’ll talk
about this briefly.
3. sub. Sets the subsystem interface, which defines the module type.
4. order. Defines the modules initialization order within the defined subsystem

The moduledata structure contains the name defined as a char variable and the event handler routine
defined as a modeventhand_t structure which is defined at line 50 of <sys/module.h>. Finally, the
moduledata structure has void pointer for any extra data, which you won’t be using.

If your head is about to explode from the overview without any code to put in context, fear not. That is the
sum of what you need to know to start writing your kernel module, and so with that, “once more into the
breach dear friends”. Before you get started, make sure you are in the same kernel directory where you
previously created the Makefile file. Fire up your text editor of choice and open a file called

Creating a module 81
Issue 22
hello_fsm.c.

First include the header files required for the data types used. You’ve already seen <sys/module.h> and
the other includes are supporting header files.

#include <sys/param.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>

Next, you are going to implement the event_handler function. This is what the kernel will call and pass either
MOD_LOAD or MOD_UNLOAD to via the event parameter. If everything runs normally, it will return a value
of 0 upon normal completion. However, you should handle the possibility that something will go wrong and if
the event parameter is neither MOD_LOAD or MOD_UNLOAD, you will set e, your error tracking
variable, to EOPNOTSUPP.

/* The function called at load/unload. */


static int event_handler(struct module *module, int event, void *arg) {
int e = 0; /* Error, 0 for normal return status */
switch (event) {
case MOD_LOAD:
uprintf("Hello Free Software Magazine Readers! \n");
break;
case MOD_UNLOAD:
uprintf("Bye Bye FSM reader, be sure to check http://freesoftwaremagazine.com !\n");
break;
default:
e = EOPNOTSUPP; /* Error, Operation Not Supported */
break;
}

return(e);
}

Next, you’re going to define the second parameter to the DECLARE_MODULE macro, which is of type
moduledata_t. This is where you set the name of the module and expose the event_handler routine to
be called when loaded and unloaded from the kernel.

/* The second argument of DECLARE_MODULE. */


static moduledata_t hello_conf = {
"hello_fsm", /* module name */
event_handler, /* event handler */
NULL /* extra data */
};

And finally, you’re going to make a call to the much talked about DECLARE_MODULE with the name of the
module and the hello_conf structure.

DECLARE_MODULE(hello_fsm, hello_conf, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);

All that is left to do is build the module. Double check that you are in the same directory as the module’s
makefile you saw earlier and run:

make

Loading and unloading the module


To load the module, you have two options: the kldload utility or the load make target via the
<bsd.kmod.mk> makefile. You must use both options via the “sudo” utility as loading and unloading
modules requires root privileges.

sudo kldload ./hello_fsm.ko


# or #
sudo make load

82 Loading and unloading the module


Issue 22
You should see the message “Hello Free Software Magazine Readers!” on your console. To view all loaded
modules, use the kldstat utility with no arguments. kldstat does not require root privileges and you can
verify that the module is indeed loaded.

kldstat
Id Refs Address Size Name
1 8 0xc0400000 926ed4 kernel
2 1 0xc0d27000 6a1c4 acpi.ko
3 1 0xc317e000 22000 linux.ko
4 1 0xc4146000 2000 hello_fsm.ko

To unload the module, use kldunload or the unload target in the <bsd.kmod.mk> make file. You should
see the message printed on the MOD_UNLOAD case, which is “Bye Bye FSM reader, be sure to check
http://freesoftwaremagazine.com!”

sudo kldunload hello_fsm


or
sudo make unload

Conclusion
There you have it, a basic, skeletal kernel module. It prints a message when loaded and a separate message
when being unloaded from the kernel. This article covered the mechanics of building, inserting, and removing
the module. You know have the basic building blocks to take on more advanced projects: I would recommend
looking at writing a character device writer as it is probably the next simplest device driver.

I hope this has been as much fun for you as it has been for me!

Resources
• Writing device drivers in Linux
• FreeBSD’s handbook
• FreeBSD’s developers handbook
• FreeBSD Architecture Handbook
• FreeBSD under VMWare

Books:
• The Design and Implementation of the FreeBSD Operating System, by Marshall Kirk McKusick and
George V. Neville-Neil
• Designing BSD Rootkits, an Introduction to Kernel Hacking, by Joseph Kong

Biography
Yousef Ourabi (/user/43" title="View user profile.): Yousef Ourabi (http://yousefourabi.com) is a developer in
the San Francisco bay area. He is currently working at the startup he recently founded, Zero-Analog
(http://www.zero-analog.com " title="Zero-Analog). Zero-Analog is currently developing an enterprise
application, however, one of its stated goals is "to increase the rate of open source adoption in companies of
all sizes, across all industries". Zero-Analog also offers consulting services, all based around open source
tools, frameworks and applications.

Copyright information
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General
Public License, Version 2 or any later version published by the Free Software Foundation. A copy of the
license is available at http://www.gnu.org/copyleft/gpl.html.

Books: 83
Issue 22
Source URL:
http://www.freesoftwaremagazine.com/articles/writing_a_kernel_module_for_freebsd

84 Books:
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Practical guide to Mindquarry
Everything you need to know to get started with Mindquarry
By Dmitri Popov
PUBLISHED: 2008-06-10

If you are looking for a powerful yet easy to use collaboration solution, you might want to take a closer look
at http://www.mindquarry.com. Groupware tools are a dime a dozen these days, but there are a few features
that make Mindquarry stand out from the crowd.

• Instead of reinventing the wheel, Mindquarry relies on proven and mature technologies such as
Subversion, wiki, and more.
• Seamless integration between the user’s desktop and web interface. The Mindquarry Desktop Client
provides an extremely easy way to keep documents in sync, hiding all the intricacies of Subversion.
The client supports multiple profiles, which allow the user to work with several Mindquarry servers.
• Tight integration between different Mindquarry modules. For example, the user can link wiki pages to
documents, tasks, and users.
• Thanks to the intuitive interface and well thought-out feature set, Mindquarry has a very gentle
learning curve. This makes it easier for users to get to grips with Minquarry as well as significantly
reduce training costs for companies.
• The Activity Timeline is a killer feature from the end-user perspective. Keeping track of document
versions is a serious challenge even for experienced users. The Activity Timeline uses the timeline
metaphor to tackle this challenge and makes the process of finding and retrieving any previous
version rather straightforward.

Mindquarry consists of two components: a server and a client. The former provides all the functionality while
the latter acts as a bridge between the user’s desktop and the server. The client’s main purpose is to keep
documents in sync. Minquarry includes four modules: Teams, Wikis, Files, and Tasks.

Using the Teams module


The Teams module is designed to manage users and teams. As an example, let’s create a team called Writers,
then create the Author, Editor, and Proofreader users, and add them to the team. There are three things you
need to do as soon as you log in to the Mindquarry server. You have to change the default administrator
password and account info, add users, and create at least one team. To change the administrator account
details and password, click on the Edit your user profile button in the upper-right corner of the window. This
opens the Change User Profile windows, where you can change the default data.

Populating Mindquarry with users is equally easy. Click on the Team tab, and press the New User button. Fill
out the required fields, and press the Create User button. Next step is to create a team, which is also an easy
thing to do. Basically, teams allow you to group users, and it’s up to you what criteria to use when grouping
users into teams. For example, you can group users either by project or by function. To create a team, press
the New Team button, enter the required information, and press the New Team button. Once the team has been
created, you have to add users to it. Press the Members button, add the users you want to the group, and press
Save.

Using the Teams module 85


Issue 22

Installing and using the Mindquarry Desktop Client


The Mindquarry Client is a utility that acts as a bridge between your desktop and the Mindquarry server. The
client does two important things: it keeps documents on your computer in sync with the Mindquarry server,
and it allows you to keep tabs on tasks.

There are two ways to install the Mindquarry Desktop Client on your computer. When you log in to the
Mindquarry server, there is the Desktop Client link. Click on it, and the latest version of the client will be
automatically downloaded, installed, and launched on your machine. Alternatively, you can download the
latest release of the Mindquarry Desktop Client from Mindquarry’s website, and run it manually. To do this,
unpack the downloaded .tar.gz file in your home directory, rename the resulting folder to
mindquarry-desktop-client, and launch it from the terminal using the following command:

java -jar mindquarry-desktop-client/mindquarry-desktop-client.jar

Once the Mindquarry Desktop Client is up and running, you have to configure a server profile containing
information about your Mindquarry server that the client needs in order to connect to it. To do this, right-click
on the client’s icon in the Panel, choose Options, and navigate to Common Settings→Server Profiles. Press the
Add Profile button, give the new profile a name, and press OK. Use the credentials of an existing Mindquarry
user to fill out the Your Login ID and Password fields, and enter the server URL in the URL of the
Mindquarry Server field. Finally, you have to specify a path to a folder that will contain your workspaces. A
workspace is the equivalent of a team in the Mindquarry server. For example, if you have the Writers team on
the server, the specified folder on your computer will have a directory with the same name containing all the
team’s documents. Every time you add or modify a document in the Writers workspace, the client
automatically syncs the changes with the respective team on the server. Press OK to save the setting and close
the dialog window. Now perform a sync operation: Right-click on the client icon in the Panel and choose
Synchronize. If everything works properly, the folder you’ve specified in the server profile will be populated
with the workspaces.

While the client sits most of the time in the background and keeps files and documents in sync, it also allows
you to manage tasks. Click on the client’s icon in the Panel, and you will see all the existing tasks in the
pop-up window. To add a new task press the New Task button. This opens the Edit Task dialog window,
where you can specify the task’s details, such as name, status, priority, and due date. Press OK to close the
window and save the task.

Working with documents in the Files module


The Files module is probably the most important part of the Mindquarry collaboration suite. However, the
Files module is not a conventional document repository. In fact, its primary function is not even to store
documents. The Files module does two important things: it ensures that the documents stay in sync across
multiple desktops, it keeps track of all changes made to every shared document.

The Files module is based on Subversion (http://subversion.tigris.org/), a powerful and mature version control
system used by many open source software developers. Subversion allows developers and users to track any
changes made to a file in a so-called repository, a directory that is “watched” by Subversion. The File module
in Mindquarry hides all the inner workings of Subversion and makes it extremely easy to use. You don’t even
need to know how the system works, but understanding the basics can help you to avoid problems and
troubleshoot issues if they occur. So let’s take a look at what makes Mindquarry’s Files module tick.

Once you’ve created a team (for example Writers) and added users to it, each user must install the Mindquarry
Desktop Client to link her desktop with the Mindquarry server. When the user runs the client for the first time,
it creates a workspace with the team’s name (in this case Writers). Now if the user puts, say, an
OpenOffice.org Writer document in that folder, the document will be propagated to other team users’
desktops. Whenever any of the team users modify the document, the changes are automatically propagated
during the syncing operation. More importantly, each time the users perform a sync, the Mindquarry server
makes a copy of the modified document. This means that all changes made to the documents are recorded, and
the users can always retrieve a previous version of the document.

86 Working with documents in the Files module


Issue 22
Most of the time, you don’t have to think about behind-the-scenes stuff. Simply use the Mindquarry Desktop
Client to run a synchronization operation each time you add or modify a document in the workspace, and
you’ll be fine. There is just one important thing you have to keep in mind, though. When you are syncing
modified documents, the client prompts you to enter a message. It’s a good idea to use this feature to describe
the changes you made to the document. This makes it significantly easier to locate the version of the
document you need.

Using the File modules features

While the Mindquarry Desktop Client makes it extremely easy to keep documents and files in sync, the File
module of the Mindquarry server offers a few clever features that can help you to stay abreast of the changes
and manage document versions.

The Activity Timeline is a unique and nifty tool that presents all document changes as a timeline. Every time
you sync a modified document, Mindquarry places a mark on the timeline. Click on the mark, and you will
see a brief description of changes (this is why it’s a good idea to add a description during syncing). If you
click on the Show files link, the file list above the Activity Timeline will display the file versions from the
given date. This way you can view the previous versions of a document and roll back to an earlier edition of a
file, if necessary.

Another way to keep track of changes is to use the Recent Changes section, which provides a list of changes
grouped by users. This can come in handy when you want to see changes to a document or file done by a
particular user. Clicking on a version of the document displays it on the Activity Timeline.

Using an RSS feed in the Files module, you can keep track of changes in real time without even logging in to
the Mindquarry server. Simply subscribe to the feed using your favorite RSS reader, and you can stay abreast
of all document-related activities.

Wiki module
When you create a team, Mindquarry conveniently creates a wiki for it. While the Mindquarry’s Wiki module
follows these basic rules, it adds a few clever twists of its own. First of all, only team members can add and
edit wiki pages. All the editing is done in the graphical mode, which means that you don’t have to fiddle with
markup. Instead, all the formatting functions are available through the buttons on the main toolbar. In other
words, you work with a wiki page in Mindquarry as with a document in a conventional word processor. If you
prefer to work in the “raw code” mode, you can switch to it by pressing on the HTML Source button. Unlike a
conventional wiki, the Wiki module in Mindquarry uses standard HTML, which has two major advantages:
you don’t have to learn yet another set of markup rules, and you can easily import HTML pages into the wiki.
Better yet, many word processors such as OpenOffice.org Writer allows you to save text documents in the
HTML format ready to be imported into the wiki.

Each wiki in the Wiki module contains the default start page, which acts as a starting point. To edit it, press
the Edit button. This opens the page in the editing mode. The main toolbar contains the buttons that allow you
to quickly apply formatting to the selected text. Most of these buttons are self-explanatory, but the Insert link
button feature deserves a closer look since it offers a rather novel approach to the whole linking concept.
When you select a text fragment and press the Insert link button, the system displays a dialog window
containing different linking options. The Web tab, for example, allows you to quickly add a link to different
domains (.com, .org, and .net), or to a Wikipedia article. To see how this works in practice, type and select the
word “monkey”, press the Insert link button, switch to the Web tab, and choose the Wikipedia option. This
automatically inserts a link to the Wikipedia article on monkeys. In a similar manner, you can add links to
documents, tasks, other wiki pages as well as teams and users. The clever part is that Mindquarry uses the
selected text to find and display the related resources. For example, when you select the word “chapter”, the
system finds and displays all documents, wiki pages, and tasks containing the word (for example,
“Chapter1.odt”, “Research notes for Chapter III”, “Finish Chapter IV”). Of course, you don’t have to link to
any of the existing resources: instead, you can choose to create an empty wiki page. To do this, click on the
Wiki tab in the linking dialog window, and choose the Create a new wiki page option. You can also create a
new wiki page by simply pressing the New Page button in the main window.

Wiki module 87
Issue 22
Similar to the Files module, the Wiki part features the Activity Timeline, which maps all the versions of the
currently viewed wiki page. You can use the timeline to go back and view the previous versions of the page.
To do this, click on the dot on the timeline representing an earlier version of the page, and click on the Show
Wiki page in the pop-up window.

The Recent Changes section provides a list of all modified pages, and you can subscribe to the wiki’s RSS
feed to keep track of changes in the Wiki module. Finally, you can generate a PDF version of any wiki page
by clicking on the PDF icon.

Using the Search field you can search the existing wiki pages. The search feature supports query operators,
including AND, OR, NOT. Note that these operators must be in uppercase. If you don’t specify any operators,
the system uses the default AND operator, which searches for all words specified in the search query. You can
use parentheses to group query terms and quotation marks to search for exact phrases.

The Tasks module


Although Mindquarry doesn’t offer a dedicated calendar, it features a rather impressive Tasks module. For
starters, the module is heavily AJAXified, which makes it more like a desktop application than a web-based
task manager. More importantly, however, it provides an ingenious way to manage the tasks. In a traditional
task manager, when you create a new task, you have to fill out a number of mandatory and optional fields. In
Mindquarry, you can choose what fields to use on the fly. When you create a new task, you have an option to
insert additional fields or remove the existing ones by pressing the appropriate Fields buttons. For example, if
you want to add a detailed description of the task, press the Description field button, and the Description field
is added to the task form (including a WYSIWYG tool bar for rich formatting). If you need to assign the task
to a particular user, you can just press the People button and select the user you want from the drop-down list.
To remove a field from the task form, press the appropriate button. By adding and removing fields from the
task form, you can customize each task, so that it contains only relevant information.

The Tasks module includes yet another useful feature. If you have hundreds of tasks in your system, keeping
track of them can be a bit of a challenge. To solve this problem, the Tasks module allows you to create a filter
that displays only tasks that meet the specified rules. Better yet, you can save the filter for later use. For
example, you can create a filter that displays only low-priority tasks assigned to you and save it as “Things I
have to do some time”. Since you can add as many rules as you need, you can create rather advanced filters.
But that’s not all. The Tasks module provides RSS feeds, so you track the tasks using your favorite RSS
reader. You can export the tasks into a PDF file.

The Tasks module also generates a calendar file you can subscribe to using any iCal-compatible calendar
application. For example, you can use Mozilla Sunbird (a standalone calendar tool) or Lightning (a calendar
extension for the Thunderbird email client), and you can subscribe to your team’s tasks by setting up a new
network calendar. To do this, choose File→New Calendar, and select the On the Network option. In the Tasks
module in Mindquarry, right-click on the Calendar icon in the Alternative versions section, and copy the
calendar link (in Firefox, choose the Copy Link Location command). Return to the Sunbird (or Lightning)
calendar, press the Next button, select the iCalendar (ICS) option, and enter the copied calendar link into the
Location field. Press Next, give your calendar a name, and press OK. You should then see the list of tasks in
the Tasks pane of the Sunbird/lightning calendar.

Mindquarry’s future
Due to the lack of funds, Mindquarry’s developers had to end their commercial offerings and put Mindquarry
development on a backburner. However, they did release a beta version of Mindquarry 1.2, which offers a
new Talk module. The developers plan to move all the code and documentation to SourceForge, so other
developers can get involved in the project. Let’s hope they do, because Mindquarry is too good to be
abandoned.

Biography
Dmitri Popov (/user/41918" title="View user profile.): Dmitri Popov is a freelance writer whose articles have
appeared in Russian, British, and Danish computer magazines. His articles cover open-source software, Linux,

88 Mindquarry’s future
Issue 22
web applications, and other computer-related topics. He is also the author of the book Writer for Writers and
Advanced Users (http://www.lulu.com/content/221513).

Copyright information
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free
Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at
http://www.gnu.org/copyleft/fdl.html.

Source URL:
http://www.freesoftwaremagazine.com/articles/mindquarry_guide

Mindquarry’s future 89
Issue 22

90 Mindquarry’s future
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


DOSBox, a multiplatform PC emulator
Take a trip back to the begining of the PC game revolution
By Michael Reed
PUBLISHED: 2008-06-05

DOSBox is a freely available, cross-platform PC emulator. Rather than attempting to be the technology leader
as a business-orientated virtualization environment like VMware or Qemu, DOSBox instead offers a rich set
of features aimed at closely recreating the behaviour of a retro gaming PC. To this end, it offers a selection of
accurate sound card emulations and facilities to throttle the emulation speed back to vintage PC levels, along
with other features designed to make sure that the old games run properly and accurately within a protected
environment.

The problem defined


Many old games do not run (or do not run properly) on modern PCs. Until Windows became the most popular
platform for PC gaming, DOS was the environment under which PC games had to operate. The majority of
DOS-based games will run into problems on a modern system, if they will run at all.

Given a sufficient level of demand, a new (and equivalent) productivity application will be created, but the
situation for games is different. Games are, to an extent, artistic works, and one artistic work cannot easily be
replaced by another.

Why run old games?


Let’s be clear: not every old game is worth revisiting. As a general rule, about eighty percent of everything, in
all media, is rubbish. If not actually rubbish, entertainment media can be so tied to the time in which it was
made that it cannot survive the transition into a later era.

However, there are games that are worth hunting down and re-playing.

An old game might employ a gameplay style that has no modern equivalent, or a much-loved old game might
have a nostalgic attachment for a gamer. Sometimes, the gamer wishes to try out a game that they passed over
at the time of release. Finally, some old games are simply great games and are worth playing in their own
right.

A sad aspect of computer gaming as a type of entertainment media is that a lot of great content is lost due to
inaccessibility. The aspects of a great game that make the experience meaningful—the characters, plots,
music, etc—can be locked away due to technological obsolescence. This can prevent both personal
re-enjoyment of the game and the potential to share a gaming experience with someone else.

A solution: emulation
An emulator is a piece of software that simulates the functions of another system. In theory any type of
computer system could be emulated in software. The downside of emulation is performance, because the host
system must be considerably more powerful than the target.

The problem defined 91


Issue 22
Most emulators are of one of two types: they are either orientated towards the running of serious applications
or the running of games. Emulators designed to unlock access to the library of serious applications on a
foreign platform usually focus on execution speed. Game oriented emulators tend to place greater importance
on aesthetic accuracy.

As an emulation target, the PC is a relatively straightforward one.

When IBM created the original PC, they made the decision to build it out of off-the-shelf components. This
led to the design being comparatively open, a fact which allowed other manufacturers to create PC clones. As
a result, the PC architecture is extremely well documented.

Emulator vs real hardware


Anyone who wants to run old games faces a dilemma: should they emulate it with software or attempt to
obtain the real hardware and run that?

For a lot of hobbies that involve a collection, the physical object and its idiosyncrasies are part of the fun, so
running a program isn’t always as good.

However, an emulator like DOSBox offers many conveniences that would not be possible with a real,
physical, vintage PC: unlike a real computer, DOSBox is free, takes up no space and requires no physical
maintenance; DOSBox allows the user to specify a system with many possible add-ons, and at no extra cost;
using DOSBox, the user can perform all of the file maintenance within the host operating system.

In addition, DOSBox is able to actually enhance some aspects of the original games.

Introducing DOSBox
DOSBox attempts to recreate the character and feature-set of a period-correct vintage PC.

DOSBox is a cross platform application and can be run on Mac OS X, GNU/Linux and Windows, amongst
others. Users of all platforms can obtain the latest version, as a free software download, directly from the
DOSBox website. As it exists within the package repository of most popular distributions, GNU/Linux users
might prefer to install it via their package manager.

It’s worth mentioning that DOSBox has an enthusiastic and active community behind it. People sometimes
forget to check out the associated community before investing the time needed to learn a new piece of
software. For one thing, it’s easier to get help when you’re stuck if the community is vibrant and supported by
decent forum facilities.

The DOSBox website also hosts a searchable games database that documents the level of success that users
have had with various games.

What is emulated?
Conceptually, the components of a PC could be split into three parts: the hardware, the operating system and
the applications. DOSBox simulates the hardware of a i486 compatible PC with a sound card and VGA
graphics. It also provides a built-in DOS-like operating system substitute.

The CPU
The upper performance limit of DOSBox depends upon the overall processing power of the host machine.
Using some subjective testing, I estimated that my modest single core 1.7GHz AMD equipped PC allows
DOSBox to emulate a PC equivalent in performance to a low-end 486. This makes a game like Doom, for
example, very playable.

92 Introducing DOSBox
Issue 22
In theory, there is no limit to how fast the emulated PC could go if you had a sufficiently powerful computer
on which to run it.

DOSBox has two modes of CPU emulation: “Normal” and “Dynamic”. Normal mode is slower but more
rigorously compatible. Dynamic mode gives the emulator a considerable speed boost but might break
compatibility with some games.

When running vintage games, a facility to slow down the emulator is often important. Many older games were
designed in a short-sighted manner, and as a result, run too quickly on later machines. So for example, some
games that were created for a 286 class machine ran unreasonably quickly on a 386. In DOSBox, a key
combination is used to “throttle” or slow down the emulator.

The memory game


DOS based PCs had quite a complicated memory layout, and as a result, the DOS gamer had to become a bit
of an expert in memory configuration.

As DOSBox automatically simulates the different memory standards, nearly every game should find enough
memory of the type that it needs, without any manual configuration of the emulator. This is another advantage
of playing games in DOSBox rather than on the real hardware.

Graphics support
DOSBox emulates all of the common graphics adaptors from the early four colour CGA all the way through
VGA and up to Super-VGA. This comprehensive graphics adaptor support means that DOSBox can
accommodate everything from the earliest PC games to the final DOS releases.

As an aside, it’s worth noting that in the early days of PC gaming, other, cheaper home computers were ahead
of the PC in terms of graphics power.

Graphics scalers
DOSBox is even able to improve upon the original graphics quality. It supports a number of methods that
intelligently increase the resolution of the original source graphics. These filters are referred to as scalers.
DOSBox supports a number of scaler types and the choice of filter normally represents a trade-off between
performance impact and quality. Some of the scalers are far better than the “texture blur” effects of earlier
technologies and honestly do give the impression of extra detail.

This is another advantage of using emulation as opposed to running the game on the real hardware.

Figure 1: Original and scaler side-by-side

Click on figure 1 and compare the two screenshots to see the level of improvement that a scaler can bring.
Notice the pixelization around the diagonal edges and the text of the unprocessed image.

The CPU 93
Issue 22

Sound
The first PCs had support for a simple monophonic sound generator connected to an internal speaker. As with
the graphics, the early PC was inferior to most games-orientated home computers of the time. Manufacturers
were quick to develop add on cards that improved the sound quality.

The most important cards emulated by DOSBox are:

• Ad Lib—A very successful early standard. This card offered facilities for synthesised music and
simple sound effects.
• Sound Blaster—This card was, effectively, the successor to the Ad Lib sound card as the standard
card for PC gaming. It featured basic digital sample playback in addition to all of the facilities of an
Ad Lib card.
• Sound Blaster 16—Improvements in sound quality.
• MIDI pass-through—the MIDI (Musical Instrument Digital Interface) support of DOSBox allows you
to route the sound of a game into an external MIDI synthesiser or a high quality software synthesiser
on the host operating system.

DOSBox emulates all of these cards and a some other, obscure cards, so the user has to decide which card to
use.

If the game supports it, any of the Sound Blaster cards are a better pick than the Ad Lib because they have all
of the facilities of the Ad Lib. The Sound Blaster 16 was widely supported in later games and had all of the
facilities of the original Sound Blaster and the Ad Lib.

If the game supports MIDI for its musical output, this has the potential to be of the highest quality.

Note that DOSBox emulates a PC that has all of these sound cards installed at the same time. Most DOS
games make use of a setup utility to tell the game which sound card to support. It’s up to the user to use this
utility to configure the game.

As for quality, the sound support is top notch. Back in the day, I spent many hours playing games that used
the real sound cards, and I can confirm that the simulation offered by DOSBox is very accurate indeed. Most
of the old sound cards were quite poor from an electrical standpoint, so it’s quite possible that DOSBox’s
output through a good quality modern card could exceed the quality of the original device.

Tip: If the DOSBox sound breaks up during gameplay, try throttling the emulator by a few percent. This frees
up some resources on your computer for sound generation.

DOS
DOSBox provides a built-in version of DOS that is similar enough to classic DOS to run most games. This
DOS replacement provides a considerable subset of the features of “real” DOS alongside some extra features
that directly control the emulator.

DOSBox in use
When the emulator first starts up, it presents a familiar DOS prompt along with some helpful start-up
information.

94 Sound
Issue 22

Figure 2: DOSBox starting up under Kubuntu Linux

Games are loaded in the same way that they were in the old days: using the standard DOS file management
commands, the user navigates to the directory that contains the game files and then types the name of the
program file.

Controlling the emulator


Control of the emulator itself is achieved through special DOS commands, key combinations, and a
configuration file. This is one of the few shortcomings of DOSBox, as most emulators now offer a more
sophisticated GUI. For example, it’s possible to become a bit stuck if one allows the emulator to grab both the
keyboard and the mouse at the same time, as there is no way of knowing the key combination needed to
release the mouse!

The developers were forced to make choices between improving ease of use and adding features that allow
more games to run, and I wouldn’t describe DOSBox as an awkward program to use. However, it’s
undeniable that some other emulators make DOSBox’s runtime control and configuration features seem
old-fashioned.

Front ends
The relative terseness of the user interface experience has prompted a number of third parties to develop
various front-end utilities. These front-ends typically give a user friendly interface to the configuration of
DOSBox and the management of a game collection. Utilities such as DOS Shell—not to be confused with the
old MS-DOS file manager of the same name—give simple point and click access to game launching. In
addition to global configuration and game launching, DOS Shell can associate each game with its own custom
settings.

Figure 3: The DOS Shell front end running under Windows

DOSBox in use 95
Issue 22
As GUI launchers for DOSBox exists for nearly every supported platform, some might argue that the
DOSBox developers are right to concentrate on core functionality rather than a pretty user interface.
Unfortunately, none of the GUI front ends can offer much run-time control over the emulator.

The command line interface


Typing intro at the command prompt gives the user a few pages of helpful information about the use of
DOSBox.

One of the first things most users will want to do is to point DOSBox towards the directory that contains their
DOS games. Mapping a DOSBox virtual drive to a real directory on the host machine is achieved by using the
mount command. Using Linux, the command sequence mount c ~/dos_games maps the the directory
dos_games in my home directory to the C drive in the emulator.

The mount command also also allows the user to setup CD ROM access from within the emulator. This
mapped CD ROM drive can be an actual, physical CD ROM drive, a directory on your hard disk or an ISO
dump of a CD ROM. DOSBox can also mount floppy and hard disk images.

The documentation covers the use of the mount command, along with the other DOSBox commands.

Save states
The second feature that DOSBox is missing is the ability to manage save-states. Some emulators have a
facility to freeze the emulation and to save the state of the emulator to a file. Later, the user can restore the
save-state and continue from where he or she left off.

Some might argue that, as there were no practical limits on game saving imposed by PC hardware, a game
that does not allow the player to arbitrarily save at any point represents a deliberate design choice by the game
developer. Still, it’s a useful facility to have.

Getting the games


Before you can make any real use of DOSBox, you must obtain some games. Unfortunately, in nearly all
cases, it is impossible to buy brand-new copies of DOS-era games, and such games can only be bought from
suppliers of second hand goods, such as eBay.

The DOSBox documentation goes into detail on the subject of mounting actual physical media from within
DOSBox.

Abandonware
If you can’t source a physical, second-hand copy of a game, another option is to search for it on-line. Formally
commercial software that has been made available for free download is termed abandonware, and
abandonware games occupy a legal grey area. However, most software companies turn a blind eye to what
are, technically, violations of copyright when it concerns games that no longer have any commercial value.

A Google search for the title of the game along with the word “Abandonware” is often a good starting point
when searching for specific game.

If you’re not looking for a specific game, there are many sites, such as The Home Of The Underdogs and
C-DOS Abandonware that contain catalogued and rated collections of games for browsing and direct
download.

What I wouldn’t run on DOSBox


As good as DOSBox is, there are certain games that I would use other methods to run.

96 What I wouldn’t run on DOSBox


Issue 22

Adventure games
ScummVM and Free SCI are two emulators dedicated to running the point and click graphical adventure
games created by Lucas Arts and Sierra. These specialised emulators are less resource intensive than DOSBox
as they simulate only the functions needed to run the game rather than emulating an entire computer. They
also have some extra features and a user interface tailored to the running of that specific class of game.

ScummVM even has some support for games that were not made by Lucas Arts, so if you’re thinking of
running a point and click adventure, it might be worth looking these two up before trying the game in
DOSBox.

If text adventures are your thing, it might be worth searching on the internet to see if there is a dedicated
emulator for the game that you want to run. The actual programming behind a text adventure is relatively
simple, and as a result, most companies used one of a few different interpreters for all of their games. Most of
the common interpreters have been rewritten and updated and are available as free software. As with the
graphical adventure emulators, these emulators are relatively lightweight and offer some enhancements
specific to the class of games that they are designed to run.

First person shooters


A number of the classic, first person shooters have had their engines rewritten to make them run on modern
computers. Game engine updates exist for Doom, Duke Nukem 3D and Quake, amongst others. As is the case
with adventure game interpreters, reworked game engines for first person shooters generally contain many
enhancements over the original game.

Windows Games
Some people have had success in installing Windows within DOSBox. However, I wouldn’t recommend
using DOSBox for running Windows games. DOSBox is optimised for running DOS games and there are
other emulators that are better at running Windows and therefore Windows games.

If you would like to run Windows games from within an emulated environment, I would recommend looking
up an emulator such as Qemu or VMware. These emulators offer better performance than DOSBox when it
comes to running Windows. As I stated above, DOS games need accurate emulation of real PC hardware;
Windows games don’t care about the details of the underlying hardware as they benefit from hardware
abstraction.

Earlier generations of Windows games are beginning to falter when run under the most recent versions of
Windows. So, even Windows users might be able to make good use of emulators such as these.

Conclusion
DOSBox was created to to enable people to play DOS era games on a modern system. Without something like
DOSBox, many of these games would only be accessible to people willing to acquire and maintain a vintage
PC.

As well as enabling the games to run, DOSBox can even enhance the original games while running them
within a protected, modern environment. Although speed isn’t the main focus of DOSBox, even computers
that are a few years old should be fast enough to run all but the final DOS-era games.

DOSBox does a nearly perfect job apart from the two, relatively minor criticisms that I outlined above: the
user interface could be a bit more sophisticated, and save states would be a welcome feature.

DOSBox is available from the DOSBox website.

Conclusion 97
Issue 22

Biography
Michael Reed (/user/45137" title="View user profile.): Michael Reed is a writer, musician and geek. See his
website for thrilling stories of his continuing adventures. http://www.unmusic.co.uk/

Copyright information
This article is made available under the "Attribution-NonCommercial-NoDerivs" Creative Commons License
3.0 available from http://creativecommons.org/licenses/by-nc-nd/3.0/.

Source URL:
http://www.freesoftwaremagazine.com/articles/dosbox_multiplatform_pc_emulator

98 Conclusion
Issue 22

Published on Free Software Magazine (http://www.freesoftwaremagazine.com)


Configure a professional firewall using pfSense
Set up multiple subnets to share your broadband Internet with
your neighbors and split the cost
By Sloan Miller
PUBLISHED: 2008-06-26

The guide will take you through the setup of the pfSense firewall with one WAN interface, one LAN interface
and one Opt1-WiFi Interface.

This guide was written for Linksys, Netgear, and D-link users with no firewall or router experience. No
experience is needed with FreeBSD or GNU/Linux to install and run pfSense. When you are finished,
management of pfSense will be from a web interface just like any of the SOHO firewall/router appliances.

pfSense is a web-based firewall project that is similar, in terms of functionality, to the software in firewall
appliances sold by Linksys, Netgear and D-Link. pfSense covers all the basic requirements offered by those
appliances but offers so much more—in fact, it is really in a class by itself since it would be very difficult to
find a commercial alternative that would provide what pfSense has to offer (or, anything cheaper than
$2,000–$5,000).

As mentioned above, in this article I will explain how to setup the pfSense firewall with one WAN interface,
one LAN interface and one Opt1-WiFi Interface. This set-up allows you to offer wireless Internet to the
surrounding community. The WiFi subnet will not be able to access the LAN: it will be able to connect to the
Internet only. You can choose to eliminate the Opt1-WiFi setup: this will leave you with a firewall more
similar to the “conventional” appliances.

One of the very unique uses for your new firewall could be to offer wireless Internet to your neighbors
at a reduced cost

One of the very unique uses for your new firewall could be to offer wireless Internet to your neighbors at a
reduced cost. This connection can be via an encrypted access point, where the network key is only given to
approved users, or an open access point where you control access to the Internet with the captive portal
function built in to pfSense. A portal landing page will be presented whenever a user tries to connect to the
Internet at the beginning of the session. Each user will need to have their user name and password entered into
the firewall in advance of the first connection.

There are many advanced features that pfSense can offer with one-click installation which are listed at the end
of this article. See the pfSense’s web site. There is an active user forum and an pfSense Wiki.

Two good reasons to use pfSense


1. pfSense is a very powerful and stable project with advanced features. Users of pfSense have reported
that it performs well even with hundreds of computers operating behind the firewall. pfSense has all
the features of the SOHO units and much more. You can have multiple network subnets separate from
each other using firewall rules. For example, you could have separate subnets for each business
function; or separate Accounting, Marketing, Sales, and R&D from each other, while giving each one
access to the Internet; or set up a HotSpot for your business, allowing users to access the Internet but

Two good reasons to use pfSense 99


Issue 22
not the company LAN (which usually contains a POS (Point Of Sale) system and/or proprietary
information and non public computer systems).
2. If you are an experienced FreeBSD, GNU/Linux or Unix user you may wish to add applications from
the FreeBSD repository. While running additional applications on a firewall can increase your
exposure to potential risk of being hacked, it can still be extremely useful to add a few applications to
pfSense. Once you get pfSense installed you can find a list of authorized ports under the System
Packages tab. These can be installed with one click. The FreeBSD.org packages are added by the user
via the shell the way it has been done for years. These FreeBSD.org packages are not officially
supported by pfSense.

Install Guide
Download, ISO preparation, and interface selection.
Here is the link to the pfSense download area This will take you to a mirror near you. This CD we will install
from is a Live CD. A Live CD will allow you to test your hardware and pfSense without actually installing
onto the hard drive. You will need to change your BIOS to boot from the CD and then boot from the CD
image that you create from the ISO image. This CD is also an installer CD—more on this later.

Users of pfSense have reported that it performs well even with hundreds of computers operating behind
the firewall

The ISO image for this guide will be pfSense-Full-Update-1.2-RELEASE.tgz. You will first need
to decompress this file using gzip to get to the ISO. Then, create the bootable CD. A good program to use is
cdrecord via the GNU/Linux command line.

Use this command:

sudo cdrecord -v speed=20 dev=/dev/sr0 pfSense-1.2-RC3-LiveCD-Installer.iso

If you use Linux, your device (dev) may vary. There is also a good utility for Windows for creating ISOs
called Deep Burner, which is freeware, but it’s not released under a free license.

Now that you have set your BIOS to boot from CD and you have created your bootable CD, you can boot into
pfSense on your PC. You will need to have at least two network cards installed—although I recommend three.
The third is necessary for the WiFi subnet, giving you:

• one for the WAN (your ISP);


• one for your private LAN;
• one for your WiFi internet-access-only subnet.

Check the FreeBSD hardware compatibility list first to make sure your hardware is supported.

You can now boot into pfSense. As the bootloader comes up the Free BSD screen 7 options are listed. You
can wait for the default option (1) to boot up. Take a sheet of paper and write down the initials for the “valid
interfaces”: you will need them in a moment. Mine are fxp0, fxp1, and fxp2. The next choice you will be
asked to make is “Do you want to set up VLAN’s now [y|n]?” Select “no” or “n”.

Then you are asked to “Enter your LAN interface name”, enter one from the sheet of notes you just created. I
enter ‘fxp1’.

Next you are asked to “Enter your WAN interface name”. I enter fxp2. The next option is “Enter the
Optional 1 interface name”. Here I enter my last ‘fxp0’.

You should then see:

The interfaces will be assigned as follows:


LAN -> fxp1
WAN -> fxp2

100 Install Guide


Issue 22
OPT1 -> fxp0

Do you want to proceed [y|n]?

(Make sure you enter “y” here).

pfSense is now running in RAM and almost fully functional. If you wish you may plug your LAN interface
into a hub or switch and connect via the web interface. pfSense is by default assigned an IP of 192.168.1.1.
Open your browser and check it out, or proceed to the hard drive install. To run from RAM you can skip to
the “Web interface configuration” section of this guide.

pfSense is now running in RAM and almost fully functional

If you choose to login, the user name is “admin” and the password is “pfsense”.

Hard drive install


Here is how to complete a hard drive installation.

Transition to the console in order to begin the “hard drive installation”. This section is “pfsense console
setup”: Select “99”.

This is a curses based install. It works best if you use an entire hard disk. If there is any data on the disk, make
sure that you have copied it to another location. You can, as a rule of thumb, accept the default settings that
are presented during the curses-based installation.

Pictures of the pfSense installation are available in pfSense’s forums.

Here is a list of operations, shown graphically by the tutorial:

• Note: If you would like to see the instructions as a Wink tutorial, you can see pfSense’s Wink tutorial.
However, the instructions here follow.
• Remember to remove the CD from the drive when you reboot.
• After rebooting, you should be presented with the “pfsense console setup” for a second time. At this
moment you can unplug your monitor cable and manage this firewall via a browser, or you could
select option 8 and explore it using a shell.
• Make sure your computer’s interface is in the 192.168.1.0 subnet, because pfSense’s LAN interface is
by default 192.168.1.1. The default username and password for the web GUI are “admin” “pfsense”.
• Select System→Setup Wizard now.
• This wizard will guide you through the initial installation of pfSense. Click “next”
• General Information: enter primary and secondary DNS (name servers) if you wish. Click “next”
• Select TimeZone and then Click “next”
• On the Wide Area Network Information page scroll down and click “next”
• On the LAN interface page you may select a Subnet IP address of your choice or stay with the default
of 192.168.1.1. If you stay with the default, you will need to configure your computers so that they
are on the same subnet, or have DHCP enabled on your network PCs.
• The password page: you should select a password that consists of at least 8 letters and numbers,
lowercase and uppercase. Save this new password in a secure place. Now that you have selected a
new password you will be required to login again.
• Go to “Interfaces” tab on the top row and select “Opt 1: Enable the opt 1 interface”. Enter the IP of
the Opt 1 interface under the IP Configuration section, “192.168.2.1”. Scroll to the bottom and select
“save”
• On the top bar, select “Firewall→Rules”; select the “Opt 1” tab; and click on the plus to add a rule.
Change protocol to “any”. Under “Destination”, check the “not” box. In “Type”, select “LAN
subnet”. In “Description”, enter allow all to net - > ! LAN subnet. Save the changes,
and then in the next window, select “Apply Changes”.
• Go to the Top row and select Status→Interfaces
• Move the cable from your current firewall to the WAN port for pfSense and connect the LAN cable to
the LAN port on you new pfSense firewall. At this point you should power cycle your Broadband

Download, ISO preparation, and interface selection. 101


Issue 22
provider’s equipment (turn it off for 30 seconds, then turn it back on). Sometimes when your MAC
address changes on your firewall, your broadband provider will need to be involved to reset your
configuration.
• Under the WAN interface section, you may see your external IP address. If this is the case you are,
most likely, good to go.
• Go to the “Services” tab, then “DHCP server”. Select the “Opt 1” tab and enable the DHCP server for
that interface. In the “Range” section, enter the IP address range for your DHCP server.
• Scroll to the bottom to select “save”, and you are ready to go.

Setting up your Wi-Fi for the Opt1-Wi-Fi interface


Run a cat-5 cable from the Opt1-Wifi interface that you set up earlier to the access point you plan to have on
its own subnet. This subnet is separated from your LAN via firewall rules. This AP will connect directly to the
internet and have no access to your LAN. Many of the SOHO firewall/routers have a default IP address of
192.168.0.1 or 192.168.1.1. Change this to a different IP address so it will work on this install, and not have
the same IP address as your new pfSense box. I selected 192.168.2.5.

You can use this same process on your LAN for a second access point with an IP address on the same
LAN subnet that is encrypted

Then, disable the DHCP server on this appliance so your pfSense box can now hand out the addresses. This
way when you are looking under Diagnostic→ARP tables you can easily see who is on your connection.
Enable the DHCP server under the Services→DHCP server, tab click on the Opt 1 interface, and on the top,
check the box “enable DHCP Server”. You will need to set the Range of the DHCP server which will regulate
how many IP addresses you will give out.

The key to this functioning properly is to make sure that when the firewall rule is set up for the Opt1 Wifi
interface is that the protocol section be set to “any”. By default when the rule is set up it is TCP. If this is not
set properly access will be limited and for our purposes would not work.

You can use this same process on your LAN for a second access point with an IP address on the same LAN
subnet that is encrypted. This wireless network connection is for your use only, not your neighbors. Disable
the DHCP server on the second Access Point and let pfSense handle that function. You can regulate access by
using the built in captive portal capability found under Services→Captive Portal. An equally effective way for
an encrypted network is to only give your network key passphrase to select people.

Get help
If you encounter difficulty you can post questions related to the pfSense forums.

Advanced Features for pfSense


This section outlines some of the advanced features available in pfSense. These are features that in the past
were generally available on proprietary and expensive firewalls.

• Traffic Shaping - This gives you the ability to prioritize traffic. For example if you use VOIP you will
want to give that top priority. Also you may want to move torrent traffic down the priority list so that
it does not slow down web surfing traffic
• Clustering - Linking two or more computers into a seperate network to take advantage of parallel
processing of those compters
• Load Balancing - If you are running multiple web servers you can spread the traffic evenly to each
server. This will help to prevent any one server from becoming overburdened
• Failover - You can set up two firewalls with pfSense if one fails the other will automatically kick in.
If you have multiple Internet connections and one fails the other will take over
• Captive Portal - Control Access to the internet. Like coffee shops use when they offer free WiFi
• The below services will install with one click in pfSense. Installing these features is a snap. There are
tutorials available for some of the below packages on the pfSense wiki. If no tutorial is available help

102 Advanced Features for pfSense


Issue 22
is available on the pfSense forums
• Snort - Lightweight network intrusion detection system
• Squid - High performance web proxy cache
• FreeRadius - Implementation of the RADIUS protocol
• IMSpector - an Instant Messenger proxy with logging capabilities
• nmap - A utility for network exploration or security auditing
• ntop - Shows network usage in a way similar to top
• Darkstat - A packet sniffer and a network statistics gatherer and much much more.

pfSense will also allow you to add packages from the standard FreeBSD repository, although any unofficial
packages are not supported by pfSense.

Resources
• HOWTO Add a Wireless Interface. You can skip this tutorial if you are planning on adding an
external Access Point as outlined above. This tutorial is for those who want an internal WiFi interface.

*Graphical Tutorials

Biography
Sloan Miller (/user/47747" title="View user profile.): Open Source Software user for about 12 years. Patiently
waiting for Open source software to take over the world.

Copyright information
Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided
this notice is preserved.

Source URL:
http://www.freesoftwaremagazine.com/articles/configure_professional_firewall_using_pfsense

Resources 103
Issue 22

104 Resources

You might also like