You are on page 1of 100

NO.

1 FOR RASPBERRY PI
PYTHON MASTERCLASS
BUILD AN ONION PI
INTEL VS RASPI

www.linuxuser.co.uk

THE MONTHLY MAGAZINE


FOR THE GNU GENERATION

HAS THE
RASPBERRY PI
MET ITS MATCH?
MinnowBoard: Review, Intel interview & spec face-off
VS Build
extensions
Sync files for XBMC
Make your own
with Unison with Python
The quick & reliable
way to save data

The other half


of WordPress
ISSUE 131

The story of co-creator Mark Little

Studio
Android
Masterclass Create a ALSO INSIDE
LaTeX docs with LyX
database with Master the Vim editor
Googles new IDE is here get started today! LibreOffice 14+ pages of reviews
Raspberry Pi 32.99
Inc VAT

Model B - 512MB with code SC


1
8GB NOOBS SD Card 27.49 E
313058
x Vat

NOW IN STOCK!
5MP Raspberry Pi Camera
19.24 16.03 Ex Vat
code SC1302358
visit cpc.co.uk for more information

Get everything for your projects...


Full range of project accessories
Kits and Cases
Expansion, Breakout and Prototyping Boards
Vast Range of Components
Y
IV E

WiFi Dongles & HDMI to VGA Adaptors


R
L E

Video and Audio Leads


E
E R

k ,
.u ply

Keyboards, Mice and Monitors


co ap
D F

cpc.co.uk
GPIO Ribbon Cables
c. s
cp n
t tio

Programming and User Guides


si i
vi nd
o
C
Welcome
to issue 131 of Linux User & Developer Get
Linux User
Mihalis Tsoukalos has over 15 years of
This issue
Your team of Linux experts

UNIX system administration and


programming experience and has for 4.19
been using Linux since 1993. He is
also proficient in Oracle database MinnowBoard exclusive per issue
administration, Cisco IOS and
Cocoa. In this issue Mihalis shows Build add-ons for XBMC Page 32
us how to sync files with Unison, a
useful open source CLI tool (42-45). Sync your files with Unison
Himanshu Arora is a software programmer, Get started with Android Studio
open source enthusiast and Linux
researcher. His articles have been Welcome to the latest edition of Linux User &
featured on IBM developerWorks
and Computerworld among others.
Developer, the UK and Americas favourite open
He also blogs at mylinuxbook.com. source and Linux magazine.
This month he shows us how to
make the most of Vim with his
When youre trying to make the best Linux and open
expert guide starting on page 62. source read in the world, theres nothing more useful
than feedback from readers. Theres little point us
Michael Reed is a technology writer, and hes
been hacking away at Linux for being here if we dont aim to give you a healthy dose
over 15 years. He specialises in of what you want, so we pay close attention to what you
desktop Linux solutions among
other things. In issue 131 Michael have to say. But what have you been saying? After collecting,
shows us how to get started with formatting, graphing and a lot of stubble scratching, its clear
databases using LibreOffice its
easier than you might think. See many of you want more tutorials, bigger reviews and more
his work on pages 34-37. introductory and intermediate developer content.
Jon Masters is a Linux kernel hacker who has As youll see this issue, weve dedicated more pages
been working on Linux for some to tutorials and guides than ever before and weve even
18 years, since he first attended
university at the age of 13. Jon lives
reformatted our distro reviews to make them more useful.
in Cambridge, Massachusetts, We still need your help, though. If youre keen to learn more
and works for a large enterprise
Linux vendor. You can find his
about development in the open source field, we want to know
indispensable Kernel Column on what languages and frameworks you care about. Weve been
pages 22-23 this month.
focusing very heavily on Python in recent months and intend
Gareth Halfacree is our new resident news to continue with this, but would you like to see Qt, Vala and
reporter and brings us the latest C++ here too, or something else entirely?
from all over the open source
ecosystem, starting on page 14. Let us know on Facebook and Twitter or simply drop me an
Also this issue, Gareth speaks to email directly at russell.barnes@imagine-publishing.co.uk.
Intel about its new dev platform
MinnowBoard on page 6. You can
also find his review of this potential Russell Barnes, Editor

Get in touch with the team:


RasPi-beater on pages 12-13.

Rob Zwetsloot studied aerospace engineering


at university, using Python to
model complex simulations in
class. Along with tutorials, reviews
and more this issue, Rob tells us
linuxuser@imagine-publishing.co.uk
which IDE we should be using
(pages 72-77) and walks us through Facebook: Twitter: Buy online
the build process of an Onion Pi
(pages 46-49).
Linux User & Developer @linuxusermag

Visit us online for more news, opinion, tutorials and reviews:

www.linuxuser.co.uk
3 Issue 131
NEW OPPORTUNITIES WITH NEW

DOMAINS
NEW!
Choose from over 700 new top-level domains! Create a short, memorable
web address that perfectly fits your business or website theme, like fashion.blog,
kitchens.online or john-smith.london. You can also make your website easier
to find by getting new extensions for your current domain.
With almost 20 million registered domains, 1&1 is Europes market leader for PRE-ORDER

FREE
domain registration. Thanks to integrated forwarding features, domains
registered with us can be quickly and easily connected with any website, no matter
which web hosting provider you use.
Find out more at 1and1.co.uk
WITH NO OBLIGATION!*

DOMAINS | MAIL | WEB HOSTING | E-COMMERCE | SERVERS 1and1.co.uk


* Pre-ordering a domain name is not a guarantee that the domain will be registered. If your requested domain has already been pre-ordered, you will be added to a waiting list for that domain.
Exclusive Intels big fish in a little pond

n Scott Garman is a Yocto Project engineer


at Intel, and the companys evangelist for
the MinnowBoard

Intels big fish


in a little pond
We chat to Scott Garman about Intels first foray into the world
of Linux-powered open hardware development systems
Scott Garman, the man Intel has appointed Open Source Technology Center, Garman has at its heart a low-power 32-bit Atom processor,
as the evangelist for its first steps into open already given plenty back to the community. Hes the board is designed as a development platform
hardware development, has a history of responsible for Yocto-related training materials, to bring the flexibility and familiarity of the
embedded development. Im not a hardcore including one of the most popular screencast x86 instruction set architecture to embedded
kernel hacker, he tells us during an interview to introductions to the project, and is now leading systems and to do so at a low cost.
commemorate the launch of the MinnowBoard the effort to introduce the first open hardware Most surprisingly of all, the device is open
single-board computer, but a generalist who platform designed with Yocto firmly in mind: the hardware: all specifications, schematics, board
enjoys working with the big picture in mind. Intel MinnowBoard. layouts and firmware packages are available for
A software engineer for the Yocto Project, a The MinnowBoard, reviewed on page 12, download and reuse under a permissive licence
collaborative effort to make the development owes a clear debt of gratitude to devices like the a first for an Intel hardware product. Clearly, this
of Linux distributions for embedded platforms Raspberry Pi and the BeagleBoard. Designed is a departure from the norm, and one of which
as simple as possible, working under Intels around Intels Queens Bay platform, which has Garman is understandably proud.

6 www.linuxuser.co.uk
Intels big fish in a little pond
How the MinnowBoard came about
InTervIew

The open
hardware movement
n Open hardware an offshoot of
open source, where the schematics,
component lists, and even the individual
Gerber files for having printed circuit
boards made are released under
a permissive licence is growing
increasingly popular. Although the
Raspberry Pi, one of the most popular
low-cost embedded development
platforms, is proprietary, many of its
competitors are more open: as well
as the MinnowBoard, the Gizmo, the
BeagleBoard and its smaller BeagleBone
offshoot, the Olimex OLinuXino family,
and the microcontroller-based Arduino
range are all open hardware.
Open hardware can lead to rapid
advances in features and technologies
for the projects that adopt it, but as with
open source software there are risks:
the Arduinos open nature has led to it
being one of the most copied projects
n The MinnowBoard itself around, with Far Eastern factories
is compact yet powerful, churning out illegitimate clones by the
and boasts impressive dozen and misappropriating the projects
trademark in direct contravention of its
I/O capabilities
otherwise extremely permissive licence.

How did the MinnowBoard come about? up this first board. Its turned out to be a great
Id say development in earnest started collaboration and were really pleased with
happening at the end of 2012. MinnowBoard the results.
was an unusual project because of the way In one sense, the Intel team working on this
Intel and CircuitCo [the company behind the is extremely small. At the same time, I wouldnt
BeagleBoard and BeagleBone development want to discount the contributions that many
platforms] collaborated on it. The Intel people have done to help make this happen,
Yocto Project team provided input to help even if they werent involved with the project full-
design the requirements for MinnowBoard time on a daily basis.
around performance, openness, flexibility
and standards. CircuitCo then used an Intel What led to the decision to choose the Queens

To my knowledge, reference design the Queens Bay platform


and adapted it as needed. They also
Bay platform, with its Tunnel Creek Atom
processor, in the MinnowBoard?

MinnowBoard is manufacture and sell the MinnowBoard, so


its primarily their product, not Intels. The result
Two main issues led us to use Tunnel Creek
CPU for MinnowBoard. One, we were looking

the first hardware


is a win-win situation where our team got a for longevity of the platform. Going with an
great development platform and more, and open hardware model means that this is

platform designed
CircuitCo has a compelling product platform going to be an attractive board for embedded
to sell. product companies to use and adapt for
Weve been really happy to work with commercial products. I can tell you from

with the Yocto CircuitCo on this, because they understand


the open hardware/open community model so
experience, there is nothing more frustrating

Project in mind well, but we both had plenty of things to learn


from each other during the process of bringing

n Along with the power and reset buttons n The MinnowBoard sits on four stilts to help aid the
on the right, the MinnowBoard boasts four passive cooling of its 1GHz Intel Atom processor
programmable buttons

7 www.linuxuser.co.uk
Exclusive Intels big fish in a little pond

Larger and pricier than the


Pi, the MinnowBoard offers
full x86 compatibility

than developing a successful embedded


product and then finding out that your
components are about to enter end-of-life.
Queens Bay is a platform used in IVI [In-Vehicle-
Infotainment] devices, and was designed with a
long lifespan since people tend to own cars for
a long time. It still has four to five years left in the
products life cycle.
Two, the time to execute was now, so
we werent about to wait for upcoming Intel
platforms to roll out. Tunnel Creek met our main
requirements and was available immediately, so Do you agree that the success of the ARM-
we ran with it. based Raspberry Pi has demonstrated a clear standards.
demand for low-cost development boards The Intel
What advantages does the x86 architecture from hobbyists? Atom CPU provides
used in the Atom processor offer in the Yes, absolutely. One of the things I appreciate plenty of performance for high
embedded space, compared to ARM or other and respect about the Raspberry Pi project computational workloads. It also has
RISC platforms? is that its introducing so many new people strong I/O performance due to PCI Express
Compatibility is likely the biggest advantage. to embedded Linux development. It used to powering its Gigabit Ethernet and SATA disk
Linux originated on the Intel 386, and whether be that embedded was a niche thing that features. We also make PCI Express available
youre working on embedded or desktop software engineers specialised in, and now the through MinnowBoards expansion connector
applications, the toolchain, libraries etc were embedded Linux community is becoming much to enable high-speed I/O to custom hardware
designed on and are pretty much guaranteed to more diverse, especially with younger people. I projects, for example interfacing with FPGAs or
work on x86. love that. other hardware.
Performance is another significant one. The MinnowBoard can be used for fun hobby
Countless person-years have been put into What does the MinnowBoard offer that other, projects, yet scales up to higher workloads. Its
optimising compilers such as GCC to take full more established development boards lack? expandable via several PC and embedded bus
advantage of x86 platforms, so you can leverage MinnowBoard stands out in its combination standards, and offers an environment for custom
that to its greatest benefit. of performance, flexibility, openness and firmware development.

The MinnowBoard includes eight GPIO pins With Gigabit Ethernet and a real-time clock, it pulls ahead
and a dedicated expansion port for Lures of the Raspberry Pi

8 www.linuxuser.co.uk
Intels big fish in a little pond
How the MinnowBoard came about
INTERVIEW

The open hardware model is Queens Bay


The code name for the combination of an
Intel Atom E6xx-series processor with

very attractive in empowering the EG20T controller hub (code-named


Tunnel Creek and Topcliff respectively),

your customers
Intel launched the Queens Bay platform
in 2010 with the embedded market firmly
in mind.
Initially, the company targeted in-car
MinnowBoard includes PC architecture Its still a bit early for me to have good visibility computer systems for navigation
standards including PCIe, USB and SATA, into this, as the board has only been available and entertainment so-called
infotainment devices but claimed
as well as embedded standards such as SPI, for about three weeks [at the time of the
the platform would be equally at
I2C, GPIO and even [a CAN bus] for automotive interview]. As I hear about community projects, home in gaming, communications,
applications. It was designed with the Yocto I do intend to highlight them on our social point-of-sale, industrial and digital
Project in mind, which is an industry-wide media channels. signage applications.
standard for embedded Linux. I am aware of someone who plans to use The Tunnel Creek family of processors
a MinnowBoard as part of a quality control are not true system-on-chip designs,
offloading much of the circuitry to the
The MinnowBoard is open hardware how system for 3D printers by making use of
EG20T chip, but do include the CPU, a
important do you think that will be to its computer vision capabilities. Ive also heard graphics processor supporting up to
success in the market? that folks in the FGPA design community are two simultaneous displays, an audio
The open hardware model is very attractive quite interested in the MinnowBoard due to its controller and a hardware video codec
in empowering your customers and high-speed expansion capabilities. Theres also on a die some 46 per cent smaller than
allowing them to innovate in ways you a group of students interested in building out its predecessors.
Until the launch of the MinnowBoard,
cant anticipate. Since people learning exercises on the MinnowBoard, as a
however, using Queens Bay in hobbyist
are free to reproduce way to advance their embedded design skills. applications was almost impossible:
and customise the Intels official development board was
MinnowBoard, the sky Intel has something of a mixed history with the provided only to registered hardware
is the limit with this open source community - in particular in failing partners, and came with the expectation
boards potential. I think to release graphics drivers for selected Atom that you would be placing an order for a
few thousand processors once you had
this will be fundamental processor models. With the MinnowBoard being
finished your design.
to [its] success. truly open, does this signal a shift in attitude
Keep in mind that towards the open source and open hardware
open hardware is communities at Intel? the embedded input/output capabilities and
meaningful not only if the The Open Source Technology Center at Intel community of Arduino will open up a lot of
design files are available, but when is full of incredibly talented, well-known and interesting possibilities.
all the parts are available through accessible passionate people who care deeply about
distribution channels and the boards price is openness. In recent years this group has How critical is Linux and the Yocto Project to the
not subsidised. If someone wants to rebuild it, grown dramatically in both size and influence, MinnowBoards success?
or rebuild something similar, they can at about and it reflects the reality of the increased We designed the board to be a Yocto Project
the cost its being sold for now. Not many boards influence open source plays in the global development platform, and Yocto produces
can offer that potential. software ecosystem. embedded Linux distros. So its pretty core to our
Intels Core graphics have open source purpose. It was the primary motivation behind the
What made Intel get involved in hobbyist-level drivers that work with hardware acceleration, project itself to my knowledge, MinnowBoard
embedded computing development? and the upcoming Bay Trail Atom platform is the first hardware platform designed with the
We wanted MinnowBoard to become a useful makes use of it. This will address the issue Yocto Project in mind. But most people using
platform for Yocto Project development that you mentioned with graphics drivers on Atom. the MinnowBoard may have no knowledge of or
encouraged experimentation and the pursuit Im looking forward to this, and I think Intel interest in the Yocto Project thats okay, too.
of fun projects in addition to more serious is definitely moving in the right direction in
embedded applications, as a board we would use this regard. Is the MinnowBoard likely to be the first in a
in Yocto Project training courses. And we needed family of open development boards from Intel,
it to be flexible enough so you could do interesting Intel and CircuitCo have published a list of or is it merely an experiment for the company?
things in a classroom-style setting, which lines up current and proposed add-on boards, dubbed There are a lot of people within Intel who are
with what hobbyists want, too. Lures, for the MinnowBoard. Is there a excited about open hardware. I cant speak
particular add-on you would like to highlight? [about] any specific future product plans, but I
With the board now in the hands of early One of the Lures that Im sure will be quite think the future is very, very bright.
adopters, have you seen any particularly popular is the Trainer Lure the one based on
innovative or exciting applications for the an Arduino [microcontroller]. Combining the
MinnowBoard emerge from the community? computational power of MinnowBoard with

9 www.linuxuser.co.uk
Specifications MinnowBoard vs Raspberry Pi

MinnowBoard Intels Atom-powered


development board is the
first to be Yocto Project-
compatible and runs
Angstrm Linux. While considerably more
expensive than the Raspberry Pi, it utilises the
x86 architecture so offers computational power
more akin to desktop and mobile computers.
Its also a very complete package, offering both
Angstrm Linux on a microSD card and a properly
rated power supply in the box.
However, without decent driver support for
the Intel GMA 600 GPU and a DVI-over-HDMI
video interface (no HD audio or HDCP encryption), The MinnowBoard supports tinkerers with The stilts increase airflow to help keep the
it lacks the same multimedia appeal as the two on-board LEDs and six buttons 1GHz Intel processor (under heat sink) cool
Raspberry Pi.

SATA support brings Analogue audio input is Four stilts and bigger
mass storage within easy
reach of MinnowBoard
a definite step up from the
Raspberry Pi
dimensions mean it
towers over the RasPi
MinnowBoard Specs
Price 162
Dimensions 106 x 115mm
Weight 119g
Operating system Angstrm Linux (Yocto certified)
supplied on microSD
Processor 32-bit Intel Atom E640T
single-core at 1GHz
Video Embedded Intel GMA 600
Max resolution 1366 x 768 (no HDCP encryption)
Memory 1GB DDR2 (shared),
4MB SPI flash (firmware
storage)
Output DVI-over-HDMI (no audio),
analogue audio out
Input Analog audio in, 2x USB,
1x SATA-2, 1x micro-USB,
1x mini-USB, 1x serial console,
SD card slot, 1x micro-SDIO,
8xGPIO pins
Networking 10/100/1000 Ethernet
Real-time clock Yes (no battery installed)
Extras Lure connector with CAN bus,
HD audio, LVDS, IC, 3x PCI
Express, SATA-2, SDIO, SPI bus,
UART, 2x USB
It has fewer GPIO pins, Gigabit Ethernet means MinnowBoard needs
Power 5V at 2.5A (adaptor included)
but includes two LEDs and faster networking great a staggering 2.5A to
four buttons to control if youre planning a server keep its lights flashing

10 www.linuxuser.co.uk
VS
MinnowBoard vs Raspberry Pi
COMPARED

Raspberry PiThe Raspberry Pi has inspired


(Model B, Rev. 2)
thousands to try Linux for the first
time and reinvigorated interest in
bare-metal computing. It opens the
door to the creation of fascinating Internet Of
Things projects and drastically lowers the barrier
of entry for both programming and physical
computing. Its not all plain sailing, though. Its
low-price means the out of the box experience
isnt stellar. One still needs to acquire a microSD
card, an HDMI cable and power supply, meaning
starter packs can retail upwards of 60.
While its raw processing power is left in the
shade by Intels x86 CPU, the Raspberry Pi
continues to amaze users with its remarkable Standard SD card support is good, but high- The Pis small size makes it ideal for hiding
multimedia prowess. speed SD cards are worth the extra expense behind a monitor or stashing in a project box

Raspberry Pi Specs A microSD card The RasPi could really


slot would have been do with a Lure port - even
Price 28
preferable here just two more USB ports
Dimensions 86 x 54mm would be great
Weight 40g
Operating system None included (Raspbian &
others supported)
Processor ARM1176JZF-S (armv6k) The multimedia 26 GPIO pins
single-core at 700 MHz support is means theres
Video VideoCore IV frankly stellar massive scope
Max resolution Full HD with HDCP encryption for tinkering.
No analogue
Memory 512MB DDR2
support,
(shared) though, sadly
Output DMI (with HDCP encryption),
composite RCA,
analogue audio out
Input 2x USB, 1x micro-USB,
SD card slot, 26x GPIO pins
Networking 10/100 Ethernet
Real-time clock No (can be added via GPIO)
The The audio
Extras DSI display connector, Broadcom on the RasPi
JTAG headers, CSI (camera SoC is brilliant, is probably
module) connector, SPI bus, even if it chugs its weakest
I2C, UART occasionally aspect. No mic
Power 5V at 700mA (not included) support either

11 www.linuxuser.co.uk
Review Intel MinnowBoard

The Lure connector, for add- An HDMI port offers DVI video
on boards, carries everything connectivity, but does not carry
from CAN bus signals to three digital audio
PCI Express lanes

Two USB ports


provide connectivity for
external peripherals

Gigabit Ethernet gives


the MinnowBoard powerful
networking capabilities

DEV PLATFORM

Intel MinnowBoard 162.83


($200)
Intels answer to the Raspberry Pi is here but at nearly six
times the price, can it tempt buyers back to x86?
Pros Clearly, the MinnowBoard is no Raspberry Pi. Measuring amount of heat, allowing for passive cooling through a
Powerful, flexible,
open; a familiar
102mm on its shortest side, its significantly larger, requires compact heat sink.
x86 environment a whopping 2.5A from a 5V power supply to run and costs With 1GB of RAM, the MinnowBoard offers a surprisingly
for newcomers
to embedded
almost six times as much as the credit-card-sized Pi. The powerful yet lightweight platform for embedded computing.
development MinnowBoard does offer something the Pi lacks, however: Peaking, during testing, at 7W from the socket, it scored a
full x86 compatibility. respectable 95th percentile time of 11.49ms almost five
Cons At the heart of the MinnowBoard is one of Intels less times faster than the Raspberry Pi at 51.45ms, but still some
Compared to ARM powerful processors: the Atom E640T. Running at 1GHz, way behind the Gizmos impressive 9.87ms score. Add in the
equivalents its
expensive, and its the single-core chip offers a 32-bit x86 implementation fact that the Gizmo can run two threads simultaneously and
performance lags already putting it on the back foot compared to the dual-core its clear Intel isnt going to win on outright performance
behind AMDs rival
Gizmo device 64-bit APU found on rival AMDs Gizmo, the closest device although it has included Hyper-Threading support in the
for comparison while generating a surprisingly small MinnowBoard for pseudo dual-core operation.

12 www.linuxuser.co.uk
Intel MinnowBoard
x86-based embedded development board
REVIEW

A micro-SDIO slot plays host to


a bundled SD card containing the
Angstrm operating system

A small heat sink passively


cools the Intel Atom
E650T processor

Bundled risers lift the board up


in order to allow the processor
room to cool

Technical specs
Operating system Angstrm Linux (Yocto Certified)
Processor 32-bit Intel Atom E640T single-core at 1GHz
Video Embedded Intel GMA 600
Memory 1GB DDR2, 4MB SPI Flash (Firmware Storage)
Dimensions 106 x 115mm
Weight 119g (excluding PSU)
Input/Output DVI-over-HDMI, Analogue audio in & out,
2x USB, 1x SATA-2, 1x USB device, 1x Serial Four switches Also
console, Gigabit Ethernet, 1x micro-SDIO
Extras Lure connector with CAN bus, HD audio,
combine with two user-
controllable LEDs to get
consider
LVDS, IC, 3x PCI Express, SATA-2, SDIO, SPI users started with the
bus, 2x UART, 2x USB boards capabilities
Power 5V at 2.5A

Treating the MinnowBoard as a standard computer, At present, the MinnowBoard ships with a bare-bones
however, misses the point entirely. The device is designed for installation of Angstrom Linux no friendly out-of-box
Sage Gizmo
embedded development, and to help Intel regain a foothold experience here. With full Yocto Project certification, $199 (154.29)
in a market that has become almost completely dominated however, rolling your own OS isnt a challenge and Intel is in Based on an embedded AMD
APU, its far more powerful
by ARM-based systems. Accordingly, it includes eight talks with distributions including Ubuntu to add support for than the MinnowBoard.
buffered general-purpose input-output pins, along with two the boards somewhat unique 32-bit UEFI firmware. Embedded graphics aid
computer performance and
user-controllable LEDs and a set of four switches. Together, Using documentation still in progress from the a bundled expansion board
these turn the MinnowBoard into a ready-to-run system projects founders, the MinnowBoard is quick to offer up its makes getting started easy.
It does, however, require
for developing embedded applications and unlike with GPIO capabilities. The only real disappointment comes from more power under load.
ARM-based devices, those used to an x86 toolchain dont the HDMI socket, which only carries a DVI signal and not the gizmosphere.org
have to learn anything new. audio required of a full HDMI implementation. Theres also no
The board also includes an expansion connector for add- support for HDCP encryption, although anyone considering
in daughterboards dubbed Lures. Designed to be analogous using the MinnowBoard as a media playback system has
to the shields of the Arduino microcontroller, the port gives probably missed the point of its design and features.
each Lure access to considerable potential: as well as three Gareth Halfacree
PCI Express lanes, an SDIO channel, two USB channels and Raspberry Pi

Summary
more, the port carries everything from CAN to IC buses. 28.07
The Pis ARMv6 processor is
Although there are no Lures available on the open market at considerably less capable
the time of writing, several are in development including The MinnowBoard is a welcome foray from Intel into the world than the MinnowBoards
of open hardware and offers considerable potential. While its Atom but at almost a
one which will offer compatibility with Arduino shields. sixth the price, its easy
That doesnt mean the main board is bereft of connectivity: performance may lag behind the rival Gizmo board, the Lure to overlook this in favour
connector holds promise for some impressive add-ons to of having spare cash for
a micro-SDIO slot for the boot device, two USB ports, add-on hardware and
come but its high price means the Raspberry Pi has little to
analogue audio connections, Gigabit Ethernet, and mini- and tinkering components.
fear from this upstart. raspberrypi.org
micro-USB ports for acting as a USB device or as a debug
serial console are included. The board also features a SATA-2
port, offering up to 3Gbps of throughput to a mass storage More
device with a second port available through the Lure information
expansion port if required. minnowboard.org

13 www.linuxuser.co.uk
OpenSource Your source of Linux news and views

www.linuxuser.co.uk Email us directly


For the latest news and views linuxuser@imagine-publishing.co.uk

OpEn SciEncE

Linux Foundation leads


open science initiative
Partnership with OpenBEL will make sharing scientific data easier
A collaboration between the Linux Foundation lead for OpenBEL. It is the standard by which
and Selventas freshly opened OpenBEL all open development projects measure
project could help push the ideals of open themselves. We know our industry can
source development further into the realms of learn a lot from this neutral steward of open
scientific research, the groups have announced. development and governance Also, by
Previously a closed-source proprietary hosting OpenBEL at The Linux Foundation, we
platform, OpenBEL the Open Biological have access to a variety of important services
Expression Language was designed to help to help facilitate collaborative development,
users to capture, store, share and use life allowing our teams to focus on our subject
sciences content through what its creators matter: life science.
describe as a knowledge engineering Hosting the OpenBEL platform with the
platform. Addressing the difficulties with Linux Foundation, its creators hope, will boost
sharing and using data, the team behind nOpenBELs Ted Slater extols the virtues of its adoption. Since going open source in June
OpenBEL has been using it for ten years Linux and collaborative development 2012, the project has already been adopted
but the platform was only opened up in June by organisations as diverse as the Harvard
last year, a move that the Linux Foundation is advance science, and were happy to impart Medical School, the University of California
claiming will be the making of the project. our knowledge of collaborative software at San Diego, the Fraunhofer Institute, and
All of us are smarter collectively than any development to leaders in the life sciences pharmaceutical giants Novartis and Pfizer.
one of us is by ourselves, and Linux is one industry. Successful open source projects The groups hope that wider adoption of
of the greatest examples of that principle, dont just host code; they make use of a full OpenBEL will lead to a pooling of information
claimed Jim Zemlin, executive director at suite of open source best practices to quickly on life sciences, with the platform allowing
The Linux Foundation. We are able to take gain adoption and collaboration. We aim to help for easy dissemination and analysis using a
what we know about Linux and collaborative OpenBEL achieve even more success. standardised set of computable networks and
development and transfer that to new The Linux Foundation hosts the largest application programming interfaces (APIs).
industries. OpenBEL represents an amazing collaborative project in the history of The deal with OpenBEL is the latest of the
opportunity for openness and collaboration to computing: Linux, stated Ted Slater, project Linux Foundations Collaborative Projects,
which include partnerships with the Yocto
Project, Xen Project, FOSS Bazaar, and mobile
platforms MeeGo and Tizen.
Details on the project, and links to the source
code, are available on the official OpenBEL
website at openbel.org.

All of us are
smarter
collectively than
any one of us is by
nOpenBEL provides a platform for the capture and collaborative analysis of life sciences data ourselves Ted Slater

14 www.linuxuser.co.uk
News
ThelatestintheLinuxcommunity
OPEn SOURCE

OPEn SOURCE
Linux calendar
SourceForge DevShare Open World Forum 13
branded malware

3 - 5 October 2013
 Le Beffroi, Paris

France
openworldforum.org
They not only crossed the line, they threw up on it The first European summit
designed to bring together
Open source hosting outfit SourceForge has efforts; its critics claim its nothing more technical experts and political
been criticised for bundling selected binary thanmalware. representatives, Open World
Forum includes speakers ranging
releases in advertising-laden packages. SourceForge, once a mighty force for
from Microsofts Frederic Aatz to
LaunchedinJulythisyear,DevSharebundles the good of open source, has fallen far from the CIO of the French Culture and
software with add-ons such as AnchorFrees its previous lofty heights, opined Red Hat Communication Ministry.
HotSpotShield. SourceForge claims it provides developer Justin Cliff in a post to the Gluster
an easy way for developers to monetise their Project blog. Im not against monetisation at
all, we all have lives and need to pay our bills.
OggCamp

19 - 20 October 2013
Butnotthroughabusingusertrust.Notthrough
LJMU Art & Design Academy,
preyingontheunskilledorunwary.Tomisquote Liverpool
MargeSimpson:Theynotonlycrossedtheline, England
theythrewuponit.
oggcamp.org
SourceForge, now owned by Dice Holdings, The largest open source and free
has defended the initiative. SourceForge will culture event in the UK enters
always respect the rights of our users and we its fifth year. Based around the
will never infringe on them. DevShare offers a unconference format, there will
transparentinstallationflowthatgivesusersall be three fluid tracks along with
a series of scheduled speakers
the necessary information to make educated
throughout the weekend.
choicesaboutwhatsoftwaretoinstall.
The decision to launch the programme,
currentlyinbeta,hasledtocallsforhigh-profile
nThe DevShare programme introduced by projects to move to alternative hosts; others 
LinuxCon Europe
21 - 23 October 2013

SourceForge owner Dice Holdings has drawn including FTP client FileZilla  have, however,
strong criticism alreadysigneduptoDevShare.  Edinburgh International
Conference Centre
Scotland
OPEn SOURCE events.linuxfoundation.org

X.Org loses The largest event covering Linux


in general  rather than specific
distributions  comes to Scotland,
non-profit status with over a hundred planned
sessions. Followed by the Linux
Kernel Summit, Automotive Linux
The Foundation behind X.Org has lost its Summit and Embedded Linux
ConferenceEurope,allinEdinburgh.
status as a 501(c)(3) non-profit group in
the US, following a failure to file taxes with
the US Internal Revenue Service for three
21 - 23 October 2013

consecutive years. CloudOpen


I was taken by surprise that the IRS hit Europe
ussorudely,FoundationaccountantStuart nThe X.Org Foundation is considering  Edinburgh International
Kreitmansaidatthecompanysmostrecent letting others take care of its paperwork Conference Centre
board of directors meeting. Ive had little in future Scotland
issueswithmyownreturnsandhavealways events.linuxfoundation.org
foundthemtobereasonableandfriendly. TheFoundationisnowconsideringjoining The second annual CloudOpen
Kreitman has, however, admitted that an umbrella organisation in order to reduce conference looks to build on the
the tax returns have not been filed, but thepaperworkrequired of its members and success of the first, helping push
argued that the organisation has never prevent this sort of embarrassing situation forward the use of open source
technologiesincloudcomputing.
filedreturns. fromrecurring.

15 www.linuxuser.co.uk
OpenSource Your source of Linux news and views

www.linuxuser.co.uk Email us directly


For the latest news and views linuxuser@imagine-publishing.co.uk

GOVERNMENT

Valencia
completes
LibreOffice
switch
Local government coffers
already 1.3 million richer
The Valencian regional government in Spain
has completed its planned switch from
proprietary software to LibreOffice.
The project to migrate to an open source
alternative began in 2012, and has already
been credited with saving the government
1.3 million in software licensing fees. Moving to LibreOffice has saved the Valencian government a small fortune
Apart from economic benefits, the Valencia has long been at the forefront added, but also boosts the development
commitment to free and open source software of open source adoption, having pushed a of the local ICT sector, promotes the
brings other advantages, including having programme of Linux adoption in schools back use of Valencian in the digital world and
the solutions available in the Valencian in 2005. Covering 110,000 PCs installed across improves interoperability and security of the
language as well as in Spanish, and IT all regional schools, the move to Lliurex Linux is administrations IT systems.
vendor independence, which encourages claimed to have saved over 30 million so far. The move has been lauded by the European
competition, said Sofia Bells, director general Installation of the free office suite is Commissions JoinUp programme, which looks
of the Valencian government ICT department. part of the regional governments strategic to improve interoperability between public
We also have the freedom to modify and adapt commitment to its use of free software. It will administrations through standardisation,
the software to our every need. not only help save costs for licences, Bells suggesting other governments may follow suit.

HARDWARE

ARM begins Internet of Things push


Aims for a trillion devices sold by 2025
Cambridge-based low-power processing giant has been a key contributor to open standards
ARM is throwing its weight behind the Internet for IoT, claimed ARMs John Cornish of the deal.
of Things, forming a new IoT business unit with By making Sensinode expertise and technology
the aim of selling a trillion devices by 2025, and accessible to the ARM partnership and through
purchasing IoT specialist Sensinode Oy. the ARM mbed project, we will enable rapid
Claimed by its proponents to be the next logical deployment of thousands of new and innovative
evolution of the internet, the Internet of Things IoT applications.
looks to equip everything possible with internet- The move comes as industry analysts predict
connected sensors and interactivity as the a pending explosion in the number of connected
means to making peoples lives easier. devices, with Bill Morelli of IHS offering an ARM is pushing its technologies, including the
ARM plans to integrate Sensinodes 6LoWPAN estimate of 30 billion connected devices by mbed prototyping platform, as the future of IoT
and CoAP standards with its own Cortex-based 2020 a figure that ARM is going to do its best
mbed microcomputing platform, which it sells to exceed. frequently, these days, the low-cost and high-
both for embedded hardware development and in Small-scale IoT projects, including printers performance Raspberry Pi or its more flexible
breadboard-friendly format for hobbyist use. that act as Twitter gateways and environmental alternative the BeagleBone Black while others
Sensinode is a pioneer in software for low- monitoring systems, often make use of ARM- use lower-cost microcontroller devices from
cost low-power internet connected devices and based microcomputing systems most Atmel, Texas Instruments and others.

16 www.linuxuser.co.uk
News
The latest in the Linux community
open source

linux viDeoGames
Torvalds celebrates metro: last light heads to linux
linux 3.11 Linux gaming no longer being ignored by triple-A developers.
Following his decision to name Linux 3.11
Linux for Workgroups, Linus Torvalds has Developer 4a Games has confirmed that first-
posted a nostalgic message celebrating its person shooter metro: last light is heading to
final release candidate. linux following its debut on windows earlier
Hello everybody out there using Linux this year.
Im doing a (free) operating system (just a Due to arrive on Steam for Linux later this year,
hobby, even if its big and professional) for Metro: Last Light is one of the first big-name
486+ AT clones and just about anything else titles to be released on Linux in the same year as
out there under the sun, Torvalds wrote. its Windows counterpart and marks a growing
This has been brewing since April 1991, and trend for development houses to consider Linux
is still not ready. as a valid target market for their software.
n4A Games has ported Metro: Last Light to
The message is an amusing echo of his Development of the Linux release was
Linux, for launch later this year
1991 initial Linux release notice, which performed in-house at 4A Games, with the
called for Minix users to try Linux and company crediting its custom game engine for We are very happy with the results, said 4As
claimed it wont be big and professional making it easy to port to alternative platforms. CTO Oles Shishkovstov. We hope that Mac and
like GNU. The game will also be launching on OS X around Linux gamers will appreciate our efforts to create
the same time. the best possible version for their machines.

malware

Hand of Thief Trojan


targets linux Does your current database support provider
guarantee a 15 minute response?
Experts warn users to beware as
malware spreads
a Trojan horse, dubbed the Hand of Thief, has been discovered
targeting linux users and attempting to grab banking credentials
and other sensitive data.
The Trojan, discovered by RSA researchers, includes sophisticated
anti-monitoring and anti-virtualisation techniques which make
it hard to analyse. Sold for around $2,000 on underground sites,
the Trojan is claimed to be effective against all common Linux
desktop distributions.
Anti-virus experts are positioning the Trojan as proof that such
protective software is a requirement on Linux. Its yet another reason
why Linux users shouldnt be complacent about their computer
security, and run an anti-virus program, claimed former Sophos
consultant Graham Cluley. The statement that the Linux platform
We do.
is absolutely secure now seems even more illusive, added Avast!s
Peter Klnai. 2ndQuadrants Platinum Production Support for PostgreSQL
However, the Trojan can only install when provided with root access
provides a guaranteed 15 minute (human) response, 4 hour
workaround and guaranteed bug fix within 24 hours.
something the majority of modern desktop distributions shut off
behind a password. By being careful about what is installed and not 24 hours a day, 365 days a year.
providing a password to an unexpected pop-up dialog, Linux users PostgreSQL is used worldwide for mission critical applications. Now
should largely be protected from its ravages. you can choose this open source database, safe in the knowledge
Those who frequently install software from outside their that if you ever need help, its less than 15 minutes away.
distributions official repositories, however, should take heed: as With guaranteed fix times and access to leading Postgres experts.
the popularity of Linux grows, sadly so too does its attractiveness 2ndquadrant.com/support
to criminals.

. . . .
PostgreSQL Development 24x7 Support Training Services .
2ndQuadrant Ltd. 7200 The Quorum, North Side, Oxford Business Park, Oxford, OX4 2JZ, UNITED KINGDOM
www.2ndquadrant.com TEL +44-870-766-7756
Opinion
The free software column
open source

open source robotics

Linux is the platform


for robotics
Linux is increasingly being used for cutting-edge robotics opening up the
field to anyone interested in learning more
of commonly used robotics hardware such as Over the last five years, ROS has dramatically
cameras, accelerometers and communication eased the process of writing robotic software.
devices are now both much cheaper and much Now you can download a large number of pre-
smaller than they were ten years ago. Actually compiled packages to quickly allow you to
making use of electronic sensors, and motors, is hook up common sensors such as cameras or
also a lot easier now, as platforms like the Arduino Microsofts Kinect. High-level services such as
make connecting electronic components to inverse kinematics, map building and speech
your computer, and controlling them, both quick recognition are easy to plug in, and ROS also
and simple. On top of all this, small, powerful provides a great selection of visualisation tools
computers such as the Raspberry Pi and the so that you can see whats going on from your
BeagleBoard, to name but two, mean that you robots point of view. When you need to write your
can now cram much more processing power into own software, you can do it in the language you
your robots at an affordable price. choose. Low-level motor drivers can be written
In order to put this hardware to good use, in C and then communicate over ROSs network
Alan broun is currently studying however, you need software, and as luck would layer with high-level control processes, written in
for a PhD at the Bristol
Robotics Laboratory. He is have it, Linux is the platform where the most a language such as Python or Java.
also the managing director exciting developments in robotic software are Not having access to robotic hardware is
of Dawn Robotics Ltd
taking place. Writing the software for modern no bar to entry, as ROS also provides support
www.dawnrobotics.co.uk
robots can be one of the most involved and for simulators such as Gazebo. ROS has been
robotics is a fascinating subject. It links complicated parts of the process. Software is embraced by the robotics research community
computers to the physical world, allowing them needed for controlling and so lots of

Not having access


to move around, sense their environment, and to motors, reading simulations of cutting-
interact with it. Building your own robot, however, values from sensors edge robots are now
has traditionally required that you spend a huge and, possibly most provided by the teams
amount of time and energy to get even the most
basic of robotic systems up and running. You
importantly, to provide
high-level control
to robotic hardware who built them. So,
for absolutely no
need mechanical engineering skills to build
the chassis or body, electronic engineering
and AI. A number of
distributed software is no bar to entry cost at all, you can
get access to Willow
skills to wire up the motors and the sensors, environments have Garages PR2 robot,
and programming skills to animate the robot, been produced to try to ease the development NASAs Robonaut and Boston Dynamics Atlas
to control its body to get it to do what you want. of robotic software. But the Robot Operating robot. This last robot is currently being used in the
These barriers to entry mean that people entering System (ROS) produced by a company called DARPA Robotics Challenge, which seeks to get a
into the field of robotics either in search of a Willow Garage in Silicon Valley is arguably one humanoid robot to drive a car and move around a
stimulating pastime, or perhaps as part of more of the most successful. ROS is not actually an disaster area, so its ambitious stuff.
formal research can quickly be overwhelmed operating system, but rather a BSD-licensed Now is an exciting time in robotics, and Linux
by the sheer amount of work required. The initial open source software framework which runs is the platform on which some of the coolest
dreams of building a robot to fetch your beer or on Linux. It allows interfaces to be defined for stuff is happening. If you havent tried it yet, then
to walk your dog get pushed further and further common bits of robotic software, such as the I would urge you to download and have a play with
back, as more and more time is sucked up just drivers for cameras and motors, and it allows ROS, start building yourself a robot and join in all
getting the basics working. this software to be run as a large number of the fun!
Things are changing, however, and the barriers separate processes called nodes either all on
to entry are falling. The relentless march of one machine, or transparently distributed over a
progress in consumer goods means that a lot network of machines.

18 www.linuxuser.co.uk
Can you volunteer for
Code Club?
Code Club is a nationwide network of volunteer-led
after school coding clubs for children aged 9-11.
We need people who know how to program computers to volunteer to run a club at their
local primary school, library or community centre for an hour a week.

We create the projects for our volunteers to teach, the projects we make teach children how
to program by showing them how to make computer games, animations and websites.

Get involved, lets teach the next generation to code!

Visit www.codeclub.org.uk to find out more


OpenSource Your source of Linux news and views

the Open SOurce cOLumn

Fair game
Simon fears the future of gaming is the future of technology
eyes. Scratch that: thanks to computer games, Windows, has taken things to scary levels. At
Ive slipped under the proverbial door seconds one stage, the publisher Ubisoft implemented a
before it slams shut more times than Id care system whereby you had to go online and prove
to admit. you were legitimate once a day, else you werent
But games are changing. For someone allowed to play the title that youd legally bought.
who was brought up with the spirit of 8-bit Naturally, one day its servers werent working
computing, where anyone could spend a day or properly and people werent allowed to play their
two locked up in their bedroom coding a game, game. Those running pirates copies could.
the current climate is all a little disconcerting. Microsoft has tried to implement a similar
Take Watch Dogs: this is a big game that a big system with its upcoming Xbox One games
publisher is making, that before its even been console, although its had to perform a
released has been put on the fast track for a big- significant U-turn when the volcano of public
screen movie. Or the evil of Candy Crush Saga, opinion erupted. Still, those buying a game for
the mobile game revolution that doesnt want an Xbox One machine will need to activate
Simon Brew is a technology any money off you up front, but is happy to take it. A friendly word that, isnt it? It sounds so
writer and editor,
as much off you as it can once its got you cosy reasonable and happy. Just do one thing and
working across the
Linux, Windows and and sitting on the sofa. everything will be active and working. What
Mac OS X platforms Games are interesting, and always have been, could be easier? The truth, of course, is that
because theyre at the forefront of control. I its a further eradication of users rights in the
I play games. Ive always liked playing games, think back to sticking dongles in the back of my proprietary software sector.
and suspect Ill continually sneak one or two in Commodore Amiga to stop people pirating a The problem is that what happens in
for the rest of my days. If you talk to my editor, game (naturally, the only people inconvenienced videogaming increasingly becomes a dry-run
hell obviously tell you that Im the most reliable turned out to be the people who legitimately for what we get in the broader technology
hitter of a deadline that hes ever met and that coughed up), or lining up pictures on wheels. ecosystem. Publishers know that people will
my words arrive perfectly formed, requiring the Then, as technology evolved, so did the endure a degree of hassle to play a game,
barest of edits before theyre laid before your methodologies of control. PC gaming, through and they take advantage of it ruthlessly. Now,
were at a point where Adobes Creative Suite of
tools wont even be sold in a box any more its
the cloud version or bust, and a subscription.
Someones been looking at the World Of
Warcraft model.
Even in the app sphere, where the spirit of the
bedroom programmer should still be alive and
well, theres a corporate sheen thats taking the
fun off things. That Candy Crush Saga model
has proven to be the proverbial grail for many,
in that the appearance of a free, open approach
is just a disguise for one of the most ruthless
gaming money-making machines Ive seen in
recent times.
Its why the good ones need supporting, of
course. But for all the marches of progress,
the loss of an ethos has become real
collateral damage.

n Kings Candy Crush Saga a ruthless money-making machine

20 www.linuxuser.co.uk
Opinion
The free software column
open source

the Free soFtware column

a Gpl breakthrough
Samsung is releasing the code for its exFAT file system driver
for Linux under the terms of the GPL. This is an important
breakthrough because of the participation of both Samsung
and the GPL Compliance Project for Linux Developers
As we all know, the GPL makes a simple pact The great majority of infringements are
between the coder and the user. Anyone can take, not deliberate, and can be attributed to
modify, copy, share and redistribute the software misunderstandings and lack of attention to
and the code, but must pass on the same rights to detail. Manufacturers of mobile devices operate
subsequent users of the software, including any in a rapidly changing environment with short
modifications to the code. product cycles and shorter time-to-market. The
The coder, who is usually (but not always) the market for firmware and mobile devices is highly
copyright holder, gains because enhancements competitive, and every new product comes to
to the code are fed back through the development market with a new range of features. Failure to
process. The manufacturer gains because third- comply with the GPL is usually inadvertent, but
party developers become involved who may releasing the source code is a small price to pay
bring new dimensions to the code. The user gains when set aside the considerable advantages of
because the code remains free and the obligation cost-effectiveness, speed to market, and the
is mutual, meaning that every other user has the accessibility of pre-written and tested code
richard hillesley writes about same obligation to feed their changes back. that free software offers, especially when it is
art, music, digital rights,
Linux and free software for The only requirement of the GPL is that the remembered that it is only the GPLd code that
a variety of publications source code be made accessible to end users, but has to be made available to others.
this requirement is often ignored, especially when Sharing the code is useful to everyone, but the
the code is reused in firmware and embedded terms of the GPL havent always been enforced
non-profit Foss organisation the software devices. GPL code is used in thousands of because the coders have other things to do, or the
Freedom conservancy has reached an devices, but many dont comply with the terms of copyright has been assigned to corporate entities
amicable agreement with samsung to the licence. who dont care about the licence beyond their
release the code for samsungs exFat file The role of Software Freedom Conservancy is immediate needs.
system driver for linux under the terms of to alert manufacturers to failures in compliance For this reason it is an important development
the Gpl. The exFAT driver code came to light and to help them to reach an amicable resolution. that significant contributors to the Linux kernel,
through its inadvertent release via GitHub Most violations are resolved without court in the shape of Conservancys GPL Compliance
(lwn.net/Articles/560424/) and the use of a proceedings. In very rare cases this may involve Project for Linux Developers, have become
binary version in a Samsung Linux-based tablet. litigation but as Jeremy Allison, a board member involved in helping to ensure compliance with the
The Software Freedom Conservancy, led of Conservancy, observes: The point is not terms of the licence, and that Samsung, a major
by Bradley Kuhn, works with developers and to punish people for making mistakes, but to manufacturer, was not only a willing and amicable
manufacturers to ensure compliance with the bring them into compliance. When people get partner in releasing the code, but was happy
GPL. The greater part of the job is to point out into trouble its usually down to laziness and to talk publicly about the matter, which may
the legal obligation to manufacturers and to inconvenience. Its usually a case of I cant be make it easier to achieve compliance from other
help them achieve compliance, and most will arsed, and its too much effort to do it right, so Ill manufacturers in the future.
happily comply. just use it. The drawback, in this instance, is that exFAT
is owned by Microsoft, is a proprietary file

Sharing the code is useful to format and has patent issues. The exFAT driver
code can only be deployed by manufacturers
or distributions that have obtained a licence

everyone, but the terms of the GPL from Microsoft.

havent always been enforced

21 www.linuxuser.co.uk
OpenSource Your source of Linux news and views

JOn MaSterS

the kernel column The latest developments in the kernel


community, including changes to Linux 3.11
raised again in the next cycle. If all goes according your computer to provide many CPU cores for the
to plan, the final release should be out very operating system) scales, it does not necessarily
shortly, in time for a summary in next months do so in a linear fashion. The truth is that certain
issue of Linux User & Developer. memory DIMM banks are closer to certain
Every Linux release has a (code) name, CPU cores.
typically something very silly, and usually In an SMP system, every CPU can access
whatever Linus dreams up at the time he opens every memory location in the system, which is
the merge window (the period of time during typically coherent, meaning that the underlying
which disruptive kernel changes are allowed) hardware takes care of ensuring that memory
for a new kernel release. But from time to time, locations cached internally by other CPUs are
Jon Masters is a Linux kernel hacker a release name has a deeper meaning. The updated when a different CPU updates that
who hasbeen working on
Linux for some 18 years, since 3.11 release came close to happening on the same memory. But accessing a given memory
he first attended university 20th anniversary of the original Windows 3.11 location can be more expensive in terms of
at the age of 13. Jon lives in
Windows for Workgroups release, but it was latency if it is not local to a given processor ie
Cambridge, Massachusetts,
and works for a large not to be. Still, Linus had some fun with the if the underlying hardware must take more steps
enterprise Linux vendor. He celebration of the 22nd anniversary of his original to reach a given location by routing access to that
publishes a daily Linux kernel Linux announcement, posting a Google+ post location through an inter-processor local bus. To
mailing list summary at
kernelpodcast.org in which he parodied himself, saying: Im doing an application (and a user) this manifests in terms
a (free) operating system (just a hobby, even if of slower performance than could be achieved if
its big and professional) for 486+ AT clones and the memory for an application were strictly local
Linus torvalds announced the latest release just about anything else out there under the sun. to a given processor.
candidate of the 3.11 Linux for Workgroups This has been brewing since 1991, and is still Linux handles NUMA in various ways. To a
kernel on the 22nd anniversary of his original not ready. certain extent it can provide a level of transparent
Hello everybody email first introducing Linux support, by migrating memory for applications
back in 1991. nUMa development to be closer to the processors that are using it
The last few weeks have been largely quiet Linux Weekly News recently noted that there (copying the underlying memory locations to
in terms of changes merged into the mainline can often seem to be themes to given periods of other locations more local to a given processor
kernel, typical both of late summer and of the kernel development, and that this past month and updating the virtual memory translation
late stages in a kernel release cycle. It would has had somewhat of a memory management tables accordingly), but special tools have been
seem that temporary fixes for the ongoing theme. This certainly seems to be the case. written to allow administrators to be more
Windows 8 ACPI compatibility issues which But even more specifically, this months theme specific about how a given application should
cause display backlights (now managed directly would seem to actually be that of NUMA (Non- manage its memory. Mel Gorman, famous for
by certain Windows graphics drivers, rather than Uniform Memory Access) development. NUMA writing the definitive book on Linux memory
in the ACPI firmware) to misbehave on some is all about dealing with the reality that as SMP management, has been working on NUMA
laptops will suffice for this release, but will be (symmetric multiprocessing, the kind used in scalability problems recently, and both he and

22 www.linuxuser.co.uk
Opinion
The kernel column Jon Masters
open source

This months theme would


seem to actually be that of NUMA
Johannes Weiner have posted patches that aim memory) killer from being triggered on kernel ongoing development
to better handle NUMA hinting and automatic allocation faults the kernel should itself be able Beyond NUMA and virtual memory, development
reconciliation of memory closer to where it to handle memory allocations failures, or use has included an initial implementation of UEFI
is used. dedicated reserve memory pools. boot stub support for 32-bit ARM systems (which
Beyond NUMA, other memory-scalability- previously used a less standard embedded
related topics were discussed at length over power capping framework bootloader called U-Boot), a patch to allow per-
the past month. Dave Chinner posted patches Beyond memory management, Srinvas process control of transparent huge pages, a
that convert the kernel inode cache (an internal Pandruvada (Intel) posted an initial RFC fix for PCIe reinitialisation when performing a
kernel data structure responsible for caching (Request for Comments) patch the first kernel crash dump (and kexec into a kernel that
metadata about mounted file systems) to use stage in developing a new idea into code must not have outstanding DMA operations
Paul McKenneys famous (and IBM patented) series that implemented an in-kernel power pending on boot), and optimisations from Andi
RCU (read-copy-update) memory access capping framework. The basic idea is to allow Kleen for the kernel build system known as
optimisation. This allows the inode cache to scale a given system (platform) to specify how much kbuild. Andis patches convert the kallsyms
more easily when Linux is run on very large NUMA power is available and for a precise cap to be stage of kernel compilation into a single-pass,
or non-NUMA systems without using a previously enforced across a variety of CPU and non-CPU rather than being the multi-stage process that
global lock. Also scale related, Andy Lutomirski (of devices installed within the system. Using has been the case. This is the point during kernel
a large banking corporation) began a discussion this mechanism, it is hoped to provide certain compilation at which all of the symbols (function
concerning a new MADV_WILLWRITE flag that limits (such as the amount of power that can names provided by the kernel for internal and
can be used when setting up memory mappings be delivered by a battery, or power utility, or the modular use) are resolved during the final linking
to inform the kernel that a given range of virtual amount of power available if a battery is intended of the kernel image. Andi has a series of cute
memory will definitely be written to later. This to last for a certain time period, and so on) and for hacks proposed for dramatically speeding up
allows the kernel to forgo its usual copy on devices to provide various performance trade- the process.
write (deferred allocation of new virtual memory offs within those constraints. But by providing In this months kernel announcements, Ted Tso
regions until the first use) and instead take the an overall framework, it is possible for the kernel reminded everyone that the 2013 Linux Kernel
(slightly more expensive) up-front hit of directly to make whole-system decisions that are not Summit is coming up in Edinburgh next month,
allocating the memory in order to save a latency isolated to a given subsystem or to a given device and that there will be places reserved for those
hit later when that memory is touched by a in isolation. who are strictly hobbyist developers. This seems
running application. Initial comments on the power capping to have been a late decision since the deadline
Memory management contributions this framework were favourable, although Greg for submissions came and went quickly, but it will
month also included a virtualisation optimisation Kroah-Hartman (now of the Linux Foundation) be worth keeping an eye on this next year, in case
from Martin Schwidefsky (of the IBM s390 team), suggested that he wanted to see actual users such an invitation is repeated. Beyond the Kernel
who provided patches that allow guest instances of the framework before it is merged by which Summit, there will be a number of kernel and non-
to inform a host hypervisor that they are not using he meant that he really wanted to see Intel post kernel developers present at the Linux Plumbers
pages (the fundamental unit of memory chunks code for its own CPUs and platforms to make use Conference in New Orleans, at which several
that the system uses to manage memory used of this framework. This seems to be in progress, other mini-conferences will run concurrently.
by applications, virtual machines, the kernel itself since comments on the mailing list implied that These include an ACPI/Power Management
and so on), which are automatically discarded such patches exist and have been reviewed by at gathering, a PCI mini-conference and this years
whenever they would be swapped out to disk, and least a subset of developers to this point. It will be Linux Security Summit, among many others.
reinitialised when required later. Still further in interesting to see where this development leads,
the realm of memory management, Michal Hocko especially in the mobile space, and also when
provided a patch that prevents the OOM (out of applied to other architectures.

23 www.linuxuser.co.uk
Feature Android Studio

Get started with


Android
Studio
Get your head around the early access preview
of the next stage in Android development

A
nnounced earlier this year at Google I/O, Android
Studio will be the replacement for the current
Android development solution in Eclipse. This
Eclipse setup is part of the Android Developer Tools, and
takes advantage of the IDEs Java-based development
environment and plug-in support to currently create the
development portion of Android apps. With the rest of the
SDK, virtual devices can be created and used to test code
before deployment onto real devices.
The Android Studio aims to be an all-in-one solution for
development and testing. Coming with the entire SDK, and
not even requiring traditional compiling or installation on
Linux, Android Studio is an incredible easy and quick way
to get straight into coding your apps whether youre an
experienced Android/Java dev working directly in code,
or a novice looking to use the graphical, drag-and-drop
approach to app creation.
Android Studio is still currently in beta as a free early
preview well cover some of the current quirks with the
software. However, its a definitely a great way to get used
to using the software before the final switchover occurs.
Well also cover how you can export from Eclipse if youve
already been using that, and how to then distribute your
app once its finally complete.

24 www.linuxuser.co.uk
Android Studio
Get to grips with the new IDE for Android development
Feature

25 www.linuxuser.co.uk
Feature Android Studio

Introducing Android Studio


The new Android Studio is based on IntelliJ IDEA, a much Installation is very simple as well the files contain both the IDE
smaller and streamlined IDE than Eclipse. Android Studio and the SDK youll need to create your apps, so you wont need
utilises its features to create an all-in-one Android development to install the SDK via ADT separately like you will have done with
environment with a smart visual view that is great for people Eclipse if youve developed for Android in the past. The Studio
just getting into app development, and the standard text editor allows you to edit how the SDKs are utilised, how imports and
for those who know their way around Java and the Android API. exports work, and even has a plug-in manager.

New Project
Start a new project by
going through the handy
Android new project
wizard, selecting API
levels and setting
the icon

Recent Projects
The recent projects view
allows you to go straight
into any project you
wish to work on without
having to look in the
Open Project prompt

Check for updates Docs and How-Tos


Android Studio has its Some tips and how-tos
own update manager, for IntelliJ, the base
allowing you to keep it of Android Studio, are
up to date. It will notify available straight from
you when a newer the welcome screen
version is available

Installation

01 Download 02 Runtime
Use cd in the terminal to navigate to
Head over to the Android Developers
website and grab yourself a copy of the early
access preview to Android Studio from here:
the folder you just created, specifically the
android-studio/bin/ directory. To launch
Android Studio, enter into the terminal:
03 First run
If this is your first time using Android
Studio, you can safely ignore the prompt
bit.ly/1bWrFXz $ ./studio.sh to import any settings. Otherwise, find the
Youll need to then extract the contents If it asks about your Java settings, for file you created from before, or your old
put it in a folder you have easy access to, as now press Enter, as we can fix that later if it installation folder, to get previous settings.
you need to run the Studio from the folder. becomes a problem. We can import from Eclipse later on.

26 www.linuxuser.co.uk
Android Studio
Get to grips with the new IDE for Android development
FEATURE

Key features Helpful shortcuts


Android Studio has handy, configurable
Development views keyboard shortcuts. Heres a list of the
As the Java for the Android
most common to get you started
apps is split into visual and
function elements, you can Command look-up
use a visual WYSIWIG editor (autocomplete command name)
for the XML code, allowing
you to place buttons and
Ctrl + Shift + A
text and other UI elements Project quick fix
wherever you want on the
screen. The text part is a full Alt + Enter
IDE, with code navigation,
debugging, syntax Reformat code
highlighting and a smart
code analyser that warns you
Ctrl + Alt + L
of any obvious issues with Show docs for selected API
what youve written.
Ctrl + Q
Virtual devices
Show parameters for selected method
Test your apps on a virtual
device that you define, either
by using settings for the main
Ctrl + P
Nexus devices, or by using Generate method
generic settings for different-
sized Android phones or Alt + Insert
tablets. You can edit the
system settings to limit or Navigate open tabs
increase RAM, and even allow
it to use the system GPU if
Alt +
you need it to. Its not perfect, Alt +
but its a great way to quickly
test functionality. Jump to source

F4
Delete line

Ctrl + Y
Search by symbol name

Ctrl + Alt
+ Shift + N
Build
Eclipse migration Debugging
For existing Android developers, its easy to A specific debugger can analyse the code as
Ctrl + F9
migrate from Eclipse and the ADT to Android it runs and give you a full rundown of whats
Build and run
Studio. The tools are already in place to happening when, allowing you to go through
export the necessary files from Eclipse, and the logs and figure out any possible issues, Shift + F10
Android Studio includes a handy feature or work out where problems are already
that allows you to then import them, and any occurring. You can pause the program at any Toggle project visibility
other Studio file. This is helpful now and will point to isolate issues, instead of having to
be essential when it replaces Eclipse. search through code as it continues to run.
Alt + 1

27 www.linuxuser.co.uk
Feature Android Studio

FAQ Create a new project


Since Android Studio is still under some Android Studio offers a quick way to start your to put together an app with specific versions
development, there are some bugs that app: name, package name, theme, advanced of Android in mind, making newer API objects
still need to be ironed out. Here are a icon options and the ability to select between available for some. Well look at a basic setup
couple of known issues with Android different Android APIs. The latter allows you first so we can make our Hello World app later.
Studio that you can work around.

1) Error: Gradle project refresh failed


Android Studio has a newer version
of Gradle that has some backward
compatibility issues. These can be fixed by
first clicking the link to search build.gradle
from the error dialog. From there, double-
click the line under the build.gradle usage,

01 02
opening the project build.gradle file. Edit Create New Project Set image
the classpath to change the gradle version From the Welcome screen, click on Here you can set your image,
to 0.5.+. Finally, save the file and rebuild Create New Project to open up the dialog giving you a nice preview of how it will look
your project. window. Name the project HelloWorld well on different types of devices. You can set
be creating the code for that shortly. Leave all padding, background colour and more to your
2) Error: Failed to import Gradle project the other default settings they relate to what app icon. For now, click Next, as we dont need
This can be a problem after upgrading versions of Android will be able to use the app. an icon for the sample project.
Android Studio, as the project files may
point towards an SDK element that
no longer exists. To fix this, youll need
to quickly install the Android Support
Repository. First, open Android SDK
Manager, find and expand Extras, and
install Android Support Repository.

03 Activity selector
For now, well just use the blank
activity. When making other apps, this activity
04 Activity name
Here you can name the activity and
customise the way it works, with tabs, drop-
selector can help you choose how the app with down menus and other actions. For now, well
behave such as being full-screen or having a leave this as is. Hit Finish and the project will
multi-column flow to view several items. be built. It may take a little while to do this.

Migration
Its quite easy to export existing projects
from Eclipse and then import them into
Android Studio. First of all, make sure your
ADT plug-in is up to date, then select File
and Export. Open Android from there and
select Generate Gradle files, then your
projects to export before clicking Finish.
In the basic Android Studio window, click
05 Project structure
Android Studio will create a lot of files
for what will be a simple app luckily we just
06 Views
The default view is the visual
development interface it includes elements
on Import project, find the build.gradle
need to pay attention to MainActivity.java down the side that allow you to drag and drop
file and then press OK at the pop-up. You
and Main_Activity.xml for the moment. The functionality. You can also click the Text tab at
should then be able to start development
interface is also initially set up to allow for the bottom to get straight into the Java code,
on the project within Android Studio.
WYSIWYG visual development. with a live preview updating as you type.

28 www.linuxuser.co.uk
Android Studio
Get to grips with the new IDE for Android development
FEATURE

A view to develop
The two views for Android Studio serve different purposes The text view works like any good IDE, with a hierarchical view
and people. The default visual view allows you to drag and drop of code, code navigation tools, autocomplete and, of course,
functions onto the interface, with guidelines to make sure you proper syntax highlighting.
keep them aligned with other UI elements. This then adds the Whichever view you use is up to you however, you will
elements to the code, so you can edit them further in there. ultimately have more control with the text view.

Layouts & widgets Live preview Toolbar Component tree


Drag and drop different layouts See a live preview of Quick access to preview and Even in the visual view, you can
and functions to create your the way your app will debugging tools, along with the ability break down the code in the
app visually a great way for look, even while using to change the theme, activity type and individual components to see
novices to get started the text mode the device preview how they work

Useful resources
There are plenty of online resources you can Developer site has regular posts on interesting Support for IntelliJ IDEA, the base for Android
use to help you with your development projects, updates to the SDK, and some Studio. Some of the support questions may be
whether you need to figure out a more elegant troubleshooting tips. more suited to the IntelliJ side of things.
method to create a specific function, or need Stack Overflow stackoverflow.com XDA Developers
to wrestle with some bugs. Heres a list of some
One of the best places on the internet to get www.xda-developers.com/
of the places you should visit.
advice on an issue either by searching for a
A community built around smartphone
Android Developer Site related question or submitting your own.
development, the XDA forum is a good way to
developer.android.com
IntelliJ IDEA Support find out about Android-specific tips and tools,
As well as the place to get Android Studio, the intellij-support.jetbrains.com/home and even to promote your application.

29 www.linuxuser.co.uk
Feature Android Studio

Make your first application


Creating your first app in Android Studio is easy, and well within them what were going to do here is learn how to simply
start with the simplest one of all the classic Hello World. make Hello World in Android, and what other simple tasks we can
All basic apps, when created, have Hello World already displayed do in it.

01 Visually
To do it visually, simply select Plain
TextView, and place it on the display. Double-
android:layout_height=wrap_content
android:text=Hello World!
android:id=@+id/textView/>
OnClickListener;
import android.widget.Button;
This allows us to use some extra Android
click it and type in Hello World!. All static text The layout variables can also be set as fixed functions to press and use the Quit button.
can be placed this way onto the interface, and pixel width/height.
it will create the necessary code in the text
view as well.
04 Quit button
The file were editing now is just the
06 Coded actions
Add the following code below the line
setContentView(R.layout.activity_main);:

02 Relative text
The relative layout should be included
in the code by default. Create a text parameter
display. To do something, we need to start
editing the .java file. While were still in the .xml,
place a button and give it the caption Quit.
Button button = (Button)
findViewById(R.id.button)
button.setOnClickListener(new
by opening up triangle brackets with: Open up MainActivity.java from the Projects OnClickListener() {
<TextView column before we continue.
which we will use to display Hello World. @Override

03 Hello code
To add Hello World to the Text
05 Imported
Now add these imports to the top of
the code:
public void onClick(View v) {
finish();
System.exit(0);
parameter, we put in: import android.view.View; }
android:layout_width=wrap_content import android.view.View. });

Code listing
Package name package com.linuxuser.helloworld;
The name of your package according to the import android.os.Bundle;
Android system import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import functions
import android.widget.Button;
Import the various functions we need to get the public class MainActivity extends Activity {
code to work on an Android device @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MainActivity class setContentView(R.layout.activity_main);
The MainActivity class includes all the functions Button button = (Button) findViewById(R.id.button);
in our main activity that we created button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Main layout finish();
This sets what the main layout, and displays it System.exit(0);
}
});
Quit button }
The section containing the code to make sure @Override
our button (with id button) properly quits the app public boolean onCreateOptionsMenu(Menu menu) {
with System.exit // Inflate the menu; this adds items to the action bar if
it is present.
getMenuInflater().inflate(R.menu.main, menu);
Settings menu return true;
This creates the Android settings menu that appears }
at the top of the app }

30 www.linuxuser.co.uk
Android Studio
Get to grips with the new IDE for Android development
FEATURE

Working with virtual devices


Create a virtual Android device to test and debug your Android apps, choosing from a selection of generic phones and tablets

Home screen Physical buttons


Emulate a list of Android Theres a range of
devices, from Nexus physical buttons you can
phones and tablets to use that work on certain
generic phones defined devices, with power and
by screen resolution volume working on all

Hardware specs
Edit specific hardware
variables to better
emulate certain aspects
Android buttons of a device, or give it
Software buttons are more power via your
included on the virtual host system
device, as they are part
of modern Android

01 Virtual device manager


From the Project View, find the
Android Virtual Device (AVD) manager icon
02 New device
In the pop-up dialog, name the virtual
device, select the device you wish to emulate
03 Virtual reality
Click OK and Android Studio will
confirm the options youre using. Press Start
along the top and click it. From here you can and then the target API level. Some devices while the device is selected and choose
create and edit a range of devices for testing will have a minimum Android version target. whether you want to get a pixel-accurate
your apps on. Click on New so that we can Your can edit this later, but for our app we wont screen, or a scaled version. It will then boot
get started. need to change any other settings. up a virtual phone or tablet you can test on.

Debugging
Android Studio includes tools to debug
the apps you create. To use them, first
make sure a device is running to emulate
the app. Then, click the Debug button
in the shape of a green bug and the file
will rebuild and launch on the device. This
time, though, it will bring up a full logging
window, a console and a debugger with
full tools to figure out where problems
Use Android Studios debugging tools to analyse your code
may be occurring in your apps.

31 www.linuxuser.co.uk
OW
R RY
N
DEUR
OR H
SUBSCRIPTION VOUCHER
YES I would like to subscribe to Linux User & Developer

YOUR DETAILS
Title First name
Surname
Address

Postcode Country
Telephone number
Mobile number
Email address
Please complete your email address to receive news and special offers from us

DIRECT DEBIT PAYMENT


UK Direct Debit Payment
I will receive my first 3 issues for 5, I will then pay only 25.15 every 6 issues thereafter.

Instruction to your Bank or


Building Society to pay by Direct Debit
Please fill in the form and send it to: Linux User and Developer Subscriptions Dept, 800 Guillat Avenue, Kent Science Park, Sittingbourne ME9 8GU

FANTASTIC
Name and full postal address of your Bank or Building Society Originators Identification Number
To: The Manager Bank/Building Society
5 0 1 8 8 4
Address

Reference Number

SUBSCRIBER
Postcode Instructions to your Bank or Building Society
Please pay Imagine Publishing Limited Direct Debits from the account detailed in this
instruction subject to the safeguards assured by the Direct Debit guarantee. I understand
Name(s) of account holder(s) that this instruction may remain with Imagine Publishing Limited and, if so, details will be
passed on electronically to my Bank/Building Society

Signature(s)

OFFER
Branch sort code

Bank/Building Society account number

Date

Banks and Building Societies may not accept Direct Debit instructions for some types of account A6 instruction form

PAYMENT DETAILS Subscribe today and get


your first three issues
YOUR EXCLUSIVE READER PRICE, ONE YEAR (13 ISSUES)
UK: 62.40 (Save 20%) Europe: 70.00
World: 80.00
Cheque
for 5 (and save 13.00)
I enclose a cheque for Pay only 4.19 for every
(made payable to Imagine Publishing Ltd)

Credit/Debit Card
future issue a 30% saving
Visa MasterCard Amex Maestro on the store price
Card number Free UK delivery to your door
Expiry date
Issue number (if Maestro) Never miss an issue
Signed Money-back guarantee
Date
Code: PGG134Q
Terms & Conditions
Please tick if you do not wish to receive any promotional material from Imagine Publishing Ltd by post by This offer entitles new UK direct debit subscribers to receive
telephone via email their first three issues for 5. After these issues, subscribers
Please tick if you do not wish to receive any promotional material from other companies by post
will then pay 25.15 every six issues. Subscribers can cancel
by telephone Please tick if you DO wish to receive such information via email
this subscription at any time. New subscriptions will start from
Terms & Conditions apply. We publish 13 issues a year, your subscription will start from the next available issue
unless otherwise indicated. Direct Debit guarantee details available on request. This offer expires without notice. the next available issue. Offer code PGG134Q must be quoted
I would like my subscription to start from issue: to receive this special subscription price. Details of the Direct
Debit guarantee are available on request. Offer expires 31 March
Return this order form to:
2014. Imagine Publishing reserves the right to limit this type of
Linux User & Developer Subscriptions Department, 800 Guillat Avenue, Kent Science Park,
offer to one per household.
Sittingbourne, ME9 8GU or email it to lud@servicehelpline.co.uk
Source Code PGG134Q
You will be able to view your subscription details online at www.imaginesubs.co.uk Web address: www.imaginesubs.co.uk/lud. Tel: 0844 249 0282
3 ISSUES OF
LINUX USER
FOR JUST 5
Readers in
the US see
page 84 for
exclusive
offer

Get your first 3 issues for just 5,


then save 30% on the shop price
THREE EASY WAYS TO SUBSCRIBE
1.Online 3.Post or email
www.imaginesubs.co.uk/lud Please complete and post the form to
Linux User & Developer
And enter PGG134Q Subscriptions Department
800 Guillat Avenue

2.Telephone Kent Science Park


Sittingbourne

0844 249 0282 ME9 8GU


Or alternatively, you can scan and email the form to
And quote PGG134Q lud@servicehelpline.co.uk
Tutorial Make a small business database with LibreOffice

phpMyAdmin offers a Data entry is All of the actual You import and export data
web-based front-end for the carried out via an database design to and from LibreOffice
creation and maintenance of easy-to-use form in (fields, form layout Base by using Calc, the
MySQL databases Base, the front end etc) is carried out spreadsheet module. This
to our database from within Base enables access to most
common data formats

Make a small business


database with LibreOffice
Create a database that combines an easy-to-use,
form-based front-end using LibreOffice with a portable,
networked MySQL back-end
Advisor Were going to show you how to put together
a typical database for small business use: a
forms for data entry and the actual business
of entering data. For the back-end, we will be
Michael Reed is a technology database of customer details. It will be possible using the industry-standard MySQL. This allows
writer, and hes been
hacking away at Linux to both export and import contact data from us to locate the back-end on a central server.
for over 15 years. He in standard formats by making use of Calc, This, in turn, allows multiple users to access
specialises in desktop LibreOffices spreadsheet module. Well use the database.
Linux solutions
Gmail contacts as our source, but you can use For initial creation of the MySQL database,
any software that can export CSV files and well use phpMyAdmin thanks to its friendly
Resources pretty much everything can. web interface, although the actual database
LibreOffice: www.libreoffice.org Weve added a few twists to keep things design will be carried out from within Base. By
interesting. This project uses the Base module the end of the project, you will have a GUI system
At least one Ubuntu Linux PC
of LibreOffice as the front-end, and this provides for browsing and editing the database with a
a GUI for setting up the database, creating the portable, networked back-end.

34 www.linuxuser.co.uk
Make a small business database with LibreOffice
Use LibreOffice and MySQL to create a customer database
TUTORIAL

01 Install LibreOffice
At time of writing, the major Linux
distributions havent moved over to LibreOffice 4
04 Install the MySQL Server
Type sudo apt-get install mysql-server to begin installation. Before long, you
should be prompted to set a root MySQL password. Note that this isnt the same as the administrator
and are still offering 3.x. This means that you may account of your system, which is also called root. Choose a password and make a note of it.

05 06
have to install LibreOffice 4 manually. Visit the
Install and test phpMyAdmin Create database
LibreOffice website (www.libreoffice.org) and
Type sudo apt-get install Within the phpMyAdmin web interface,
follow the instructions. On Ubuntu, this consists
phpmyadmin to begin installation. When select the Databases tab. Now create a new
of unpacking the archive and running sudo dpkg
prompted to choose a web server, choose database by entering the name customer into
-i *.deb on the contents.
Apache2, select it with the space bar and press the text box and clicking on Create. This database
Return. When requested, give it the MySQL will contain our customer data.
root password and then choose a password for
phpMyAdmin and make a note of it. Navigating
to http://localhost/phpmyadmin/ should take
you to a functioning login page. Log in using the
MySQL root username and password. Well
use MySQL to set up and maintain the actual
database, although well create the fields from
within LibreOffice later on.

02 Install the Apache web server

07
Well install Apache early on and with Add JDBC in LibreOffice
its own command because some of the other We now need to tell LibreOffice where
packages need to be able to configure a working to find the JDBC class file. Start LibreOffice
Apache installation. Carry out the installation and go to LibreOffice>Options>Advanced. In
with sudo apt-get install apache2. Test the Java Options section, select Class Path and
it by navigating a web browser to http://localhost. then Add Archive. The file you need is located at:
/usr/share/java/mysql-connector-java.jar.
Select it and restart LibreOffice.

03 Install Java and additional classes


Connectivity between Base and MySQL
makes use of a Java class. Type sudo apt-get
install default-jdk to install the Java
runtime. Type sudo apt-get install
libmysql-java to install the needed additional
Java classes.

35 www.linuxuser.co.uk
Tutorial Make a small business database with LibreOffice

08 Connect the database


We now need to connect our front-
12 Create form from template
Select Forms from the sidebar. Click on
Use Wizard to Create Form in the Tasks window.

10
end (LibreOffice) to the back-end (MySQL) of In the table wizard, click on the >> symbol to copy
Save the database
our database. Start LibreOffice and launch the across all of the fields in the database.
You can accept the defaults on the next
Base module. In the dialog that pops up, select
page, so click on Finish. When prompted, give
Connect to an existing database. From the drop-
the database a name and save it. Remember
down menu below this, select MySQL as the
that this file contains the connection information
database type.
for access to our MySQL database it doesnt
contain the actual records.

13 Finalise form
Accept the defaults in sections 2, 3 and 4,
but select the first arrangement icon in section 5,
Arrange controls. You should now see a preview

09 Configure Base
On the next page, select Connect using
JDBC. On the next page, click on Test class to 11 Create fields from a template
You may want to create a custom set of
of our entry form in the main window. Select
defaults on the other sections and then click
on Finish.
ensure that the Java RT is working. Now enter fields for your customer records, but to save
the name of the database that we created, time were going to use the one of the templates
customer, and enter localhost into the Server that is built into Base. Select Tables from the
field. On the next page, add Root as the username side menu and then Use Wizard to Create Table.
and tick Password required. Now click on the Using the Sample tables pull-down menu, select
Test connection button and enter the root Customers. Use the >> button to copy all of them
MySQL password, when asked for it, to test the across. On the next page, you can tweak the fields
connection between LibreOffice and the local that you have included and add new ones. Select
MySQL server. Presuming that this completes the defaults on the next two pages and then click
without errors, click on Next. on Finish.

Remember that this file contains 14 Test data entry To enter data into the database, use the

the connection information for access


form that we created. Select Forms in the sidebar
and then double-click on the name of the form in

to our MySQL database it doesnt


the main window. This brings up the GUI record-
editing interface. The form can still be tweaked

contain the actual records


and edited by right-clicking on its name in the
main window.

36 www.linuxuser.co.uk
Make a small business database with LibreOffice
Use LibreOffice and MySQL to create a customer database
TUTORIal

18 align the fields


The field names from our imported data
dont quite match those of the database and so
we need to use the second page of the wizard
to line them up. To do so, click on a field name
and use the up and down icons in the other list
to create the correct attachments. Then click
on Create.

19 Create a new database user


To access the database from more than
one machine, you must create additional users.
Log back into phpMyAdmin, click on the Users
tab and select Add user. From here, create a
new user with the name and password of your
choosing and make a note of it. Click on Check all

15 Export your contacts from Gmail


Switch from the Gmail contacts view
using the pull-down menu in the top-left corner,
17 Import the data into Base
When youve cleaned up the spreadsheet,
select the data (including the column headers)
in the Global privileges section.

underneath the Gmail logo. From here, click by clicking on the top-left cell and then Shift-
on the More icon pull-down menu and select clicking on the bottom-right cell. Right-click and
Export Click on Export. select Copy. Select Tables from the side menu of

16
the Base module. From here, right-click on the
Clean up the data and create a key
customers table and click on Paste. This should
Start a new spreadsheet and open the
bring up the import wizard. Select Append data
CSV file that you exported from Gmail. Use
and Use first line as column names options, and
Ctrl-mousewheel zooming to get an overview.

20
click on Next. Redistribute the database
Typically, a lot of the fields will be completely
blank, so select these columns (click on the In the Base module, re-save the
column letter at the top of the window) and database under a new name. In this new version
remove them (Edit>Delete cells). We have to of the file, we have to alter a few details. Select
create a key for each record. Label a column ID. Edit>Database>Properties and enter the name
Select the first cell in the column and then select of the new database user. Click on the Additional
the final cell by Shift-clicking on it. Use the fill Settings tab and enter the IP address of the
feature (Edit>Fill>Series). machine with the MySQL database.

37 www.linuxuser.co.uk
Tutorial Write LaTeX documents with LyX

The toolbar gives you You can always see what The main window is where You can view what your
shortcuts for items like the actual LaTeX source you type your text. This document will look like by
lists, images, tables and code looks like for your is also where your text rendering it to a PDF file.
maths formulae document. Nothing is gets rendered Dont forget to refresh it
hidden from you in LyX after making edits

Write LaTeX documents


with LyX
LyX lets you to get your document written without having to
deal with LaTeXs steep learning curve. Heres how

Advisor LaTeX is a typesetting system that gives you full


control over how everything in your document is
In this tutorial, youll learn how to create a new
document and create various content sections,
Joey Bernard As a true renaissance rendered. The problem is its really steep learning like images, tables and lists. You will also learn
man, he splits his time between
building furniture, helping curve. One option is to use a basic text editor and how to use various document settings, like the
researchers with scientific learn all the markup you need for your document. document class, to control the overall options
computing problems and writing
Android apps. When the kids let
The other option is to use an application that used during document rendering. Since LaTeX
him have some time, that is wraps the markup to some degree. LyX does this is a typesetting system, LyX will let you output

Resources very nicely. While a fully WYSIWYG editor for LaTeX


doesnt make sense (since your doc isnt fully
to several formats, like PDF, Postscript, HTML,
plain text and OpenDocument files. Regardless of
LyX: www..lyx.org rendered until sent to an output device), LyX does whether you are writing a book, a journal article or
provide a pseudo-WYSIWYG interface where you a set of presentation slides, LyX will help you get
LaTeX: www.latex-project.org
can see how different regions will be rendered. your work done with minimal fuss.

38 www.linuxuser.co.uk
Write LaTeX docs with LyX
Use LyX to lay out your LaTeX documents with ease
TUTORIal

01 Installation
The first step is to get LyX installed on
your system. Most distributions should have a
package available. For your non-Linux friends,
there are binaries available for Windows, Mac
OS X, and even OS/2 and Haiku. As always, you
can download the source code and build from
scratch in the worst-case scenario.

04 Text layout
While the document class sets the
defaults for your document, you still have full
06 Numbering and the TOC
Documents are broken down into several
nested subregions. How these regions are
control to change anything in the document. handled in the layout is decided by the document
The Text Layout option lets you change the class. You can also set whether these regions are
indentation size to a custom increment. The numbered or not, and whether they show up in
vertical spacing and line spacing can also be the generated table of contents.
customised. You also have the option to make

02 Opening a new document your document two-column here.


07 View source
Now that your document is set up,
When you first start up LyX, the main
window opens up with a splash screen image
displayed. You actually have to tell LyX that you
05 Page layout
LaTeX figures out the actual rendering
of your document based on a page layout. You
you can start typing. LyX gives you a pseudo-
WYSISYG display of the text. But LaTeX is a purely
text-based markup language, so you can always
want to start a new document before you can can select one of a number of standard page see the actual source code to verify what LyX is
start writing. You can start a new document by formats, or set a custom page size. You can set putting into your document. To see the source,
clicking the menu item File>New. whether the page is oriented as either portrait or just click on the menu item View>View Source.
landscape mode.

03 Setting the document class


Many of the layout properties for your
document are set to defaults based on the class
of your document. You can set this by clicking the
menu item Document>Settings. This will pop up
a dialog window that well use for the next few
steps. The drop-down list will give you a very full
list of possible document classes.

39 www.linuxuser.co.uk
Tutorial Write LaTeX documents with LyX

Many of the
layout properties
for your document
are set to defaults
based on the class
of your document

12 Sections
In most documents, you will probably
want to break the text down into sections, and
possibly subsections. Sections are defined
by giving them a title. For instance, if your first

08 Title
The first item your document will need
is a title. In LaTeX, you need to worry about what
10 Dates
You should have noticed that there is a
date option in the drop-down. You dont need to
section is going to be an introduction, then you
would type the section title as Introduction and
set the type in the drop-down to Section. The
a particular piece of text is supposed to be, not use this if you dont wish to. LyX will automatically actual text for this section would be set to the
what it will look like. So at this stage, you can type add the current date when you actually render the type Standard.
in your title text. To identify it as a title, you can document into an output format.
click the drop-down at the top right of the toolbar
and select Title.

11 Abstracts
If you are writing an article, or a report, you
may need to include an abstract of the subject
matter being covered. If you have already written
your abstract, you can highlight the region with 13 Mathematical formulae
Mathematical formulae are always a
problem area in document typesetting. Many
your mouse and select Abstract from the drop-
down. This adds the title Abstract and changes people in the sciences first move to LaTeX
the format of the text. because of the ability to fully control equations by
explicitly laying out all of the elements. However,

09 Author
Hitting Enter will give you a new line, with
the type back to Standard. You can here enter
for more complex equations, this can still be
confusing. Therefore LyX provides an equation
writer tools that helps you create the LaTeX
your name and set the type to Author, again with required to lay out your formula in your document.
the drop-down at the top right of the toolbar. You can set the type of maths to be either inline
Where and how this will get rendered depends on with your text, or to be centred and displayed on
the document class and the output format. its own.

40 www.linuxuser.co.uk
Write LaTeX docs with LyX
Use LyX to lay out your LaTeX documents with ease
TUTORIal

14 lists
There are several different types of
lists available for your use. Both numbered and
unnumbered lists are available as buttons on the
main toolbar. To start a list, click on one of the
buttons and start typing the first item. Hitting the
Enter key will give you a new item to enter. Hitting
Enter on an empty item will drop you out of the
list section.

15 Tables
You can add a table by clicking on the
menu item Insert>Table. A dialog will appear
where you can set the number of rows and
columns. The first row is set aside as a header
for the columns, but you can change this in the
LaTeX source.

(pdflatex)]. There are also other viewing options, provided by your LaTeX installation. This is
in case you want to render your document using defined in the Document Settings dialog, where
other methods. you can set the family, encoding and fonts to use
for Roman, Sans Serif and Typewriter.

16 Images
Clicking on the menu
Insert>Graphics opens a dialog window where
item

you can select an image file to insert into your


document. You can either set a scaling factor, or
an explicit width and height for its display. You
can also rotate your image through X degrees.
You also have the option to control if and how the
image gets clipped to a bounding box.

20 Output formats
Now that you have your document
finished, you will want to render it to some
final output format. A common choice is either
PostScript or PDF. This way, you know that it will

18
look the same, regardless of who you give it to.
Spellchecking
But you have several other options available, too.
Most people need help when it comes
You can output to HTML, rich text, plain text or
to making sure everything is spelled correctly. If
even OpenDocument.
you want to use the system default spellchecking
engine, you can simply click on the menu
item Tools>Spellchecker. You can change
the engine being used by selecting it in the
options window.

17 Previewing
Now that you have a bunch of content in
your document, you probably want to get an idea
19 Fonts
Linux users have had problems,
traditionally, when dealing with fonts. This
of what it will look like once it is fully rendered. extends to applications like LaTeX. LyX includes
You can get LyX to generate a PDF for viewing options that help you correctly set up TrueType
by clicking the menu item View>View [PDF fonts, allowing you to use fonts other than those

41 www.linuxuser.co.uk
Tutorial Synchronise your files with Unison

Unison synchronises files This line indicates that This error message
between computers here Unison has nothing to sync shows that there is a
were using the command- at the moment, since no lock file that needs to be
line version of the tool files have changed manually removed

Synchronise your The network connection

files with Unison


is broken so Unison
cannot synchronise files

Learn how to use the Unison command-line tool to


synchronise files between computers quickly and reliably
Advisor Unison is an open source file synchronisation SSH service and works equally well on both UNIX
Mihalis Tsoukalos has over 15 years of UNIX tool for both text and binary files. It also has (Linux, Mac OS X etc) and Windows machines.
system administration and programming a GUI, but here were focusing on the only the It should be apparent that Unison was inspired
experience and has been using Linux
command-line version because its quicker and by the rsync utility. Unison differs from rsync
since 1993. He is also proficient in Oracle
database administration, Cisco IOS, gets the job done cleanly. Unison really shows in that the latter is a mirroring tool that needs
Cocoa and iOS programming. He always its capabilities when you are working with more to know in advance where the willing-to-keep
learns new things than one computer and you need synchronisation versions of the files are, whereas Unison is a
Resources across all of them.
Benjamin C Pierce led the creation of Unison at
synchronisation tool that identifies the files that
have been changed since the last sync process
Unison: www.cis.upenn.edu/~bcpierce/unison the University of Pennsylvania and it started life and decides the way that the changes are going to
Two networked UNIX machines as a research project. It can be used through the be propagated. In short, its smart.

42 www.linuxuser.co.uk
Synchronise your files with Unison
Use the Unison command-line tool to sync files between computers
TUTORIal

01 Installing Unison
Most Linux distributions have Unison
as a package ready for installation so that you
having a profile file does not prevent you from
adding extra command-line options (although
this article will not deal much with such options).
and is located inside the ~/.unison directory. The
following two lines to work on the same machine,
as they do not include a remote machine:
do not have to compile it. At the time of writing, In the rare event that you have troubles working root = /Users/mtsouk
the current stable version of Unison is 2.40.102. with Unison, you may run it using the -debug all root = /tmp
Note that every machine that is part of the command-line option so that you can better trace
synchronisation process must have a copy of and resolve errors.
the command-line version of Unison installed.
Additionally, this copy of Unison should be located
04 Synchronising files with
another computer
Given a profile name called articles.prf that
inside one of the directories of the default PATH
is located inside the ~/.unison directory, you
shell variable. Assuming youre on a Debian-
can tell Unison to use it by executing the
based system, simply type:
following command:
sudo apt-get install unison
$ unison articles
To find the version of Unison you are using, just
The remote machine declaration starts with
type the following command:
root = ssh://.
unison -version
There are rare occasions usually when the
user changed a file on both computers before
synchronising where Unison will not be able
to determine whether a file or directory has
changed on the local or the remote server. In
such situations, Unison kindly asks for your help
so that it will not mistakenly proceed using the
wrong version.

03 Synchronising files on the


same computer
Although Unison was initially developed with
synchronising files located on different machines
in mind, you can synchronise files located on
the same computer using one of the following
two methods:
Using localhost as the remote machine name.
Using only local directory paths for both

02 Unison profile files


Unison can run from the command line
without using any configuration files (profiles),
root = lines.
Your advisor prefers the second way as it does not
require the SSH server be up and running.
but using a profile greatly simplifies its use The Unison profile file is called localFiles.prf

43 www.linuxuser.co.uk
Tutorial Synchronise your files with Unison

07 The .unison directory


Most of the Unison housekeeping
happens inside the .unison directory which
resides in the users home directory.
Unison keeps the following data there:
Its profile files including the default profile
called default.prf.
Its backup files, if you decided to have central
backups.
The status file for each used profile.
The Unison log file, should you tell it to keep one.
You can put it anywhere you want but it is very
convenient for it to reside there.
Unison creates lock files there, during
synchronisations, which it deletes when finished.
Note: It is not recommended to synchronise the
whole .unison directory. Synchronising just the
profiles is okay.

08 A more advanced
Unison profile file
The contents of the advanced.prf file are as
follows:

05
root = /Users/mtsouk
Running Unison using a simple computer) that are going to participate in the
root = ssh://linode//home/mtsouk
profile file syncing process as well as the directories that are
considered the root directories for each machine. times = true
Some basic things you need to know about
After those important declarations, the actual batch = true
Unison profiles are:
directories that are going to be synced are listed. # Log file
The default backup level is 2, which controls
In this example we have just one directory (one logfile = /Users/mtsouk/.unison/
how many previous versions of each file are kept
path = line). Its full path is /Users/mtsouk/docs/ unison.log
not including the current version of the file. So the
article/working for the local machine and /home/ # Paths to synchronize
default backup level keeps two backup copies of
mtsouk/docs/article/working for the machine path = code/C
a file. The parameter for setting the backup level
called linode (an IP alias inside /etc/hosts). You # Backup files
is called maxbackups.
can have as many path entries as you want. All backup = Name *
You can tell Unison not to keep file backups by
files are synced except the ones that match backuplocation = central
not adding any backup options inside a Unison
the ignore option. You can also have as many maxbackups = 3
profile file.
ignore = lines as you want and can use regular ignore = Name {Thumbs.db}
Unison profile files support Unicode characters.
expressions in them. The backup option tells ignore = Name {.DS_Store}
The logfile option tells Unison to keep a log file
Unison to keep backups of all files. ignore = Path {Samples.lnk}
called unison.log inside the .unison directory.
Sometimes, network problems prohibit file
synchronisation, but Unisons error messages are
denoting the problem:
$ unison articles
Contacting server...
Connection closed by 109.xxx.yyy.zzz
Fatal error: Lost connection with
the server

06 Explaining the profile file


Lines starting with a # denote
comments and are not processed any further.
Exactly two lines must start with root =. They
declare the machines (one is always the local

44 www.linuxuser.co.uk
Synchronise your files with Unison
Use the Unison command-line tool to sync files between computers
TUTORIal

3. Copy the contents of the ~/.ssh/id_rsa.pub


file from your local server into the file
~/.ssh/authorized_keys found on the remote
server. One way of doing it is by executing the
following command:
$ cat ~/.ssh/id_rsa.pub | ssh linode
'cat >> .ssh/authorized_keys'

The next time you try to log into the remote


Linux server using SSH, you will be asked for 12 Unison hints and tips
The first two or three times you use a
new profile, double-check if everything works
the passphrase of step 1 for the last time.
From now on, you can log into the remote as expected.
Linux server by just typing ssh linode: You do not need to use every parameter that
$ ssh linode Unison supports, just the ones that will do
Linux (none) 3.9.3-x86_64-linode33 your job!

09 Explaining the advanced


profile file
The times = true line tells Unison to
#1 SMP Mon May 20 10:22:57 EDT 2013
x86_64
You can troubleshoot Unison using the
-debug all command-line option. It will
generate lots of output useful for debugging.
.
synchronise modification times. . The more you use Unison, the more you will
The maxbackups = 3 line tells Unison to keep . understand its practicality.
the current file version plus three backups of it. Last login: Wed Jul 31 18:46:23 2013 You should be very careful with your backup
The backup = Name * line tells Unison to from ppp-94-64-21-97.home.otenet.gr options, especially maxbackups, as it can take
back up every file. mtsouk@li140-253:~$ up too much space on your computer.
The backuplocation = central, which You can use Unison to securely exchange files
is the default option, tells Unison to keep all The first time you log into the remote server between computers.
backups in a central location. If neither the without typing your password, the following If a Windows machine is involved in the
backupdir preference nor the environment informative message will be on the screen: synchronisation process, be careful with file
variable UNISONBACKUPDIR are set, the Identity added: /Users/mtsouk/.ssh/ and directory permissions.
.unison/backup directory is used as the id_rsa (/Users/mtsouk/.ssh/id_rsa) For non-critical data files you may run Unison
backup location. If set to local, then all backups once a day, but for critical data you should run it
will be kept in the same directory as the more often.
original files. Unison cannot replace regular backups!
The batch = true option is a little tricky and When you are making a new profile, either
you should be careful with it as Unison will ask start simple or use an existing one as a starting
no questions at all and non-conflicting changes template. Add the extra functionality and
will be propagated whereas conflicts will be features while making sure that you always
skipped. Nevertheless, it is an essential option have a working profile.
if you want to use Unison as a cron job.
The ignore = Name {.DS_Store} line tells

11
Unison to not synchronise files that end with Two common Unison
.DS_Store. troubleshooting techniques

10 Using SSH without


giving a password
The single most time-saving thing you can
There are times when things do not work as
expected. Unison offers you many options that
can help you both find and solve problems.
do is to set up SSH so that you will not need The first option to try is the -testserver
to enter your password each time you want option that just connects to the remote server
to synchronise your files and directories. The and then exits without synchronising any files.
procedure is easy and involves the following The second thing to do is run the
three steps: following command:
1. Run ssh-keygen -t rsa $ ssh remote.machine.domain 'echo
You will have to enter a passphrase twice, so $PATH'
please do remember the passphrase! Two new The aforementioned command let you see
files are going to be created: ~/.ssh/id_rsa and whether the PATH is the same as when you
~/.ssh/id_rsa.pub. log in using ssh remote.machine.domain.
2. You may need to create a directory called If the problem is with the PATH, check if the
.ssh on the remote server if it does not option PermitUserEnvironment in /etc/ssh/
already exist. sshd_config is set to no and change it to yes.

45 www.linuxuser.co.uk
Tutorial Browse privately with Onion Pi

This isnt a Using not much more than a Hook into the internet just
hardware hack a Raspberry Pi, you can route about anywhere theres
spare SD card can one or more systems through an internet connection a
be used for the Tor a Tor-enabled access point, relatives house, hotel
router, and other guaranteeing anonymity rooms and more
SD cards can be
used for different
functions without
any problems

Browse privately Connect everything

with Onion Pi
over a wireless
network no need to
directly connect to
the Pi with a cable

Turn your Raspberry Pi into a highly secure and


very portable router to keep your system safe and
your browsing anonymous, wherever you are
Advisor We showed you in issue 129 how
to turn your Raspberry Pi into the
Tor to create and secure a wireless
access point using just a Raspberry Pi.
Rob Zwetsloot models ultimate portable wireless router, This project is fairly straightforward:
complex systems and
is a web developer requiring very little power and giving after setting up the wireless access
proficient in Python, you a wireless network wherever point, we install Tor and do some basic
Django and PHP. He theres the most basic of internet setup tasks so that it routes traffic
loves to experiment
with computing
connections. What if its not enough to properly, and securely. This will keep
know you can search the web, though? you anonymous online a handy
Resources What if you want to be wholly secure feature in a time of privacy concerns
A Raspberry Pi as you do it? Then its time to upgrade all around the web.
the router with Tor to protect your When the Pi is not connected to
Raspbian: www.raspberrypi.org/downloads privacy on the internet. the internet, it should still function as
Compatible Wi-Fi adaptor: This Onion Pi, as dubbed by a wireless router, allowing at the very
www.adafruit.com/products/814 Adafruit, combines Raspbian and least a wireless LAN in your location.

46 www.linuxuser.co.uk
Browse privately with Onion Pi
Turn your Raspberry Pi into a Tor-enabled wireless router
TUTORIAL

06 Set up DHCP
Now we need to configure the DHCP
server. Edit the configuration file with:

$ sudo nano /etc/dhcp/dhcpd.conf

And start by putting a # in front of the two option


domain-name entries, then remove the # in front
of authoritative, seven lines down.

07 Server address
At the end of the configuration file, add
the following:

subnet 192.168.42.0 netmask


255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address
192.168.42.255;
option routers 192.168.42.1;
default-lease-time 600;

01 04
Install Raspbian SSH connection max-lease-time 7200;
Raspbian is the Raspberry Pi distro Plug your USB wireless adapter into option domain-name "local";
well be using for the Onion Pi. Download the zip the Pi and turn it back on. On another computer option domain-name-servers 8.8.8.8,
file, extract the image and then apply it to an SD connected to the same network, open a terminal 8.8.4.4;
card using: or type into the command line: }

$ dd bs=4M if=[version number]- $ ssh [user]@[IP address] Save and exit.


wheezy-raspbian.img of=/dev/[SD card
location] Then enter the password for your Raspbian if it
asks for it.
You can also use NOOBS to install Raspbian if
you wish.

02 Set up Raspbian
Go through the initial Raspbian setup
and make sure to turn on the SSH server, and to

05
disable autoboot to desktop this is unnecessary Install DHCP
and will only use extra power. You can also tell it to To make life easier for any system
fill up the rest of the card if theres room for it. connecting to the Pi access point, we need to

03 Pi IP install a DHCP server to it. We do this with:


Well be accessing your Raspberry Pi via
SSH to set it up. To do this we need to know its IP $ sudo apt-get install hostapd isc-

08
address you can find it by typing ifconfig into dhcp-server DHCP server
the command line. Make a note of it and turn off Edit the server configuration files
your Pi. DHCP will automatically assign IP addresses to so that its set to work in conjunction with the
network-attached devices, meaning you wont wireless adaptor:
need static IPs.
$ sudo nano /etc/default/isc-dhcp-
server

Scroll to INTERFACES and change it to:

INTERFACES="wlan0"

47 www.linuxuser.co.uk
Tutorial Browse privately with Onion Pi

09 Incoming Wi-Fi
We need to set up the Wi-Fi adaptor to be
both static and accept incoming signals. First:
14 Network addressing
Setting up a NAT will allow multiple clients
to connect. To do this, run:

$ sudo nano /etc/network/interfaces $ sudo nano /etc/sysctl.conf

Put a # in front of iface wlan0 and following And add to the bottom of the file:
lines with wpa roam, iface default and any other
affecting wlan0. net.ipv4.ip_forward=1

Save this, and then finish by running:

$ sudo sh -c "echo 1 > /proc/sys/


net/ipv4/ip_forward"

10 Static IP
Now give the wireless interface a static 12 WLAN configuration
interface=wlan0
driver=rtl871xdrv
IP after the line allow-hotplug wlan0, enter
the following: ssid=[access point name]
hw_mode=g

15
iface wlan0 inet static channel=1 IP tables
macaddr_acl=0 Run the following three commands to
address 192.168.42.1 auth_algs=1 make sure the internet connection is forwarded
netmask 255.255.255.0 ignore_broadcast_ssid=0 correctly:
wpa=2
Save and exit, and then set wlan0s address with: wpa_passphrase=[password] sudo iptables -t nat -A POSTROUTING
wpa_key_mgmt=WPA-PSK -o eth0 -j MASQUERADE
$ sudo ifconfig wlan0 192.168.42.1 wpa_pairwise=TKIP sudo iptables -A FORWARD -i
rsn_pairwise=CCMP eth0 -o wlan0 -m state --state

13
RELATED,ESTABLISHED -j ACCEPT
Hostapd
sudo iptables -A FORWARD -i wlan0 -o
After saving and exiting, we need to edit
eth0 -j ACCEPT
hostapd to point it to this new file. Open it with:

$ sudo nano /etc/default/hostapd 16 Apply configuration


So that this still works after a reboot, type:

And then find the line #DAEMON_CONF="". $ sudo sh -c "iptables-save > /etc/
Remove the #, and change it to: iptables.ipv4.nat"

11 WLAN creation DAEMON_CONF="/etc/hostapd/hostapd. Then add to the end of /etc/network/interfaces:


We need to create a new file that holds all conf" up iptables-restore < /etc/iptables.
the information for our wireless network. We are
ipv4.nat
going to make it password protected so that only
the people we want to can access it. To create the
file, start with:

$ sudo nano /etc/hostapd/hostapd.


conf

And then enter the text from the next step.

48 www.linuxuser.co.uk
Browse privately with Onion Pi
Turn your Raspberry Pi into a Tor-enabled wireless router
TUTORIal

17 Wi-Fi final
Finally, set it up as a daemon so it runs
at boot with the following commands:

sudo service hostapd start


sudo service isc-dhcp-server start
sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server
enable

And the wireless access point part will be


finished.

18 Install Tor
After a reboot, we now need to install
Tor. Do this simply with:

$ sudo apt-get install tor

Once its installed, youll need to edit the Tor


config file with:

$ sudo nano /etc/tor/torrc

Follow the next step to add all the necessary If you want to keep SSH open to connect $ sudo sh -c "iptables-save > /etc/
information to it. remotely, youll need to make an exception for iptables.ipv4.nat"
that with:

19 Tor configure
Put this below the FAQ comment: $ sudo iptables -t nat -A PREROUTING 23 logging
We should create a log file in case
you need to debug later. To do this, use these
-i wlan0 -p tcp --dport 22 -j
Log notice file /var/log/tor/ three commands:
REDIRECT --to-ports 22
notices.log

21
VirtualAddrNetwork 10.192.0.0/10 Reroute $ sudo touch /var/log/tor/notices.
AutomapHostsSuffixes .onion,.exit Route all DNS traffic first, using: log
AutomapHostsOnResolve 1 $ sudo chown debian-tor /var/log/
TransPort 9040 $ sudo iptables -t nat -A PREROUTING tor/notices.log
TransListenAddress 192.168.42.1 -i wlan0 -p udp --dport 53 -j $ sudo chmod 644 /var/log/tor/
DNSPort 53 REDIRECT --to-ports 53 notices.log
DNSListenAddress 192.168.42.1 You can also check it with:
And then route any TCP traffic with:

$ sudo iptables -t nat -A PREROUTING $ ls -l /var/log/tor

24
-i wlan0 -p tcp --syn -j REDIRECT Secure the router
--to-ports 9040 Finally, we can activate the Tor service
so that we can start using the access point
securely with:

$ sudo service tor start

You can check this if you wish with:

$ sudo service tor status

20 Table flush
We now need to flush the current IP
tables so that we can get the routing to go
22 Check and save
You can check the table setup with:
To make it turn on at boot, you simple add it to
rc.d with:

through Tor. First of all, do: $ sudo iptables -t nat -L $ sudo update-rc.d tor enable

$ sudo iptables -F If youre happy with it, save it to the NAT file like
$ sudo iptables -t nat -F before with:

49 www.linuxuser.co.uk
Have you got
unwanted monitors?

4,000 monitors needed for


schools in Africa and Latin America
WEEE compliance guaranteed
0% to landfill policy
All legal liabilities covered
Data wiped to UK military standards on all PCs

www.computeraid.org/donate
020 8361 5540
enquiries@computeraid.org
Or find us on...

Registered Charity No. 1069256 Registered Company No. 3442679


The only Linux magazine for open source developers
100% FOSS focused Features Tutorials Sample code

If it wasnt
open source, if it
wasnt GPL, there
wouldnt be the
20,000 plug-ins
that have been
written for it
Mark Little talking about
WordPress

51
Mike Little celebrates receiving his outstanding contribution award

The other half


of WordPress
With ten years under its belt, WordPress has firmly
cemented its place in the hearts of bloggers. But what next
for its co-founder Mike Little? David Crookes finds out
We are on a tram to another. We decide to sit in a coffee shop and being made where you get someone just filming
Manchester, tapping away he grabs a sandwich before telling us about what they are doing and there are lots of ums
on our phone as we update his latest venture, which is unsurprisingly and ahs and backtracking. My screencasts
one of our blogs, engrossed given the software is used by 18.9 per cent of wont be like that and people will certainly get
in the words and thinking the top 10 million websites very much related value for money.
little about the underlying to WordPress. Little, who also teaches WordPress to classes
code which is making all of this possible. Just Little is currently working on a series of face-to-face, continues to work with WordPress
as the last few words are written, the tram screencasts which showcase how WordPress for professional clients too. After all, if he
stops and we make our way up the escalator can be used, explaining the fundamentals of it cannot produce a killer website for companies
to Piccadilly Station about to meet the man to encourage more people to get involved with and organisations using the software, then
who created the behemoth that is WordPress, blogging using the platform. Its a slow process nobody can. It is fitting, then, that he has worked
the very blogging platform we had been using it takes about an hour to edit a minutes with Downing Street on government sites. He
throughout the journey. footage, he says but hes getting there. The appears most proud of a science-engagement
Our meeting is being held at a railway station idea is that the screencasts will form a paid-for site for children called Im A Scientist, Get
because Mike Little, who is from Stockport, is online course. I want them to be better than Me Out Of Here, which has spun off into Im
a busy man. He has already had one meeting anything else that is out there, so they have to An Engineer. I really enjoy doing these, he
before we shake hands and he is due to have be done right, he says. There is a lot of rubbish says, explaining that his entire freelance

52 www.linuxuser.co.uk
The other half of WordPress
The story of WordPress co-founder, Mark Little

LITTLE AND LINUX


Mike Little is a long-term user of Linux. Ive
been into Linux since the early days, he
recalls. I could see that the openness, the
ability to look at code, to modify [it] was
making better software So Ive always been
passionate about it and I just absolutely think
its the right thing to do.
He has fond memories of the days when
Linux needed to be downloaded from FTP
sites and stuck on several 3.5-inch floppies.
Im going back to 1.something series kernels,
so right from when there probably were only
three or four distributions. Slackware was one
but I dont even think the likes of Debian had
started in the early days. I remember Red Hat
starting so I was into it before that.
Matt Mullenwegs WordPress.com website is run by his company Automattic Little had been involved in a project called
DJGPP, which was a port of the GNU Compiler
career has been based around domain that was up for renewal.

66%
Collection onto 16-bit DOS. It is, he concedes,
WordPress since he left full-time Another programmer, Matt a ridiculous undertaking in hindsight, but
employment in 2008. Mullenweg, also used b2/ it meant developer tools could be obtained
WordPress has, therefore, cafelog, or, as it was more on DOS without having to shell out money. I
shaped his life. In between commonly known, b2, think that was before I even got the world wide
mouthfuls, he tells us and he was concerned web, so at that time I had a modem but I was
all about the WordPress
project, barely pausing for
Proportion of all not only about Valdrighis
disappearance but
dialling up to bulletin boards and getting
software that way, he explains.
breath, and there is little WordPress sites also about the lack of And then when I got onto the internet
doubt that he is proud of the
part he played in the initial
that are in development of b2. He
posted an article on his blog
I just kind of continued in that vein. So Id

years of WordPresss inception. English called The Blogging Software


already understood that this DJGPP was a
port of these GNU tools so I started looking
If there was any doubt, then the Dilemma which discussed how at what they were and how I could use those
snazzy WordPress T-shirt hes wearing he had come to be using b2, primarily and eventually got brave enough to partition
at our meeting certainly puts paid to that. because it was the best of the bunch and my Windows machine and get Linux booted
something he was able to develop. Mike Little on that. Before that I used to boot it from a
Before WordPress spotted this blog post and responded, asking floppy but yes, eventually I went over to dual
Little has been programming professionally Mullenweg if he would be interested in forking booting into Linux and in 1998 I went over at
since 1990. His first six years were spent at b2. Mullenweg said he would. The pair then got home full-time to Linux By the time I had a
an industrial software house called Pantek together, albeit remotely over the internet. decent laptop, I started with Debian but my
in Stockport, where he became responsible Id communicated with Matt a couple of last three laptops have run Ubuntu.
for a team of six and developed Visual Basic times before because he had a website with
apps, learned C++ and gained experience in a really good gallery on it and Id emailed him
DOS, Windows SDK, assembler, Novell, TCP/IP
and Microsoft networks. After leaving Pantek,
to ask him about the software, recalls Little.
Id actually communicated with him on the b2 That first release
he went on to work at various other software
companies in the Greater Manchester area, but
forums as well, but I didnt know he was the
same person as the one who ran the gallery of WordPress had
he was also an early blogger.
He used software called b2/cafelog which
site. So when I saw his blog post about b2,
I was interested. As it turned out, I was the a couple of extra
had been written by Michel Valdrighi, the first
Corsican blogger. A small community had built
only person who responded to his posting at
the time.
features Id already
up around the software with around 2,000 active
users on the forum, but development of b2/ Version one created for b2
cafelog suddenly ground to a halt when Valdrighi Mullenweg and Little took the b2 software
disappeared, leaving behind an app that had and began to work on it, fixing bugs and adding
a few bugs, a couple of security issues and a extra features. Then Valdrighi reappeared. He

53 www.linuxuser.co.uk
declared Mullenweg and Littles software as killer feature, Little says, came in the guise of User-friendliness
the official successor to b2. It turns out hed hooks. It meant you could write additions to Little and Mullenweg saw WordPress as
been made redundant or something like that, the product without having to modify the code, an evolving product. Little worked on doing
had to give up his flat, gone back to his parents and that was something that only really big what he could to eliminate the ability to make
who didnt even have internet and so on, grown-up software did, like some of the Java mistakes, which he believes was a crucial step
smiles Little. So it was just the real world was Stacks, says Little. This ability to actually forward. With the original b2, you could lose
much more important than a bit of software. change the way it behaves and add things to your settings, he says. But with WordPress, I
WordPress was thus born. it without having to touch any of the core files added the config sample PHP and it just took
It was January 2003. Little had been learning was crucial. Its still the hardest thing, I think, for that ability to make a mistake away. I took what
PHP and he felt he would work his way around b2 new developers to get their heads round how it was the original b2 settings file and created an
and make alterations. No software is perfect, works, but I think thats what made it Options interface for it. It was another

18.9%
so it was just a case of thinking of things that so much easier. file, you didnt have to fiddle with
we wanted to add to it, says Little. That first He said it made the process it - you didnt have to know how
release of WordPress had a couple of extra of updating the software so to edit these files and FTP
features that Id already created for b2 and much easier. Prior to that, them back up to your server
the same for Matt: hed had a couple of extra with anything like Drupal and stuff like that. I think
features that hed added to b2. Wed shared or any of those tools, The percentage all those bits helped make
these things on the forums and we kind of whenever there was an of the 10 million it easier, made it harder
update you were in danger
incorporated those into the core project. And
yeah, we just took it from there. of losing your changes
websites in the to cock up and I think that
all helped.
One of the biggest changes was the because youd modified world that run The need to be user-
introduction of Pages, which made a massive original files to call your stuff WordPress friendly was at the forefront
difference to WordPress and set it apart from or to add somebody elses stuff of the minds of both developers.
its rivals at the time. It enabled WordPress to in. Youd stick these function calls in It was also important for them that
become more than blogging software. But the there. It meant that as soon as you got the WordPress, like b2, was an open source
new version, if you just literally FTPed the new project. They loved that b2 operated under a
one over the top of the old one, you were going to General Public License, which meant they had
lose your stuff and lose your modifications. So I the freedom to take the code, change it and
TAKING INSPIRATION think that was probably one of the key features distribute it to other people. They loved that
WordPress was not created in isolation. and I dont think its necessarily something it was free too. Ive always been a huge open
Although Little and Mullenweg worked on that people appreciate because these days source advocate, says Little. Matt was kind of
their own, with the expanse of the Atlantic they just never see the problem. They update new to the open source idea, but that was one of
ocean separating them, they did look at other WordPress or they update the plug-ins and oh, the reasons behind him choosing to use b2.
blogging software being created at the time its the new version, and nothings gone wrong. Little attributes the popularity of WordPress
and they took inspiration from it. And yet before then you had to save those to its open source nature (if it wasnt open
There was definitely a lot of studying files you modified before you updated to the source, if it wasnt GPL, there wouldnt be the
of rivals and playing catch-up, seeing what new software. 20,000 plug-ins that have been written for it or
other people were doing, Little says. For Mullenweg and Little continued to work on the 10,000 themes, he says) and it matters not
a very long time there was a lot of blogging WordPress and the first release came in May of to him that he has not made any direct money
software and certainly you would see Blogger that year. from WordPress. Nobody does, he says. Its
or Moveable Type with features that were
cool and that we thought we might add to
WordPress. Eventually it started going the If it wasnt open source, if it wasnt GPL,
other way round as well and these other apps
were copying features that had been added there wouldnt be the 20,000 plug-ins that
to WordPress.
have been written for it

54 www.linuxuser.co.uk
The other half of WordPress
The story of WordPress co-founder, Mark Little

OUTSTAnDinG
COnTRiBUTiOn
TO DiGiTAL
At SASCon 2013, Mike Little was presented
with the inaugural Outstanding Contribution
to Digital award for his part in co-founding
and developing WordPress.
The award, which was handed out at
a conference at the new Manchester
Metropolitan University Business School,
acknowledged his instrumental role in
setting up and developing the first version
of WordPress, which has become the most
popular content management system on
the internet.
Richard Gregory, one of SAScons
founders, said: There isnt a single digital
marketing agency that hasnt made
generated income by building WordPress
websites, and we are honoured to be able to
recognise him with this award.
n The original posting, The Blogging Software Dilemma, on Mat Mullenwegs website and
Mike Littles response

not sold and yes, I continued in my day job. Matt Up until the first release, the development the morally right thing to do, for me. The fact
went [to work] for CNET, which had just started team consisted of just Mullenweg and Little, but is that, at the time, in the 1970s and 1980s,
using WordPress for just a couple of things, and five people were working on the project by the software companies were effectively creating
they actually had him doing a standard software end of 2003 and it continued to grow after that. artificial scarcity, based on intellectual ideas
development job. But they paid for him to work By the end of 2005, Little wasnt able to stay that were almost free to reproduce. Back then
one day a week on WordPress itself and I think involved. I had issues at home, real-life issues firms were making floppy disks and putting
it was through working there that he met a guy which meant that I couldnt spend the time them in boxes and getting manuals printed and
called Tony Schneider, who had just working on this thing voluntarily, he they were charging 500 or 600 for a product
sold some software to Yahoo! for says. It was still a very techy thing, that had just 30 or 40 worth of materials.

4 billion
25m or something like. Matt a very geek thing, it wasnt as As things moved on, it got easier and easier to
had started Automattic at good and as user-friendly distribute software online where the distribution
this point. Schneider later as it has become today costs and the reproduction costs approach zero,
managed to help raise and it certainly wasnt so to then charge artificial amounts on top of
funding for him and joined The number of page as prominent. that just seemed like the wrong thing to do.
the service that eventually
became WordPress.com.
views of WordPress Cash, he insists, is
something that does not
He hopes that future generations go down the
same path and release open source software.
But me, I continued in websites from motivate him, however. I But first, he says, I think it is crucial that we
my day job up until 2008. April 2012 to need to pay the bills and we just get kids learning how to code. There are

Carrying on April 2013 need to eat, he says. I am


the breadwinner of the house
some good moves in that direction and I love
what is being done with the Raspberry Pi.
Little considered becoming and I always have been, but I just Suddenly, a school cant say it cannot afford to
part of WordPress.com, which is a wish I could put that side of things in buy lots of computers to experiment with. These
blog web hosting service provider owned by place and do what interests me from that point are costing 25 each. Its a great time to be in
Automattic, but this was prior to the funding on. Theres no doubting my passion for open computing and I feel its good to be putting back
and the company couldnt afford to pay him a source computing. in and helping people learn.
wage. Today it is financially supported via paid Indeed, he has read up on the philosophy Mike Littles new website is at mikelittle.org
upgrades, VIP services and advertising and can behind the General Public License and he has but he also runs his company site, zed1.com.
pay wages, but in the early days there wasnt devoured Richard Stallmans story of how he
much cash for this and the bulk of the fund- created the free software movement. I not only
raising efforts went on infrastructure. found it very inspiring, he says, it just seemed

55 www.linuxuser.co.uk
Tutorial MakeextensionsforXBMCwithPython


Rating (only available for
Current media hosted plug-ins)
selection

List of
installed
plug-ins

Configure
Localised
launcher
description string

Makeextensionsfor Opens
changelog for

XBMCwithPython
the plug-in

Python is the worlds most popular easy-to-use open source


language. Learn how to use it to build your own features for
XBMC, the worlds favourite FOSS media centre
Advisor a solid community behind it. It supports almost
all major platforms, including different hardware
the look and feel of just about every facet of
the package.
KunalDeois a veteran open source developer. architectures. It is available for Linux, Windows, Depending upon which category your
Currently he is leading two open
Mac OS X, Android, iOS and Raspberry Pi. extension fits, you will have to create the
source projects: WinOpen64 and
KUN Wiki. He is also a KDE developer. In these pages we will learn to build extensions extension directory accordingly. For example
He has contributed to many open for XBMC. Extensions are a way of adding Plug-ins:
source projects, including KDE- features to XBMC without having to learn the plugin.audio.ludaudi: An audio plug-in
Solaris, Belenix and Openmoko
core of XBMC or alter that core in any way. One plugin.video.ludvidi: A video plug-in
Resources additional advantage is that XBMC uses Python script.xxx.xxx: A program
as its scripting language, and this can be also In this tutorial we will build an XBMC plug-in
XBMC: www.xbmc.org/download
used to build the extensions. This really helps called LUD Entertainer. This plug-in will provide a
Python2.7x new developers get involved in the project since nice way to watch videos from Reddit from within
PythonIDE(optional) Python is easy to learn compared to languages XBMC. Our plug-in will show various content such
like C/C++ (from which the core of XBMC is made). as trailers and documentaries from Reddit. Well
XBMC supports various types of extensions (or also allow our users to add their own Subreddit.
XBMCisperhapsthemostimportantthingthat Add-ons): Plugins, Programs and Skins. Plugins Each video can then be categorised as Hot, New,
has ever happened in the open source media add features to XBMC. Depending on the type Top, Controversial etc. With this plug-in we will
centre space. It started its life on the original of feature, a plug-in will appear in the relevant demonstrate how easy it is hook into XBMCs
Xbox videogames console and since then it has media section of XBMC. For example, a YouTube built-in method to achieve a very high-quality
become the de facto software for multimedia plug-in would appear in the Videos section. user experience.
aficionados. It also has been forked into many Scripts/Programs are like mini-applications for Due to space limitations, we arent able to print
other successful media centre applications such XBMC. They appear in the Programs section. the full code here. You are highly recommended
as Boxee and Plex. XBMC has ultimately grown Skins are important since XBMC is a completely to explore the cover disc to access the complete
into a very powerful open source application with customisable application you can change code, which has many other amazing functions.

56 www.linuxuser.co.uk
Make extensions for XBMC with Python
Use Python to create a new plug-in for XBMC
TUTORIal

01 Preparingthedirectorystructure
As we have mentioned previously, each
XBMC extension type follows a certain directory
version="2.1.0"/>
<import addon="plugin.video.
youtube" version="3.0.0"/>
05 Settingupplug-inmetadata
Metadata about the plug-in is provided in
<extension point="xbmc.addon.metadata">. The
naming convention. In this case we are building <import addon="plugin.video.vimeo" following are the important elements
a video plug-in, so the plug-in directory name version="2.3.0"/>
would be plugin.video.ludlent. But thats just the <import addon="plugin.video. <platform>: Most of the time, XBMC extensions
root directory name we will need several other dailymotion_com" version="1.0.0"/> are cross-platform compatible. However, if you
folders and files as well. </requires> depend on the native platform library that is only
The following describes the directory structure of available on certain platforms then you will need
LUD Linux Entertainer: In the above code we have added a dependency to set the supported platforms here. Accepted
plugin.video.ludent Root Plugin directory to a library called xbmc.python version values for the platform are: all, linux, osx, osx32,
|-- addon.xml 2.1. Currently it is added as a mandatory osx64, ios (Apple iOS) , windx (Windows DirectX),
|-- changelog.txt dependency. To make the dependency wingl (Windows OpenGL) and android.
|-- default.py optional you will need to add optional="true";
|-- icon.png eg <import addon="kunal.special" <summary lang="en">: This gives a brief
|-- LICENSE.txt version="0.1.0" optional="true" /> description of the plug-in. Our example sets the
|-- README In the above example we have added core language attribute as English, but you can use
`-- resources dependency xbmc.python to 2.1.0 because its other languages too.
|-- lib the version shipped with XBMC version Frodo <description>: A detailed description of the
`-- settings.xml 12.0 and 12.1 . If you were to add xbmc.python plug-in.
to 2.0 then it would only work in XBMC Eden 11.0 <website>: Webpage where the plug-in is hosted.

02 Creatingaddon.xml
An addon.xml file needs to be created in
the root of the extension directory. The addon.xml
and not in the latest version.
For the current version of XBMC 12.1, the
following versions of core XBMC components
<source>: Source code repository URL. If you are
hosting your plug-in on GitHub, you can mention
the repository URL here.
file contains the primary metadata from a XBMC are shipped: <forum>: Discussion forum URL for your plug-in.
extension. It contains overview, credits, version xbmc.python 2.1.0 <email>: Author email. You can directly type email
information and dependencies information about xbmc.gui 4.0.0 or use a bot-friendly email address like max at
the extension. xbmc.json 6.0.0 domain dot com.
xbmc.metadata 2.1.0
The root element of addon.xml is the <addon>
element. It is defined as:
xbmc.addon 12.0.0
In addition to xbmc.python we are also adding
some third-party plug-ins as dependencies,
06 Settingchangelog,icon,fanart
andlicence
We need a few additional files in the plug-in
<addon id="plugin.video. such as plugin.video.youtube. These plug-ins directory
ludent" name="LUD HSW Viewer" will be installed automatically when we install
version="0.0.1" provider- plugin.video.ludent. changelog.txt: You should list the changes made
name="LUDK"> to your plug-in between releases. The changelog
rest of the content is placed here
</addon> 04 Settinguptheproviderand
entrypoint
Our extension is supposed to provide the video
is visible from the XBMC UI.

An example changelog:
Here, id is the identifier for the plug-in, so content for XBMC. In order to convey that, we 0.0.1
it should be unique among all the XBMC have to set up the following element: - Initial Release
extensions, and id is also used for the directory 0.0.2
name; version tells XBMC the extension <extension point="xbmc.python. - Fixed Video Buffering Issue
version number, which helps in its ability to pluginsource" library="default.
deliver automatic updates XBMC follows the py"> icon.png: This will represent the plug-in in the
Major.Minor.Patch versioning convention; name is <provides>video</provides> XBMC UI. It needs to be a non-transparent PNG
the English title of the plug-in. </extension> file of size 256x256.
Note: Steps 3 to 5 cover entries that need to be
added within the addon.xml file. Here, the library attribute sets up the plug-in fanart.jpg (optional): The fanart.jpg is rendered
entry point. In this example default.py will be in the background if a user selects the plug-in

03 addingdependencyinformation
Dependency inside an extension is
managed using the <requires> element.
executed when the user activates the plug-in.
The <provides> elements sets up the media
type it provides. This also gets reflected in the
in XBMC. The art needs to be rendered in HDTV
formats, so its size can range from 1280x720
(720p) up to the maximum 1920x1080 (1080p).
placement of the plug-in. Since ours is a video
<requires> plug-in, it will show up in the Videos section
<import addon="xbmc.python" of XBMC.

57 www.linuxuser.co.uk
Tutorial MakeextensionsforXBMCwithPython


The following are a few important settings resource/language/english/string.xml
types that you can use example:
text: Used for basic string inputs.
License.txt: This file contains the licence of ipaddress: Used to collect internet addresses. <?xml version="1.0" encoding="utf-8"
the distributed plug-in. The XBMC project number: Allows you enter a number. XBMC will standalone="yes"?>
recommends the use of the Creative Commons also provide an on-screen numeric keyboard for <strings>
Attribution-ShareAlike 3.0 licence for skins, the input. <string id="30001">Add subreddit</
and GPL 2.0 for add-ons. However, most of the slider: This provides an elegant way to collect string>
copyleft licences can be used. integer, float and percentage values. You can get <string id="30002">Hot</string>
the slider setting in the following format: <string id="30003">New</string>
Note: For the purpose of packaging, extensions/ <string id="30004">Top</string>
add-ons/themes/plug-ins are the same. <setting label="21223" type="slider" <string id="30005">Controversial</
id="sideinput" default="10" string>
07 Providingsettingsfortheplug-in
Settings can be provided by the file
resources/settings.xml. These are great for user-
range="1,1,10" option="int" /> <string id="30006">Hour</string>
<string id="30007">Day</string>
In the above example we are creating a slider with <string id="30008">Week</string>
configurable options. min range 1, max range 10 and step as 1. In the <string id="30009">Month</string>
option field we are stating the data type we are <string id="30010">Year</string>
Partial:resources/settings.xml interested in we can also set option to "float" </strings>
or "percent".
<settings> As you may have seen in the settings.xml
<category label="30109"> bool: Provides bool selection in the form of on example, all the labels are referring to string
<setting id="filter" type="bool" or off. ids. You can have many other languages as
label="30101" default="false"/> file: Provides a way to input file paths. XBMC will well. Depending upon the language XBMC is
<setting type="sep" /> provide a file browser to make the selection of file. running in, the correct language file will be
<setting id="showAll" type="bool" If you are looking to make selection for a specific loaded automatically.
label="30106" default="false"/> type of file you can use audio, video, image or Post XBMC Frodo (12.1), strings.xml will be
<setting id="showUnwatched" executable instead of file. deprecated. Post Frodo, XBMC will be moved
type="bool" label="30107" to a GNU gettext-based translation system;
default="true"/> folder: Provides a way to browse for a folder gettext uses PO files. You can use a tool called
<setting id="showUnfinished" xbmc-xml2po to convert strings.xml into
type="bool" label="30108" Example: equivalent PO files.
default="false"/> <setting label="12001" type="folder"

09
<setting type="sep" /> id="folder" source="auto" Buildingdefault.py
<setting id="forceViewMode" option="writeable"/> Since our plug-in is small, it will all be
type="bool" label="30102" Here, source sets the start location for the contained inside default.py. If you are developing
default="true"/> folder, while option sets the write parameter for a more complex add-on then you can create
<setting id="viewMode" type="number" the application. supporting files in the same directory. If your
label="30103" default="504"/> library depends upon third-party libraries, you
</category> sep & lsep: sep is used to draw a horizontal line have two ways to go about it. You can either place
<category label="30110"> in the setting dialog; lsep is used for drawing the third-party libraries into the resources/lib
<setting id="cat_hot" type="bool" a horizontal line with text. They do not collect folder; or bundle the library itself into a plug-in,
label="30002" default="true"/> any input but are there for building better user then add that plug-in as the dependency in the
<setting id="cat_new" type="bool" interface elements addon.xml file.
label="30003" default="true"/> Our plug-in works with reddit.tv. This is the
</category> <setting label="21212" type="lsep" website from Reddit which contains trending
</settings> /> videos shared by its readers. Videos posted on
Reddit are actually sourced from YouTube, Vimeo
Here, label defines the language id string which and Dailymotion.

08
will then be used to display the label. id defines Languagesupport We will be starting default.py with the following
the name which will be used for programmatic Language support is provided in imports:
access. type defines the data type you want the form of the strings.xml file located in
to collect; it also affects the UI which will be resources/languages/[language name]. This import urllib
displayed for the element. default defines the approach is very similar to many large software import urllib2
default value for the setting. You should always projects, including Android, where static strings
use a default value wherever possible to provide a are never used. import xbmcplugin
better user experience.

58 www.linuxuser.co.uk
Make extensions for XBMC with Python
Use Python to create a new plug-in for XBMC
TUTORIal

import xbmcgui idFile idPath strFilename playCount lastPlayed dateadded


import xbmcaddon
1 1 plugin://plugin. 2013-08-06 23:47
Apart from xbmcplugin, xbmcgui and 2 2 plugin://plugin. 1 2013-08-07 22:42
xbmcaddon, the rest are all standard Python
3 2 plugin://plugin. 1 2013-08-08 00:09
libraries which are available on PyPI (Python
Package Index) via pip. You will not need to install 4 2 plugin://plugin. 1 2013-08-08 00:55
any library yourself since the Python runtime for 5 2 plugin://plugin. 1 2013-08-08 00:58
XBMC has all the components built in.
urllib and urllib2 help in HTTP communication.
socket is used for network I/O; re is used
for regular expression matching; sqlite3 is
12 Buildinghelperfunctions
In this step we will look at some of the
important helper functions.
The above table is an example of a files table.

addSubreddit(): Our plug-in allows users to add


the Python module for accessing an SQLite their own Subreddit. This function takes the
embedded database; xbmcplugin, xbmcgui and getDbPath(): This returns the location of the Subreddit input from the user, then saves it in
xbmcaddon contain the XBMC-specific routine. SQLite database file for videos. XBMC stores the subreddits file inside the addon data folder.
library and playback information in SQLite DB

10 Initialising
During the initialisation process, we will
be reading various settings from settings.xml.
files. There are separate databases for videos
and music, located inside the .xbmc/userdata/
Database folder. We are concerned with the
The following sets the subreddits file location:
subredditsFile = xbmc.
translatePath("special://profile/
Settings can be read in the following way: videos DB. It is prefixed with MyVideos addon_data/"+addonID+"/subreddits")
this translates into .xbmc/userdata/
addon = xbmcaddon.Addon() def getDbPath(): addon_data/plugin.video.ludent/
filterRating = int(addon. path = xbmc. subreddits
getSetting("filterRating")) translatePath("special://userdata/
filterVoteThreshold = int(addon.getS Database") def addSubreddit():
etting("filterVoteThreshold")) files = os.listdir(path) keyboard = xbmc.Keyboard(,
latest = "" translation(30001))
In order to read settings of type bool you will need for file in files: keyboard.doModal()
to do something like: if file[:8] == MyVideos if keyboard.isConfirmed() and
and file[-3:] == .db: keyboard.getText():
filter = addon.getSetting("filter") if file > latest: subreddit = keyboard.
== "true" latest = file getText()
return os.path.join(path, fh = open(subredditsFile,
We are also setting the main URL, plug-in handle
latest) a)
and the user agent for it:
fh.write(subreddit+\n)
pluginhandle = int(sys.argv[1]) getPlayCount(url): Once we have the database fh.close()
urlMain = "http://www.reddit.com" location, we can get the play count using a
userAgent = "Mozilla/5.0 (Windows NT simple SQL query. The MyVideo database This function also demonstrates how to take
6.2; WOW64; rv:22.0) Gecko/20100101 contains a table called files, which keeps a a text input from the user. Here we are calling
Firefox/22.0" record of all the video files played in XBMC by the Keyboard function with a text title. Once it
opener = urllib2.build_opener() filename. In this case it will be URL. detects the keyboard, it writes the input in the
opener.addheaders = [(User-Agent, subreddits file with a newline character.
userAgent)] dbPath = getDbPath()
conn = sqlite3.connect(dbPath) getYoutubeUrl(id): When we locate a YouTube

11 Readinglocalisedstrings c = conn.cursor() URL to play, we pass it on to the YouTube plug-in


As mentioned, XBMC uses strings.xml to (plugin.video.youtube) to handle the playback. To
serve up the text. In order to read those strings, def getPlayCount(url): do so, we need to call it in a certain format
you will need to use getLocalizedString. c.execute(SELECT playCount FROM
files WHERE strFilename=?, [url]) def getYoutubeUrl(id):
translation = addon. result = c.fetchone() url = "plugin://plugin.
getLocalizedString if result: video.youtube/?path=/root/
translation(30002) result = result[0] video&action=play_video&videoid=" +
if result: id
In this example, translation(30002) will return return int(result) return url
the string "Hot" when running in an English return 0
environment. return -1

59 www.linuxuser.co.uk
Tutorial MakeextensionsforXBMCwithPython


On the same lines, we can build a function to if spl[i]:
place links as well subreddit = spl[i]
Similarly for Vimeo:
entries.
def addLink(name, url, mode, append(subreddit)
iconimage, description, date): entries.sort()
def getVimeoUrl(id): u = sys.argv[0]+"?url="+urllib.
url = "plugin://plugin.video. for entry in entries:
quote_plus(url)+"&mode="+str(mode) if entry in defaultEntries:
vimeo/?path=/root/video&action=play_ ok = True
video&videoid=" + id addDir(entry.title(),
liz = xbmcgui.ListItem(name, "r/"+entry, listSorting, "")
return url iconImage="DefaultVideo.png", else:
thumbnailImage=iconimage) addDirR(entry.title(),
And for Dailymotion: liz.setInfo(type="Video", "r/"+entry, listSorting, "")
infoLabels={"Title": name, "Plot": addDir("[ Vimeo.com ]",
def getDailyMotionUrl(id): description, "Aired": date})
url = "plugin://plugin.video. "domain/vimeo.com", listSorting,
liz.setProperty(IsPlayable, "")
dailymotion_com/?url=" + id + true)
"&mode=playVideo" addDir("[ Youtu.be ]", "domain/
ok = xbmcplugin. youtu.be", listSorting, "")
return url addDirectoryItem(handle=int(sys. addDir("[ Youtube.com
argv[1]), url=u, listitem=liz) ]", "domain/youtube.com",
Once we have the video URL resolved into the return ok
respective plug-in, playing it is very simple:
listSorting, "")
addDir("[ Dailymotion.com
Based on the abstractions we have just created,
def playVideo(url): ]", "domain/dailymotion.com",
we can create the base functions which will
listitem = xbmcgui. listSorting, "")
populate the content. But before we do that,
ListItem(path=url) addDir("[B]-
lets first understand how Reddit works. Most of
xbmcplugin. "+translation(30001)+" -[/B]", "",
the Reddit content filters are provided through
setResolvedUrl(pluginhandle, True, addSubreddit, "")
something called Subreddits. This allows you to
listitem) xbmcplugin.
view discussions related to a particular topic. In
endOfDirectory(pluginhandle)
our plug-in we are interested in showing videos;

13 Populatingplug-incontentlisting
xbmcplugin contains various routines
for handling the content listing inside the
we also want to show trailers, documentaries
etc. We access these using Subreddits. For
example, for trailers it would be reddit.com/r/
Here, the penultimate entry makes a call to
addSubreddit. listSorting takes care of sorting
out the data based on criteria such as Hot,
plug-ins UI. The first step is to create directory trailers. For domains we can use /domain; for
New etc. It also calls in Reddits JSON function,
entries which can be selected from the XBMC example, to get all the YouTube videos posted
which returns nice easy-to-parse JSON data.
UI. For this we will use a function called on Reddit, we will call reddit.com/domain/
We have created a settings entry for all the
xbmcplugin.addDirectoryItem. youtube.com. Now you may ask what is the
sorting criteria. Based on what is set, we go
For our convenience we will be abstracting guarantee that this Subreddit will only list
ahead and build out the sorted list.
addDirectoryItem to suit it to our purpose, so videos? The answer is that it may not. For that
that we can set name, URL, mode, icon image reason we scrape the site ourselves to find
def listSorting(subreddit):
and type easily. videos. More on this in the next step.
if cat_hot:
The first base function well define is index().
addDir(translation(30002),
def addDir(name, url, mode, This is called when the user starts the plug-in.
urlMain+"/"+subreddit+"/hot/.
iconimage, type=""):
json?limit=100", listVideos, "")
u = sys.argv[0]+"?url="+urllib. def index():
if cat_new:
quote_plus(url)+"&mode="+str(mode)+" defaultEntries = ["videos",
addDir(translation(30003),
&type="+str(type) "trailers", "documentaries",
urlMain+"/"+subreddit+"/new/.
ok = True "music"]
json?limit=100", listVideos, "")
liz = xbmcgui.ListItem(name, entries = defaultEntries[:]
if cat_top_d:
iconImage="DefaultFolder.png", if os.path.
thumbnailImage=iconimage) exists(subredditsFile):
addDir(translation(30004)+":
liz.setInfo(type="Video", fh = open(subredditsFile,
"+translation(30007),
infoLabels={"Title": name}) r)
urlMain+"/"+subreddit+"/
ok = xbmcplugin. content = fh.read()
top/.json?limit=100&t=day",
addDirectoryItem(handle=int(sys. fh.close()
listVideos, "")
argv[1]), url=u, listitem=liz, spl = content.split(\n)
xbmcplugin.
isFolder=True) for i in range(0, len(spl),
endOfDirectory(pluginhandle)
return ok 1):

60 www.linuxuser.co.uk
Make extensions for XBMC with Python
Use Python to create a new plug-in for XBMC
TUTORIal

In the code listed to the left here, we are


def listVideos(url): opening the URL, then based on regular
currentUrl = url expression matches we are discovering
xbmcplugin.setContent(pluginhandle, "episodes") the location title, description, date, ups,
content = opener.open(url).read() downs and rating. We are also locating
spl = content.split("content") video thumbnails and then passing them on
for i in range(1, len(spl), 1): to XBMC.
entry = spl[i] Later in the code, we also try to match the
try: URL to a video provider. With our plug-in we are
match = re.compile("title": "(.+?)", re.DOTALL).findall(entry) supporting YouTube, Vimeo and Dailymotion.
title = match[0].replace("&amp;", "&") If this is detected successfully, we call the
match = re.compile("description": "(.+?)", re.DOTALL). helper functions to locate the XBMC plug-
findall(entry) in based playback URL. During this whole
description = match[0] parsing process, if any exception is raised, the
match = re.compile("created_utc": (.+?),, re.DOTALL).findall(entry) whole loop is ignored and the next JSON item
downs = int(match[0].replace("}", "")) is parsed.
rating = int(ups*100/(ups+downs))

filterRating:
if filter and (ups+downs) > filterVoteThreshold and rating <
15 Installing&runningtheadd-on
You can install the add-on using one of
the following two methods:
continue
title = title+" ("+str(rating)+"%)" You can copy the plug-in directory to
match = re.compile("num_comments": (.+?),, re.DOTALL). .xbmc/addons.
findall(entry) You can install the plug-in from the zip file. To
comments = match[0] do so, compress the add-on folder into a zip file
description = dateTime+" | "+str(ups+downs)+" votes: using the command:
"+str(rating)+"% Up | "+comments+" comments\n"+description $ zip -r plugin.video.ludent.zip
match = re.compile("thumbnail_url": "(.+?)", re.DOTALL). plugin.video.ludent
findall(entry) To install the plug-in from the zip file, open
thumb = match[0] XBMC, go to System then Add-ons, then click
matchYoutube = re.compile("url": "http://www.youtube.com/ Install from zip file. The benefit of installing
watch\\?v=(.+?)", re.DOTALL).findall(entry) from a zip file is that XBMC will automatically
matchVimeo = re.compile("url": "http://vimeo.com/(.+?)", try to install all the dependent plug-ins as well.
re.DOTALL).findall(entry)
url = "" Once you have the plug-in installed, you can
if matchYoutube: run it by going to the Videos Add-ons section of
url = getYoutubeUrl(matchYoutube[0]) XBMC, selecting Get More and then clicking
elif matchVimeo: on LUD Reddit Viewer.
url = getVimeoUrl(matchVimeo[0].replace("#", "")) You can access the settings dialog of the
if url: plug-in by right-clicking the LUD Reddit Viewer,
addLink(title, url, playVideo, thumb, description, date) then selecting Add-on settings.
except:
pass So, you have seen how robust and powerful
match = re.compile("after": "(.+?)", re.DOTALL).findall(entry) XBMCs extension system is. In this example,
xbmcplugin.endOfDirectory(pluginhandle) we were able to leverage the full power of
if forceViewMode: Python (including those magical regular
xbmc.executebuiltin(Container.SetViewMode(+viewMode+)) expression matches) from within XBMC.
XBMC itself also offers a robust UI framework,
which provides a very professional look for

14 Populatingtheepisodeview(listingvideos)
At this point we have the URL in hand, which returns JSON data; now we need to extract the
data out of it which will make sense to us.
our add-on.
As powerful as it may seem, we have only
built a video plug-in. XBMCs extension system
By looking at the JSON data, you can see theres a lot of interesting information present here. For also provides a framework for building fully
example, url is set to youtube.com/watch?v=n4rTztvVx8E; title is set to The Counselor Official fledged programs (called Programs). We will
Trailer. There also many other bits of data that we will use, such as ups, downs, num_comments, cover this in a later issue.
thumbnail_url and so on. In order to filter out the data that we need, we will use regular expressions.
There is one more thing to note: since we are not presenting directories any more but are ready to
place content, we have to set the xbmcplugin.setContent to episodes mode.

61 www.linuxuser.co.uk
Tutorial Master Vim in easy steps

All the examples


presented in this
article are tested for
Vim version 7.3.547
on Ubuntu 13.04

Just type :help and


Vim displays some Type :help iccf
valuable info for and Vim displays
newbies, such as information
navigation keys and (including weblinks)
keyboard shortcuts related to donations
to enable the for the needy in
mouse in xterm or Uganda as well as for
GUI etc the development of
the Vim editor

Master Vim in easy steps


Take a step ahead, learn some advanced features
and get more productive with the Vim editor

Advisor Thanks to a steep learning curve, many people


either avoid using Vim or use it on a very basic
on the whole some of the prominent pros include
fast text editing (because of little to almost no use
Himanshu Arora is a level. If youre guilty of either of these then youre of the mouse) and easy execution from anywhere
software programmer, open
source enthusiast and Linux really missing out. on the command line. There are also many GUI
researcher. His articles have been Vim, first released in November 1991, is front-ends (like gVim) available for Vim.
featured on IBM developerWorks, a command-line-based text editor that was Although it is command-line based, Vim has a
Computerworld and in Linux
Journal. He (along with some developed by Bram Moolenaar as an improved loyal following and is extensively used by system
other Linux freaks) blogs at Vi clone for Amiga platform. Besides including administrators and software programmers.
mylinuxbook.com all the features of the popular Vi editor, it also Though it is hard to learn and understand all the

Resources
contains a lot of new features and so derives features that Vim provides, in order to reap its real
its name from Vi improved. As well as being benefits it is essential to master Vim for your day-
Vim: www.vim.org/download.php a text editor, Vim can be used as an integrated to-day work.
development environment by software Through this article you will learn how to work
programmers. Vim provides a wide range of with multiple files, how to indent and fold code,
features, but as it is a command-line utility it has how to search and replace keywords, how to split
a steep learning curve. Please note that Vim is not the Vim window horizontally/vertically, and many
a word processor, which means that you cannot other related features provided by Vim.
do layout-related changes with it. Note: This article assumes that you have some
While you will get to know about the real basic knowledge (opening, editing, saving and
strengths of the Vim editor once you master it, closing a file) of the Vim editor.

62 www.linuxuser.co.uk
Master Vim in easy steps
Learn some advanced features of Vim
TUTORIal

03 Get list of currently opened files


in Vim
05 Copy-paste across the files
Another frequent requirement is to
copy from one file and paste into another. For
To get the list of files currently opened in the

01 Work with multiple files this, you need to split the Vim window to open
Vim editor, just type :ls. This will display list of both files. This can be done either by using
While most regular users use Vim to opened files along with other information like
edit one file at a time, it can also be used to edit the -o option with the vim command (vim -o
the current line number of the cursor in a file, <file1-name> <file2-name>); or by opening
multiple files in parallel. To open multiple files file in current active window (represented by
with the Vim editor, just provide names of all a file with vim <file1-name>, then opening
%a), file in previous active window (represented the second file in split window mode from
these files as arguments to the vim command. by #) etc. Switch between current and previous
The first file is displayed by default. Type :n to within the active Vim window with :split <file2-
active windows by typing :b#. name>. To switch cursor control between the
switch to the next file, :prev (or :N) to switch

04
to previous file, :bf to switch to first file, :bl to Use wildcard characters two windows, press Ctrl+w (a couple of times).
switch to last file and :bw to close the file. Vim also supports wildcard characters Copy-paste operation across the files can
(like *, ? etc) while opening multiple files at a be done as follows: open files in split mode (as

02 Work with multiple files


Sometimes it is required to open a
new or an existing file while editing an already
time. This is especially useful in cases where
multiple log files begin with a common set of
explained above); copy the required text from
one file; press Ctrl+w to switch the control to
characters like the current date (2013-08-05-- the other file; then paste the copied text.
opened set of files. Well, this can be done by --.log), or where multiple programming source You can also split a Vim window vertically.
typing :e followed by the filename (along with a files have same language extension such as All you need to type is :vsp <file-name> from
complete path if its not located in the current .c or .cpp. within an active window.
working directory).

63 www.linuxuser.co.uk
Tutorial Master Vim in easy steps

06 Close all files


To close all the opened files in one go, braces of the function definition. For example,

While most
add a to regular close options like :q, :wq or bring the cursor to the first line of the function
:q!. So, to close all the files in a single shot, do body. Once there, just type va}zf. As you type

regular users
something like :qa or :wqa or :qa!. this, you will observe that va is used to activate
visual mode in Vim, while } selects the complete

07 Close files without closing Vim


Normally, when the last open file is
closed, the Vim application also exits. But, if it
use Vim to edit
block including curly braces and zf enables
the fold.

one file at a time,


To open the fold, press zo; to close it, press
is required to close the last open file without zc. Make sure that the cursor is within the block
closing the application, then just type :bd.
it can also be
while performing fold open and close. Typing
This closes the current file and opens an va}zf creates a fold (that is invisible). zo and zc
empty buffer.
used to edit
work only when a fold is created. An existing
fold can be deleted by typing zd.

multiple files 09 Manual indenting


Another important feature that

in parallel Vim provides is code indentation. Software


programmers are required to indent their
code and Vim provides easy steps for code

08 Fold blocks of code


Another frequent requirement which
software programmers usually have is to fold
indentation. To indent a single line of code,
you can use >> or << to indent the line to the
right or left respectively. Multiple lines can
some blocks of code in order to save window
also be indented using [number-of-lines]>> or
space. This helps them to focus on the required
code blocks. Vim does support block folds. For
this, the first step is to bring cursor inside the

64 www.linuxuser.co.uk
Master Vim in easy steps
Learn some advanced features of Vim
TUTORIal

:set shiftwidth=<number-of-spaces>. For


example, use :set shiftwidth=4 to indent lines
by four spaces.
For those programmers who want
everything automated, Vim also 11 Search words
To search for a word in the active
window, simply type /[search keyword]. This
provides an auto-indenting feature will enable Vims search mode and find the
first occurrence of the searched keyword.
Use n (just press n) in order to search more
occurrences of the keyword. Note that you
cannot do a backward search here.
If you need to do a backward search then
just type :?[search keyword]. This will enable
Vims backward search mode. Again, use n to
continue the search, but backwards this time.
Sometimes the keyword is present in the
text/source file and it is desired to find other
occurrences of that word in the current text/
source file. In this case, just put the cursor
below that word and press * (ie Shift+8). This
way, you can search for a word without even
typing it.

[number-of-lines]<<; for example, 10>> or 10<<.


10 automatic indentation
For those programmers who want
12 Replace words
Vim also supports search and
replace operations. To execute a basic
This is a better technique than indenting each
line, but you still need to count the number of everything automated, Vim also provides an replace operation, just type :%s/[keyword-
lines to indent. This could prove frustrating, auto-indenting feature. For example, to enable to-search]/[keyword-to-replace-with] to
especially if the number of lines is very large. auto-indenting for C code, use :set autoindent replace keyword-to-search with keyword-to-
Fortunately, there is another trick: to select and :set cindent. Now, try writing some C replace-with.
the lines by working with Vim in visual mode. In code and you will see that Vim automatically This trick is good if you want to replace all
order to do this, you first need to bring Vim into produces indentation as you write it. the occurrences of a searched keyword, but
visual mode. This (as mentioned previously) can Sometimes, depending upon the existing what if it is desired to replace only selected
be done using va. Once in visual mode, use the settings of your Vim editor, lines might get occurrences? Well, there is a way through
arrow keys to select all the lines that you want indented to a number of spaces other than which you can run a search and replace
to indent in one go. After this, all you need to do four spaces or any other default value that operation in interactive mode. This means
is press > or < and the whole selected area will you desire. As a solution to this, you can that Vim will confirm before replacing the
be indented accordingly. set the number of spaces to indent using keyword each time. This can be done through
:%s/[keyword-to-search]/[keyword-to-
replace-with]/c.
The first occurrence is always highlighted
and Vim displays a prompt (in green, at the
bottom) where you can input your choice of
whether you want to replace this occurrence
or not. Here, y = Yes, replace this occurrence;
n = No, skip this occurrence; a = Replace
this and all other occurrences; q = Quit the
command; l = Replace this match and then quit
the command.
Use Ctrl+e (^E) and Ctrl+y (^Y) to scroll the
window up and down in this mode. Also, use i
and I (along with /c, for example /ci or /cI) for
case-insensitive and case-sensitive search.

65 www.linuxuser.co.uk
Tutorial Make a Python Twitter client

Create your own app details by using Access the entire dataset of Twitter via
the Twitter Developer account tools, the Python wrapper, allowing you to grab
either for personal use or for an app timelines, lists and user profiles among others
you intend to release

Create your authentication keys Write your own tweets in Python


for your user and OAuth, letting using the Twython module to access
you tap into the Twitter API components from the Twitter API

Make a Python
Twitter client
Learn the basics of the Twitter API using Python libraries and
create a simple Twitter client to make and monitor tweets
Advisor
Rob Zwetsloot models Python has many strengths, and one of them with Tkinter (from previous issues of LUD). You
complex systems and is a web is the way you can use it to create lightweight can also specify the login details youd normally
developer proficient in Python, desktop software and packages for the ask for from a client and then use it to check for
Django and PHP. He loves to
experiment with computing Internet of Things. One of the services used for specific words on Twitter, retweets, messages
this is Twitter, which has a few Python APIs you received, or if a specific person is sending tweets.
Resources can make use of in a Python script to check and
post the tweets from a specified user.
For this tutorial well be using Twython, which
provides a pure Twitter interface for Python, and
A Twitter account With this you can create a standard Twitter show you how to get your own unique API key to
Python 2: www.python.org/ client in the command line, or make a UI for it use it with Twitter itself.

66 www.linuxuser.co.uk
Make a Python Twitter client
Create a simple Twitter client to make and monitor tweets
TUTORIal

We need to
create a Python
file to hold all our
authentication
details. Start
01 accountability
To create a Twitter app, you need a
by importing
Twitter account. Sign into your account, or
create a separate one if you want to split up
Twython
personal and development accounts on the
service. Once thats done, go to dev.twitter.com
and log in using your desired account.

04 access token

07
We can now create an access token authentication file
for the application to work with your Twitter We need to create a Python file to hold
account. Go back to the details once the read all our authentication details. Start up IDLE, or a
and write permissions have been changed, text editor of your choice, and start by importing
and scroll down to the bottom. Click Create my Twython with:

02 New beginnings access token to retrieve it. from twython import Twython
Go to My applications and click Create
a new application. Here youll need to enter the
apps name, a short description and a website
05 Install Pip
Well install the latest version of python-
twitter from its website. To do this, first install pip
Make sure you have the keys we created earlier
handy to add in the next parts.
If the output is long, type it to go to the next screen.
where more details about yourself and/or on your system, available in repos as python-pip.
the app can be found. Names of apps are not As were using Debian, this looks like:
allowed to use the word Twitter in them. $ sudo apt-get install python-pip
which allows us to set up Python modules.

08 app keys
Add the following to your code:
APP_KEY = 'YOUR_CONSUMER_KEY'

03 Privileges
After this has been created, youll be
06 Install Twython
Now that we have Pip installed, we
can go ahead and install Twython. To do this,
APP_SECET = 'YOUR_CONSUMER_SECRET'
replacing YOUR_APP_KEY and YOUR_APP_
SECRET with your own consumer key and
brought to the details page of the app. Before continue in your terminal and put: consumer secret respectively.
we go any further, click on Settings and select $ sudo pip install twython
Read, Write and Access Direct Messages under This will get the Twython module, and all the
Application Type so that we can use it properly OAuth packages you need to log into your
as a Twitter client. account with tokens we created.

67 www.linuxuser.co.uk
Tutorial Make a Python Twitter client

09 Access keys
Now we add the access tokens that we
created to the script with:
OAUTH_TOKEN = 'YOUR_ACCESS_TOKEN'
OAUTH_TOKEN_SECRET = 'YOUR_ACCESS_
SECRET'
where again youll need to replace YOUR_
ACCESS_TOKEN and YOUR_ACCESS_SECRET
with the relevant numbers.

10 Verification
Nows a good time to verify if what
youve done so far actually works. Enter the
following at the bottom of the script:
twitter = Twython(APP_KEY, APP_SECRET,
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

twitter.verify_credentials() twitter.get_user_timeline(screen_name
And run. If it doesnt come up with any errors, its
= 'username')
all working fine.

15 Full timeline
We can access the accounts full timeline
by using the get_home_timeline variable like so:
twitter.get_home_timeline()
If you printed this out, it would display all the

11 Test post unfiltered data from the last 20 tweets on


As it all seems to be working, you could your timeline. You can modify the amount of
try making a test post straight to Twitter. At the tweets by adding the count parameter to the
bottom of our code, enter: get_home_timeline. Well set it to five for now:

13
twitter.update_status(status='Test') Update twitter.get_home_timeline(count = 5)
And then run it again. If its successful, there will To post this, we use the update_status Well need to parse the data to make sure we
be no errors and it will show up on your timeline. bit from before, only it now uses the string from get something coherent and recognisable as
post to update our timeline. Add: a timeline.
twitter.update_status(status=post)
And then save the file. Run it, and test the
code again.

14 Timeline Create a simple


12 Write a post
Lets create a simple way to post tweets
To access the timeline of our account
tweets, we use the following: way to post
tweets to your
to your timeline via our script. Well use human twitter.get_user_timeline()
input like so: This accesses the past 20 posts our account has

timeline
post = raw_input("Write your tweet: ") made. You can specify which timeline to check as
which will store our tweet as a string in post. well by adding the screen_name option:

68 www.linuxuser.co.uk
Make a Python Twitter client
Create a simple Twitter client to make and monitor tweets
TUTORIal

19 Favouriting
This works very similar to retweets, using
the unique ID for the tweet used in the URL to

16 Search tweets
We can search Twitter for specific
determine which tweet to favourite. The function
for this is create_favorite, and is written as:
keywords using the following:
twitter.search(q='linux')
This will return a mixed result of tweets relating
twitter.create_favorite(id = '12345')
Make sure to use the American spelling (favorite) 22 Trending topics
Everyone knows what everyone else
is talking about thanks to Twitters trending
when doing this.
to the word Linux. You can filter them with the topics, whether its a young Canadian musician
result_type parameter, by setting it as mixed, or important world events. You access the
recent or popular. trends with:
twitter.get_place_trends(id = '1')
An ID of 1 returns global trends. You can specify
different IDs for different locales.

20 Retrieve favourites
All of a users favourites are stored by
Twitter so that you can recover them at any time.
You can either get your own, or specify a user to
get the favourites from. The basic code is:

17 Follow twitter.get_favorites()

23
To follow someone on Twitter, we use the which will get your own favourites. As
Retrieve list
create_friendships function. We need either the before, you can specify the user ID number or
If you prefer to use Twitter by curating
screen name or numerical ID of the Twitter user screen name with user_id and screen_name
lists of people, you can get the contents of any
you want to follow youll most likely be using the respectively to get a specific list.
list using the get_list_statuses function:
screen name, so well write it like so: twitter.get_list_statuses(id =
twitter.create_friendship(screen_name '12345')
= 'LinuxUserMag') Each list has a unique ID, or a slug, that you can
use. You can also call members of any list, or
anyone that subscribes to it.

24 The end
With all these functions, you can start

21 Mentions
You can also access the list of mentions
picking and choosing data and making our code
do a lot more than just post tweets. Getting

18 Retweeting
As retweets are an integral part of Twitter,
the function for this is simply retweet. We require
for your authenticated account. To do this,
use the get_mentions_timeline function. This
works like the other timelines, allowing you limit
specific attributes from the timeline functions
will allow you to display a coherent timeline, and
it also includes the details needed to follow the
the tweet ID for this, the numerical string used for the amount of posts you get from the selection. links to the users and their links.
each tweet and displayed in the URL for a tweet. Limit it to five like before with:
We use it with: twitter.get_mentions_
twitter.retweet(id = '12345') timeline(count='5')

69 www.linuxuser.co.uk
Review index
Essential kit, software and resources for the open source scene
REVIEWS

An easy way to get


started with wireless
microcontroller
development
Wireless Inventors Kit

Group Test Hardware How we review


Our experts thoroughly test
12 MinnowBoard the kit and grade it using the
72 IDE Has the Raspberry Pi following criteria
super-test really met its match?
Enhance your workflow
with the best dev 79 Nook HD+ Avoid at all costs
environments The perfect mix of low
cost and high performance?

Software A designer/developers bad day

82 Sparky Linux 3.0


Code::Blocks Geany One of the first distros to use Good but could do better
Debian 7.0 Jessie
Books Get this. It wont disappoint
85 The latest Linux
Eclipse Netbeans
reads dissected
Software or hardware nirvana

71 www.linuxuser.co.uk
Review Integrated development environment group test

GROUP TEST

Integrated development
environments
We pit four of the best IDEs against each other to find out which is the best
way to streamline and enhance your workflow
The humble IDE can be a very powerful tool for In this test, well be looking at the more fully Weve chosen Eclipse, Code::Blocks, Geany
any coder whether its for hobby programming featured, multi-language IDEs, rather than and Netbeans for this review. While theyre
or used professionally. With all the various specialised single-language environments not included, KDevelop and Anjuta are other,
programming languages one can use, theres or lightweight equivalents. Were also testing desktop-environment-specific IDEs that are
an even greater number of IDEs that can help these IDEs for their abilities to be expanded also great. Weve chosen platform-independent
you write code in them each with their own through plug-ins and add-ons either for other IDEs for this test, although those two will
advantages and disadvantages. languages, or different interface effects. generally work fine on other desktops.

72 www.linuxuser.co.uk
Integrated development environment group test
Four of the best IDEs go head to head
REVIEW

Code::Blocks
A relatively new IDE, Code::Blocks was first
A more open IDE originally for C++, but
now able to do a bit more
released in early 2008 after three years
of release candidates. Although a C++ IDE
by default, it has plug-in support to extend its
functionality to allow for building and testing
of other languages. However, for pure coding,
Code::Blocks can be used to write scripts in
various languages thanks to support for syntax
of a variety of different languages. However, you
cannot test these without add-ons.
Unfortunately, the plug-in scene for
Code::Blocks is fairly immature and there isnt
even proper support for Python and other
interpreted programming languages. Plug-ins
are found via the Code::Blocks wiki and are not
particularly well laid out at the moment. Plug-ins
are installed manually, which would be fine
normally, but the other IDEs in the test have some
interesting ways of managing plug-ins that make
this method seem somewhat archaic. There are a few first-party plug-ins available, but not many third-party
While you wont be able to properly debug doesnt always work for all functions and classes; Code::Blocks is a nice piece of software,
test code, the interface for Code::Blocks is still however, it will allow you to perform simple code although due its immaturity it doesnt quite have
very nice for actually writing your code. Projects editing to test elsewhere if you specifically like the best plug-in support of the other IDEs in this
are handled via proprietary projects files which the interface. test especially if you want to use it for multi-
link to specific folders. Projects dont need to be Code::Blocks is also quite customisable, language programming. Its a bit lighter than
created with a specific language in mind and, like allowing you to change the look and behaviour of Eclipse at least, and the interface is well laid out,
some text editors, it will smartly know to highlight the editor, the way the compiler works and even but it may still be a few years before it becomes
the syntax for different languages. Browsing editing the startup script for the application itself. preferable to the others.

Unfortunately, the plug-in scene for SCORES


Code::Blocks is fairly immature Available in repos, but

Installation
binaries and source
code is easily accessible
elsewhere
8
Code::Blocks interface

7
is generally good for
workflow, although
it doesnt support all
Workflow languages properly

7
A great selection of
features that can all be
Features heavily customised

Very limited right now,

Plug-in
support
meaning that not all
languages are
properly supported
4
Code::Blocks has a great

6
interface, and some great
ideas on how to code and
manage projects, but the
plug-in selection needs to
The interface is nice and aids workflow
Overall be improved

73 www.linuxuser.co.uk
Review Integrated development environment group test

Geany
A fully featured IDE
thats a little more
lightweight than most
Geany is sometimes mistaken for a glorified
text editor. In reality, its a full IDE, albeit slightly
more lightweight than most.
Geany has multi-language support out of
the box, with easy options to create files that
use different languages as part of the main
interface. Projects are kept in specific folders,
like Eclipse, although there is a file to go with
them that Geany can read to manage the
projects. Multiple projects can be viewed and n Geanys interface is smart and easily breaks down code for workflow purposes

Code is automatically highlighted with


edited at a time, all in different languages. There
are also debuggers and builders for the various

the correct syntax


languages that support them, and you can run
and test stuff like Python that doesnt need
compiling as such.
The rest of the interface for Geany is clean and Sadly, Geanys plug-in support is pretty dire. Geany is a very smart IDE, with a low barrier
well labelled. Code is automatically highlighted Some plug-ins extend the basic functionality for to getting your project started straight away. It
with the correct syntax and theres a smart a few of the languages, but theres not the kind does lack in some of the features of some of
tab in the left column that allows you to track of depth as Netbeans or Eclipse in the sheer the bigger IDEs, such as more advanced unit
and view the different variables, functions and number of available plug-ins. testing and debugging, although it will let you
classes in the projects and code. Navigation There are a lot of ways to customise browse compile errors. The plug-in selection is
through the code is fairly simple via context- Geany with the standard tools and menus, also pretty poor, so it may not be extensible for
sensitive menus and nice options within the though. Almost every part of the interface specific functions.
rest of the interface, and the usual code-editing and workflow is editable, with ways to
tools such as commenting out a selection or even change the characters required for
indenting are all present. autocomplete suggestions. SCORES

9
Readily available in
most repos and requires
Installation minimal dependencies

9
Workflow is superb for
the variety of different
Workflow languages included

No proper debugger,

Features
but a great selection
of build and project
management functions
7
Although it doesnt quite

Plug-in
support
need it like the others,
there are very few
plug-ins available
4
Geany is a great,

8
lightweight IDE with
good native support for a
variety of languages, but
theres not much room
Overall for expansion
n The native languages are supported quite well with compilers and such

74 www.linuxuser.co.uk
Integrated development environment group test
Four of the best IDEs go head to head
REvIEW

Eclipse
The ubiquitous
Eclipse is an industry
standard how does
it fare against more
community-run efforts?
Eclipse is one of the most popular development
suites around, and at first glance its easy to see
why. While created mainly for Java development,
Eclipse is highly customisable through plugins.
Thanks to its popularity and community, this
has resulted in a great selection of addons
n Plug-in support for Eclipse is top-notch
that enables Eclipse to work with just about
any language. These plugins allow for more anything that might be inefficient in terms of the select which extensions to install from each of
than that, with a marketplace full of interface code. There are plenty of editing tools too, such the repositories.
and behavioural modifications alongside the as simple indent or dedent options. Eclipse is customisable in other regards, with
language elements. The debug suite in Eclipse is fully featured, an expansive properties and settings menu
Eclipse has great project management with various ways to run, check and unittest that lets you edit a huge amount of the native
tools as well, with a smart tabbed interface, code, although this depends on the plugins to behaviour of the IDE, from the way patches
and pluginspecific menu entries for starting some degree. The tools are there, though, and are viewed to little things like key bindings and
projects in different IDEs if needed. Projects are most of the major plugins seem to use them. other shortcuts. Eclipse is a fairly big suite
located in plain folders in the location of your The plugins are handled by a repository of packages, though, and easily the biggest
choice, allowing for easy access of source code if system, which lets you keep any addons resource hog out of all of the IDEs were testing.
you need it, instead of being inside a proprietary up to date. While there arent a huge amount It does have probably the best extensibility of all
file. The function search ability works well and available by default, its easy enough to add these IDEs, however, meaning it also probably
the interface has plenty of tips and warnings for more to the plugin manager and you can even has the most to offer those who work on a lot of
differing projects.
A great selection of add-ons enables it to SCORES
work with just about any language Eclipse requires a lot of

Installation
dependencies; however,
its available in most
major repos
7
Smart interface design

Workflow
that lets you easily
navigate projects
and code
9
8
A great set of features by
default, although mainly
Features for handling Java

The best support around,

Plug-in
support
with a great repo system
offering a wealth of
add-ons
10
Eclipse is popular for a

9
reason its got a great
selection of features that
are easily extensible to
Overall suit almost any need
n Code navigation and highlighting aids your workflow

75 www.linuxuser.co.uk
Review Integrated development environment group test

Netbeans
The Oracle-developed
Java development
platform that multitasks
Netbeans started life as a humble student
project to make a Java IDE in Prague. Within a
few years, a company had been set up around
the IDE, and then had been bought by Sun
Microsystems. The rest is history and after
over 15 years of development, Netbeans is on
version 7.3.
Netbeans has a very similar feature-set to
Eclipse, with debuggers, compilers, unit testers
and the like, although by default Netbeans n Netbeans has a nice welcome screen to start new projects

There just isnt quite the same level of


has support for PHP and HTML as well as its
Java-specific features. Netbeans also has a

customisation as Eclipse or the others


huge database of plug-ins to call from, allowing
you to extend its features to just about any
programming language. These plug-ins are
nicely arranged in a database format on the and some functions are hidden away in weird Overall, Netbeans seems like its a little
Netbeans website, with simple search functions menu options. The code view is not particularly behind the times, with an interface that needs
and a fairly easy way to install the plug-ins to the well handled, with syntax highlighting a little a small overhaul and a better selection of
system. Theres no repository function for the sparse. The function navigator is fairly nice, customisation options. Its by no means a
plug-ins like Eclipse, but the database displays though, with the sidebar allowing you to track bad IDE, with a great suite of debugging and
enough information to know if youre getting the the hierarchy a little better than some. testing options to use on code. On the other
latest version of the plug-in. Customisation in Netbeans is handled with a hand, Eclipse is equal or better in almost
The interface is a little confusing not very nice-looking options menu, but there just isnt every regard.
well streamlined and aesthetically a little dated. quite the same level of customisation as Eclipse
While the splash screen is nice for starting new or the others. However, for similar customisation
projects, the rest of the interface is cluttered tasks, its a little better laid out than Eclipse. SCORES
Packages are readily

Installation
available for Netbeans
and it requires a
Java install
8
The interface is a little

Workflow
cluttered and convoluted,
but there are some decent
options to be found
7
7
A similar feature-set to
Eclipse, but not as much
Features customisation

A fairly large selection

Plug-in
support
of plug-ins are available
for it within an easy-to-
search database
8
Netbeans just misses the

7
mark with a slightly dated
interface, but its made up
for somewhat with a good
n The interface is not particularly well laid out
Overall selection of plug-ins

76 www.linuxuser.co.uk
Integrated development environment group test
Four of the best IDEs go head to head
rEvIEW

In brief: Compare and contrast our verdicts


Code::Blocks Geany Eclipse Netbeans
Available in repos and Requires few A big suite of In most major repos

Installation
via binaries on the
website 8 dependencies and
easy to come by 9 packages, but readily
available 7 and doesnt have
many dependencies 8
Good for the Great workflow Project management A nice workflow

Workflow
languages that are
supported 7 ideas, with easy code
navigation 9 is excellent and code
navigation is good 9 view, but the
interface is a
little dated
7
A decent selection of Theres not a proper Eclipse is a feature- A decent debugger

Features
features for C++
7 debugger for Geany
7 full IDE and is highly
customisable 8 and reasonable
customisation 7
Code::Blocks plug-in Geany does not Eclipse has the best A huge database of

Plug-in
support
support is immature
and badly distributed 4 have many available
plug-ins 4 selection of plug-ins in
this test by a long way 10 plug-ins, although
some are a bit old 8
A bit disappointing A great lightweight Ubiquitous for a Netbeans just falls

Overall
as of yet, but
Code::Blocks shows
some potential
6 IDE that may not be
the best, but its still
recommended
8 reason, Eclipse has
a lot of things going
for it
9 short of the other
IDEs with some
missing features
7
AND thE Offers excellent project
WINNEr Is
www.linuxuser.co.uk

management features and a GROUP TEST


Eclipse hugely expansive plug-in list WINNER
We were actually a little surprised that Eclipse
was this good compared to the other IDEs to work any way you want
in this months group test. It offers excellent
project management features, while its hugely
expansive plug-in list means that you can make
it work just about any way you want it to much
more so than Geany or Code::Blocks.
Geany is definitely a close runner-up,
though, and while were not specifically looking
at lightweight IDEs this time, it does have a
great selection of features while being light on
system resources. The only thing that really
let it, and Code:Blocks, down was its lack of
plug-in support.
Code::Blocks still needs some development
time, and more community involvement, to
make it a truly great IDE. Its good to work
with for C++ for now, and wed recommend
it for that, but it just doesnt have enough to
recommend it for multi-language work.
Eclipse, on the other hand, has a great
balance of all the aspects were looking for in a
multi-language IDE and thats why it takes the
editors choice award.
Rob Zwetsloot n Eclipse can be anything you want it to be

77 www.linuxuser.co.uk
Nook HD+
Low-cost Android tablet
REVIEW

The display has a The hole in the


high pixel density corner is a Nook
and is great for trademark. We
reading eBooks and cant say whether
watching videos. it is supposed to be
We would have functional or not
preferred a bit more
brightness to it

The Nook has a fully customised skin, but does have


access to the full range of Google apps, plus the Play Store,
Technical specs
TABLET
Operating system Android 4.0
so you can Android-it-up a bit more Processor 1.5GHz dual-core

Nook HD+ 179


Memory 1GB RAM, 16-32GB storage
Dimensions 240.3 x 162.8 x 11.4mm
Weight 515g
Display size 9-inch
Display resolution 1920 x 1280 pixels
Expansion slot microSD

Is this low-cost, hi-res tablet alternative to the Kindle Fire an


Android hackers dream device?
With the future of the Nook brand looking decidedly murky, The software is also built for eBooks. Like Amazons Kindle
it may not seem like the best time to be investing in one of Fire series the bulk of the UI is built around encouraging you
Pros
Great screen and
its tablets. Or maybe it is. With price drops aplenty, Barnes to buy content, but unlike with the Kindle you do get the full exemplary battery life;
quite hackable too
and Nobles answer to the Kindle Fire represents perhaps set of Google apps, and Play Store access as well. There
the cheapest way to get a high-quality tablet hi-res display, are a number of apps pre-installed, ranging from Spotify
fast performance and full Play Store access. Its also fully to Pinterest to a crosswords app, and none of these can be Cons
hackable, so even if you dont like the Nooks UI you can removed. You will need a Nook account before you can start Pre-installed apps cant
be removed; some strange
switch it to proper Android. using the tablet, and will also need your Google account design decisions
The Nook HD+, with its 9-inch display, feels pretty good in details to access the Play Store.
the hand with solid construction and weighty feel. The design With a bit of work you can get the Nook looking pretty much
is distinctive in good and bad ways. A large bezel around the like a normal skinned Android 4.0 tablet. We wouldnt count
screen is not as offensive as it might have been, while the n- on getting OS updates, but it is rootable and there are Jelly
shaped Home button gives the tablet subtle branding. On the Bean ROMs available. Theres a good chance there will be
downside is the weird hole in the bottom corner that serves KitKat (Android 4.4) ROMs in future too.
no apparent purpose. It looks as though youre supposed to Sandra Vogel
attach a lanyard, but the tablet is far too big and heavy for
that to be practical.
The screen is the Nooks standout feature. With a Summary
resolution of 1920x1280, a pixel density of 257ppi, it is close The Nook HD+ is a pretty good device. With nice hardware
to the level of the Retina display on the iPad and is wonderful. and a good display, its surprisingly flexible: you can use it as a
Text is sharp and crisp and it is very easy on the eyes. We did casual eBook optimised tablet, for the full set of Android apps,
find the screen to be lacking in brightness, however. Perhaps or open it up to hacks and tweaks.
this is because the tablet is intended primarily as an eReader
and so needs to have less glare, but for general use we More
had the brightness cranked up to the max, and would have information
preferred even more. www.nook.co.uk

79 www.linuxuser.co.uk
Review RasWIK

n There is no pass- n A small chip


through for the Pis spare provides the Pi with
GPIO pins, sadly a radio for wireless
communications

n The small ceramic n While small, the Slice


antenna can be replaced of Radio does block the
with a wire whip to little-used Display Serial
boost range Interface (DSI) connector

PeRIPheRAl

Raspberry Pi
www.linuxuser.co.uk

EDITORS
CHOICE

Wireless Inventors
Kit 49.99 Designed to mate a wireless Arduino microcontroller with
the Raspberry Pi, is the RasWIK what budding developers
have been waiting for all this time?
Pros While its easy to see the Arduino and the Raspberry Pi Getting started couldnt be easier: the kit includes a 4GB
The easiest way
to get started
as competitors theyre both low-cost electronic devices SD card with a customised version of the Raspbian operating
with wireless aimed at the hobbyist market, after all in truth theyre system. Simply slide this into the Pi, pop the bundled Slice of
microcontroller
development using
extremely complementary: the Arduino excels at real-time Radio board onto the GPIO header and apply power.
the Raspberry Pi control and sensing, while the Pi provides cheap network The SD card includes an open source example utility for
connectivity and powerful data processing capabilities. controlling the included Arduino clone, a radio-equipped
Cons Thats clearly been the thinking of Ciseco in designing the microcontroller dubbed the XinoRF. Using this tool, a visual
The LLAP wireless Raspberry Pi Wireless Inventors Kit, or RasWIK: a bundle of representation of the board appears on screen and allows
protocol offers no
encryption; Slice components and accessories, its designed to make working the user to turn outputs on and off, or read values from digital
of Radio blocks with the Arduino on the Raspberry Pi as simple as possible or analogue input pins.
unused pins on the
Pis GPIO header and showing users just what potential is opened up when the With nothing connected to the Arduino, that would
two are connected over a radio link. soon get pretty boring, but the kit also includes numerous

80 www.linuxuser.co.uk
RasWIK
Wireless microcontroller connection kit for Pi
Review

nMost Technical specs


Operating system RaspianLinux
existing
Dimensions (XinoRF) 70.9x53.3mm
Arduino
weight (XinoRF) 25g
shieldswork  Dimensions
finewiththe (Slice of Radio) 30.3x34.3mm
XinoRF  weight
(Slice of Radio) 7g
 extras 4GBSDcard,USBcable,
  smallbreadboard,5xred,
  yellowandgreenLEDs,
  30xresistors,lightsensor,
  thermistor,piezoelectric
  buzzer,3xpush-button
  switches,25xjumperwires
nTheAtmel
Atmega-328
provides
Also
fullArduino
compatibility consider

nTheXinoRFcanbe nThesamecompact
radioboardisfoundon ARDX experimenters
poweredbyamains Kit 62
adaptororthrough theXinoRFasonthe Anopensourcekit,
SliceofRadio OomloutsARDXisthe
mini-USB bestwaytogetstarted
withArduinodevelopment.
Whileitincludesmore
components and instructions for various experiments and of Radio in particular is a very clever bit of design and sits componentsthanthe
RasWIKincludinga
small projects. Using the bundled compact breadboard, its happily on top of the Pis GPIO port without increasing its mountingplate,servoand
possible to get building simple circuits remote buzzers, dimensions meaning it can be used in conjunction with the motoritdoesnotinclude
anywirelesscapabilities
traffic lights, even a light and temperature sensor in vast majority of non-metal cases on the market. asstandard.Thesecan,
mere minutes. The only real downside for those who enjoy experimenting however,beaddedata
laterdate.
The RasWIK has a serious trick up its sleeve once your with the Pis GPIO hardware is that the Slice of Radio does not www.oomlout.co.uk
device is built: an embedded radio on the XinoRF connects include pass-through connections for the other pins on the
to the Slice of Radio with no effort, allowing you to place header, despite only using power and the UART connection
the XinoRF almost anywhere in the same building as the itself. Careful work with a soldering iron will allow you to fix
Raspberry Pi and still take control of it. The system uses that, but if youre not happy with such modifications and have
the Lightweight Local Automation Protocol (LLAP), which only one Pi, youll soon grow tired of removing the radio board
allows for multiple devices on the same radio network in favour of other GPIO-connected devices you may have.
Gertboard
more XinoRFs, more Raspberry Pis, or some of the LLAP- Gareth Halfacree 31.12
compatible accessories also sold by Ciseco. Oneofthefirstadd-on
boardsdevelopedforthe
Its here where the only real downside of the kit comes to Pi,theGertboardisawired
light, however: LLAP is extremely lightweight, as you might Summary GPIOexpansionmodule.
Notentirelysuitable
expect from a protocol designed for a microcontroller with forbeginnersdueto
AlthoughitwouldbeeasytomarktheRasWIKdownforits
around 32KB of program storage. Accordingly, it includes inaccessiblecodeexamples
insecureprotocol,todosomissesthepoint:itsaneasyway andawkwardhardware,
no protection against intrusion; so if your neighbour buys a to get started with wireless microcontroller development, itsstillanaffordable
RasWIK kit, he or she would be quite able to take control of wayofincreasingthePis
andprovidesagreatplatformforaddingsensorsoractuators
GPIOcapabilitiesbut,
anything you build. toaRaspberryPi.Ifsecurityisaworry,userscanalwaysroll again,hasnointegrated
For the experimenter, though, its a minor point. While the theirownprotocol. wirelesshardware.
uk.farnell.com
kit runs LLAP out of the box, the radio can also be used as a
point-to-point serial connection, and you can write your own
protocol to run over the top if you desire robust security. More
That minor issue aside, theres little not to like about the information
RasWIK kit. The radios offer surprising range, and the Slice ciseco.co.uk

81 www.linuxuser.co.uk
Review SparkyLinux 3.0

New features: Debian 7.0 Linux kernel 3.9.8 GNOME 3.8 compatible

n Customised
desktop
environments
such as LXDE,
Openbox and
MATE are n The preset
available Conky display
gives a lot of
information
about your
system, all of
it relevant

n The SparkyCenter is a nice


little app for controlling your
system, although it could do with
better navigation

diStRo

SparkyLinux 3.0
Minimum Specs: CPU 1GHz i486 RAM 256MB (128MB for CLI Edition) StoRAge 5GB (2GB for CLI Edition) Best for: Home office

One of the first distros using Debian 7.0 Jessie, SparkyLinux is


positioning itself as a lightweight system for any user
SparkyLinux is a relatively new distro, with its first version in most cases, along with a nice custom theme. All of the
Pros only coming out in May of last year. Since then, its gone live images include both a graphical and a command-line
Lightweight distro
based on new through a few major upgrades and number changes and is installer as used in the CLI version. Both work exactly
testing branch
of Debian; nice now on its third iteration. The idea is to create a lightweight the same way with the exact same options; however, the
aesthetic; great distro that computers both old and new can use with command-line version uses cfdisk for partitioning, and the
selection of images
modern aesthetics and graphical features available for those graphical installer used GParted. Its a minor difference that
with high system specs. In case you dont need graphics at can actually cause a unique issue SparkyLinux cant detect
Cons all, though, there is a handy CLI image that reduces the specs partitions on a hard drive that uses GPT. This means that
Doesnt play nice
with all desktops; down further another first for a Debian 7.0-based distro. systems with UEFI may need to be wiped before installing. As
some issues with
Flash and JS on
Graphical images come in several flavours: the standard GParted can work with GPT, you may never know that this is
non-Iceweasel lightweight LXDE image, a purely Openbox-based image, a an issue, as no warning messages or errors are thrown up.
browsers
MATE image and a Razor-Qt running edition. These are all This also means that partitioning for SparkyLinux is
customised to fit the needs of Sparky, with a dock added completely manual. It does explain what it needs to run, and

82 www.linuxuser.co.uk
SparkyLinux 3.0
Debian 7.0-based lightweight distro
Review

n Unlike a lot of modern distros, the installer has you manually n Synaptic grants you access to the entire Debian repos although we had some issues with
partition the hard drive although there are decent instructions using apps and other packages we installed to it
on how to do it

Partitioning for n Its a rolling release


SparkyLinux is based on testing
Debian, so all the latest

completely manual software is available to


use in Sparky

the Sparky website has some nice instructions to help you are featured on the dock with a couple of other apps, and
along the way, but the graphical installer could be improved Synaptic is used as the main package manager. While we
Screenshot
by having the auto-partitioning of other modern distros. had no issues with Iceweasel on some websites, when we
Gallery
Other than these issues, installation is quick and relatively tried using Chromium, Flash or JavaScript, heavy sites would
painless and while the majority of people wont face the GPT basically break the browser including even the Chromium
problem, its something that will become more problematic store. Tabs could be exited and reopened; however, the same
as more and more systems use it. problems would happen consistently.

Unique aesthetic it shouldnt happen


The default login manager is very simple: a drop-down list That also wasnt the only extra package we had issues with bit.ly/LUDSL3
for users, and a few options in the corner hidden away that trying to install Cinnamon went terribly, with only a patchy
let you change the locale and desktop session. Nothing
fancy. However, the default desktops each have an aesthetic
black screen showing up when trying to boot into it. This
really shouldnt happen, even if its not available as a default Summary
quality unique to SparkyLinux. A nice use of monochrome desktop. At the very least, the default desktops all work well, There are some
great ideas in
icons and colours class up the desktop, and the dock especially the Razor-Qt offering which is fast becoming one
SparkyLinux, and
included with LXDE increases its usability. Theres also a of our favourite lightweight desktops.
it works very well
preconfigured Conky display that gives a great selection of Being Debian based, the repos are of course full of all the unless you decide
system information. This is also present in the live image, just latest and greatest software. The reason SparkyLinux has to step a bit outside
in case you need to keep an eye on your system. iterated so much is because its considered a rolling release the predefined
SparkyLinux has a great graphical system manager, similar basically updated with snapshots from Debian testing at barriers of apps
to the likes of Mageia, albeit not as well laid out or as deep. specific intervals. This should mean that Sparky is always and desktops. Well
The SparkyCenter gives you access to change the theme and up to date if you like to be on the cutting edge. However, we worth a look, but its
overall look of the distro, software sources, Flash and Java dont think its worth it. Being severely limited to basically the not for everyone.
settings, default applications, hard drive management etc. default applications and desktops, however good they are, is
The interface is presented in icons that move into different not the Linux way. Its worth a look, but dont get your hopes up.
layers and while theres no back button, exiting the window Rob Zwetsloot
will take you back a step. Dowload now
The default app selection was nice, although with no
commitment to truly free software. VLC, GIMP and Iceweasel sparkylinux.org

83 www.linuxuser.co.uk
Subscribe Subscribe today & start saving
Non-USA readers see page 32

USA special offer


Subscribe
today and get
5 free issues*
Exclusive subscriber
benefits
Subscribe today and pay just $122
for 13 issues*
Pay as little as $9.39 an issue
usually $15.99 in stores
Your
exclusive For more information and to order visit
offer code:
USA www.imaginesubs.co.uk/lud
Or call +44 (0) 1795 418661
Imagine Publishing publishes more than 20 monthly magazines, some of which
have been running for over 10 years, reaching over 4 million readers every year

*Terms and conditions: This is a US subscription offer, please dont forget to quote USA when ordering. You will actually be charged 80 sterling for an annual subscription. This is equivalent
84 www.linuxuser.co.uk to $122 at the time of writing, although the exchange rate may vary. Five free issues refers to the newsstand price of $15.99 for 13 issues being $207.87, compared with $122 for a subscription.
Your subscription will start from the next available issue. This offer expires 31st December 2013.
Book Reviews
Latest Linux books revealed
REVIEWS

Burn Your Portfolio:


Stuff They Dont Teach You in
Design School, But Should
Scala in Action
Fast-paced real-world Scala tutorial
Authors Michael Janda
Publisher New Riders Scala is gaining many new users, attracted by its convenience
ISBN 978-0321918680 (runs on JVM and .NET); OO implementation (modelled on
Price 22.99 Smalltalk and Eiffel); functional programming features (though it
Score does not force any aspect of this such as immutable data on
Sage advice for the coder); scalability (readily extensible, yet suitable for smaller
all creatives scripting jobs); sane concurrency (through Erlang-style Actors
programmers and web implemented in libraries); productivity (say goodbye to ugly Java
designers, not just artists and illustrators boilerplate); type inference; and compatibility with Java libraries.
that should be common sense, but comes Raychaudhuri evangelises these features, but quickly
(if at all) from decades of experience. Its gets you to practical appreciation as in chapter 2 you build
never too late to learn improve your work a command-line REST client, and in chapter 3 you code a
and your workplace with Jandas blog- MongoDB driver using Scala classes and traits. Functional
post-sized bites of wisdom. data structures make a logical stepping stone to functional
Authors Nilanjan Raychaudhuri
programming, and the book stays practical with web apps,
Publisher Manning
databases and concurrent programming.
Vagrant: Up and Running ISBN 978-1935182757
Testing, Java interoperability, and scalable distribution with
Price 28.99
Author Mitchell
Score Akka round off this excellent, fast-paced (if you want good-but-
Hashimoto
Publisher OReilly gentle, try Odersky) tutorial.

Emergent Design:
ISBN
Arduino Adventures:
978-1449335830
Price 22.99
Score
Escape From Gemini Station The Evolutionary Nature
Virtual development
Fun and imaginitive of Professional Software
environments the
easy way, with two
Arduino inroduction Development
commands to get a Improve old code
virtual machine up, then easy sync of Authors James Floyd Kelly & professionalise
complex development environments. & Harold Timmis programming
Publisher APress
Automated provisioning includes Chef, Author Scott L Bain
ISBN 978-1430246053
Puppet and shell script options. Vagrant Price 23.50 Publisher Addison Wesley
creator Hashimoto expounds, explains, Score ISBN 978-0321889065
and expands including a section on Price 38.99
writing plug-ins. Framing an Arduino tutorial in a science-fiction Score
story is a big risk. Fortunately, Timmis and Kelly
Functional JavaScript: have made both story and tutorial work, as their A profession an agreed-upon set of minimal
Introducing Functional engaging characters get caught in an adventure standards, and a clear path of entry is not a way
Programming with Underscore.js that can only be survived with the help of some of describing software development, but Scott
Author Michael Fogus
creative, breadboard-based, hardware hacking Bain would like it to be and, with Emergent Design,
Publisher OReilly something they must learn from scratch, along sets out his view of the standards to improve our
ISBN 978-1449360726 with the reader. lot as creators of software.
Price 22.99 An imaginative way of justifying the various To make (inevitable) change an opportunity,
Score beginner projects which can build knowledge Emergent Design leans heavily on Gang-of-
both of electronics, and of Arduino programming, Four patterns and refactoring (with attention
this book should carry young minds easily past to coupling, cohesion, redundancy, readability,
some new concepts, and through the acquisition testability) so Bain concentrates exclusively on
of a number of skills. object-oriented languages and techniques.
The near-ubiquity of JavaScript in Fiction, theory, hardware and software Missing is the functional programming view
the web age makes it a good platform through eight challenges, from simple (most G-o-F patterns are unnecessary in FP
for teaching functional programming potentiometer and LED projects, through languages), but this book is valuable for the
techniques, while applying functional temperature and motion detection, to building questions it asks, and its (practical) optimism:
concepts to JavaScript will improve your your own robot. Rounded off by a comprehensive An old concept that I used to accept code must
apps in many ways though functional parts list for each project, and the advice: Never inevitably decay over time fades away in favour
programming people looking to learn JS stop learning. Recommended for any beginner, of something more hopeful: code can evolve over
may need an additional guide. of any age, wanting to start learning Arduino. time, getting better and better every time I touch it.

85 www.linuxuser.co.uk
Classified Advertising
01202 586421

Rock solid protection


for Raspberry Pi.

Machined Aircraft Aluminium


Integrated Camera Option
Anodized Colour Options
Security Features
Passive Cooling

Proto
Armour
TM

www.protoarmour.com
Raspberry Pi is a trademark of the Raspberry Pi Foundation

Read To Advertise In
anything
good lately?
Shop for quality
magazines, books
and DVDs from
Imagine Publishing
Contact Rhian on 01202 586421
rhian.carter@imagine-publishing.co.uk
MAGAZINES BOOKS DVDS DOWNLOADS GIFTS
Contact us...
Web: www.linuxuser.co.uk
Email: linuxuser@imagine-publishing.co.uk

Questions Facebook: Twitter:


& answers Linux User & Developer @linuxusermag

Your questions
answered
ASK THE EXPERTS
This month your questions
were answered by
Send us your questions and well do our best to answer them!

Russell Barnes has been


a computer and technology
journalist for nearly 15 years

Clonezilla is a powerful disc imaging tool


Rob Zwetsloot studied
aerospace engineering, using
Python to model simulations How do I compile to build the files, and follow up with:

software? $ make
Compiling software from source code isnt that
difficult all it requires are simple build tools .to compile it.
available in all repos. To make sure you have the
correct build tools installed, do the following in a
Debian-based system: Ghost editing
Hi there. Ive been playing around with my
Kunal Deo is a veteran $ sudo apt-get install build- system recently, and decided to do a small
developer of many open essentials overhaul of my disc setup. I created a ghost of
source projects
my main hard drive, which was not full, and am
Alternatively, for other systems, use: now attempting to apply it to a smaller space
than it was originally on.
$ sudo yum groupinstall I figure because the image wasnt full up
'Development Tools' anyway (and there was no important data Ill lose
if I start messing about with it) that I can make
Once you have the necessary source code for the some changes to the file and be able to apply it
software you want to compile, navigate to the to the new disc I want it to be on? Hope you have
folder in the terminal and type: some answers.
Richard Smedley spends
90% of his screen time shelled
into servers in the UK and USA $ ./configure Joe OReilly

88 www.linuxuser.co.uk
Questions & answers
All your technical problems solved
Q/A

Its certainly possible to do this, and you can do so with the following commands:
and it doesnt require a huge
amount of messing around to
$ ffmpeg -i input.mkv -vcodec
libxvid -qscale 5 -s 640x272 -aspect Minty Apple
accomplish either. First of all, 40:17 -r 23.976 -g 240 -bf 2 -acodec My parents have finally decided to join this
boot into a live Linux environment libmp3lame -ab 160k -ar 48000 -async century and get a proper computer rather
from a disc or USB storage. 48000 -ac 2 -pass 1 -an -f rawvideo than relying on me or library computers
Use fdisk -l and make a note of the -y /dev/null to get their information. As family tech
cylinders, heads and sectors, and then edit the support, Ive told them Ill get them set up
image file sda-chs.sf with these new details. $ ffmpeg -i input.mkv -vcodec with a new system they can use for emails
Next, use: libxvid -qscale 5 -s 640x272 -aspect and such. Because theyve never really used
$ parted /dev/sda 'unit s' print 40:17 -r 23.976 -g 240 -bf 2 -acodec computers much at all, I wanted to set up a
noting down the first few lines, and then edit libmp3lame -ab 160k -ar 48000 Linux Mint system for them. However, the
the file sda-pt.parted to match this. -async 48000 -ac 2 -pass 2 -f avi only issue I have is finding spare hardware
Finally, sync/restart and the restore the outlander-q5.avi to get that going. I did find that I have a Mac
image with Clonezilla and you should be all set. This should give you a little more control over Mini lying around, though so I thought
Next time, you could always shrink a partition what youre outputting, and hopefully work a bit about putting Linux on that. However, I seem
to fit the destination before cloning, which better with your DVD player. to recall its not as easy as just putting the
should make it a little easier. live disc in and installing as I found out.

Converted Batch download


Every now and then I come across a website
Im not too bothered about losing OS X,
and would much prefer my parents use Mint
anyway. How do I get it installed on there?
Ive been trying to follow a guide on converting an directory that has a load of individual files I need
MKV to an AVI using MEncoder. It seems to work to download residing within it. I used to use a Jeff Vincent
just fine, but I keep getting problems where it just Firefox add-on to select and download them
plays the audio on some devices. Heres what Im all in one. However, I wanted to know if theres a While Mint and its Ubuntu base
doing to convert the video, by the way: more universal way of me doing it without having have tools to install on Secure
$ mencoder abc.mkv -oac pcm -ovc to get extra add-ons for my browser? Boot systems that use UEFI, it
xvid -xvidencopts bitrate=886 -sub requires the use of legacy
ITC0101.srt -subfont-text-scale 3 -o Colin Still modes to get it work normally.
zzz.avi But we dont have that luxury with a Mac, so
It works fine on my PC, but on my DVD player, you need to do a little more. The main issue is
which has no problem with these codecs usually that it uses a different partition table that
as far as Im aware, it just doesnt work. wont work with Mint, so the easiest thing to
Am I missing something with my command, do if you dont mind losing OS X is convert it
or is there another way I should be going about to something more Linux friendly.
doing this? Make sure any files you want to keep are
backed up, as this method will format the
Tim Daley hard drive. Burn a live CD or DVD of Mint
and put it in your optical drive. Restart the
No, your command seems to be Mac and hold down the Option key to bring
fine, its most likely an issue with up the boot selection screen, and of course
MEncoder and the limited codecs select CD. Boot into the live environment by
on the DVD player. You might be n Web directories can be easily downloaded choosing Try Linux Mint.
better off trying FFmpeg, though, from using wget When Mint loads up, youll next need to
open GParted. By default it should select the
Macs hard drive, so click Device on the menu
bar and then go to Create Partition Table.

Its most likely


A warning will pop up, and then youll want
to click the Advanced triangle. From here

an issue with
youll be able to create a new partition table
format, this time as MS-DOS.

MEncoder and the


After that is done, you can install Linux
Mint however you wish. Wed suggest using

limited codecs on
Cinnamon if your parents are more used to
Windows systems, and show them how to

the DVD player


install apps from the Software Centre.
n Not everything has the latest codecs

89 www.linuxuser.co.uk
Questions Facebook: Twitter:
& answers Linux User & Developer @linuxusermag

One method wed recommend


using on Linux would be wget, the
standard downloading tool for
the command line. You can
download the contents of a web
directory with something like:

$ wget --mirror -p --convert-links


-P /destination/folder/ http://www.
websitre.com/directory/

You can also use curl as well. This can also


be used with single files if you find yourself
Battery management is not always easy
without a browser to use.

Assault on
battery
I want to have a notification show up in the
event that my laptop battery charge falls below
10%, as I regularly move around when working
on it. I guess that most desktop environments
provide a notification of this sort, but I use
xmonad with a few other programs, so I just
need something like a notification daemon
and front-end. Ive had a few close calls while
working so far, and Id really rather not go back
to a desktop environment if I dont have to.
Can you suggest any notification tools?
I would prefer a lightweight package that
I can extend with other notifications, but
any suggestions are welcome. If there are
any DE notification tools that work well
outside of their environments, that would
Make sure Java knows where itself is located
also do.

Chris Dodd how do I go about setting up my system to use Now you need to run some specific commands
the Oracle JDK? Im currently running Ubuntu. to update the system Java info, allowing you to
Theres actually a couple of great Thanks. then switch to it. First of all do:
tools you can use on xmonad to
get this type of functionality. You Peter Chan $ sudo update-alternatives --install
can use i3, which is a tiling window "/usr/bin/java" "java" "/usr/lib/
manager, which can be used on its Okay, so the process for doing this jvm/jdk1.7.0/bin/java" 1
own or in conjunction with twmn. Both offer is a two-step one. Firstly, you
tiling notification windows, and i3 is specifically need to download the JDK files $ sudo update-alternatives --install
designed to work with the xmobar as well. from the Oracle website, which "/usr/bin/javac" "javac" "/usr/lib/
i3 is also very extendable, and it can be used come in a tarball. Extract these jvm/jdk1.7.0/bin/javac" 1
for a lot more than just battery notifications. and this will create a ./jdk.1.7.0_0x directory in
Hope this helps. the location of your choosing. $ sudo update-alternatives --install
"/usr/bin/javaws" "javaws" "/usr/
Oracle of Java Now create a new directory for it and move into
it with:
lib/jvm/jdk1.7.0/bin/javaws" 1

So I have the OpenJDK installed on my system, Now, correct the file ownership and the
and it turns out I need to use the official Oracle $ sudo mkdir -p /usr/lib/jvm permissions of the executables with:
JDK for a project Im working on. Only, it seems $ sudo mv ./jdk.1.7.0[Current
like I cant just install it and expect it to work Version] /usr/lib/jvm/jdk1.7.0 $ sudo chmod a+x /usr/bin/java

90 www.linuxuser.co.uk
Questions & answers
All your technical problems solved
Q/A

n When connecting remotely, some settings


n The right drivers dont always produce the right response are different for displays

$ sudo chmod a+x /usr/bin/javac and then enter the following into it:
/usr/lib/jvm/java-7-openjdk-amd64/

Open the
$ sudo chmod a+x /usr/bin/javaws jre/lib/amd64
/usr/lib/xulrunner-17.0

terminal while
$ sudo chown -R root:root /usr/lib/
jvm/jdk1.7.0 and run ldconfig as root. Choose /home for

logged in as root,
the user and libnpjp2.so file locations. The
Now we need to select the new JDK by running: Oracle and OpenJDK versions of Java are linked

and then change


$ sudo update-alternatives --config to PulseAudio, so sound-wise youre better off
java using PulseAudio.

to another user
Theres some Java OpenGL packages, too,
Youll be shown a list with numbers from which that you might want to install with:
to choose the new JDK from make sure to
choose the one weve been setting up. Now we $ dpkg-query --load-avail -l
can make sure its done properly by checking '*jogl*'
the Java version with: As root works, heres a little thing
$ java -version Hopefully that should fix things up for you. you can try open the terminal
while logged in as root, and then
You can now also switch back to OpenJDK, if you
need to, with the config java command. Terminal trouble change to another user with:

Im experiencing a very weird problem every $ su -l <user>


Graphical Java now and then I need to do some work in the
terminal on my system. However, whenever I try This will allow you to open another shell to log
Ive just upgraded my box to the Radeon drivers, and open the terminal emulator, it opens for a in with and then try to open the terminal. Any
and its so far proved to be a good idea. The box brief instant and then automatically closes. errors will show up in the root terminal. What
runs smoothly now. There are some issues with The system in question is CentOS, which I may likely happen is that you cannot even load
Java OpenJDK, though. have to access remotely via VNC. Its using Xfce into the shell.
How do I get it to use OpenGL? There may well as a desktop environment as well. The weird
be the option to use Suns Java, but it needs thing is, it works just fine if Im logged in as root, This is because the user will not have access to
AOSS so, either I tweak the OpenJDK to not so I can only assume its a problem with the connect to the X server because youre using it
crash and use OpenGL/acceleration; or I use user type. Obviously, I dont want to make some via VNC. To solve this, you just need to add the
Suns JRE, but it would involve installing OSS. of the normal users have full root privileges, relevant users to the list that are allowed to
and Id much rather not log in as root every make this connection. You can do this with xhost
Chris Kimpton time I work on this system. Have you heard of by typing:
Youre going to have to use a little anything like this before? Is there something
hack so that Java knows where fairly obvious that Im missing? # xhost local:<user>
its located. Create it with: Thanks for any help.
$ nano /etc/ld.so.conf.d/ as root. Give the system a reboot and it should
javaworkaround.conf Thomas Reid now be working fine.

91 www.linuxuser.co.uk
Sponsorship opportunity
Hosting listings
Bring attention to your brand by sponsoring this
section. Contact Rhian Carter on +44(0)1202586421

Dedicated server listings


Got a deal
you think we

REMOTE POWER REBOOT


should list?

24/7 PHONE SUPPORT


UPTIME GUARANTEE

NETWORK BACKUP
PERMANENT KVM
1GBPS INTERNET

PRIVATE SUBNET
HARDWARE RAID
CONTRACT TERM
Whether youre a hosting firm or
a happy customer who wants a

CONNECTION
CPU CORES /

DISK SPACE
favourite provider listed, drop us

MINIMUM
COST PER
PACKAGE

STORAGE
NUMBER

a line with the details!

MONTH
PHONE

SPEED
linuxuser@imagine-publishing.co.uk

NAME AND URL

Dual Core
2200DC 0800 061 2801 50 1 month 160GB N/A Raid 1
2.2GHz

Dual Core
3000DC 0800 061 2801 80 1 month 2 x 250GB N/A Raid 1
3GHz

Intel Quad Core


2660QC 0800 061 2801 130 1 month 2 x 500GB N/A Raid 1
2.66GHz

Developer 0800 061 2801 32.89 1 month N/A 1GB N/A

One 0800 061 2801 109.99 1 month N/A 5GB N/A

Netcetera
www.netcetera.co.uk/linux Reseller 0800 061 2801 274.89 1 month N/A Unlimited N/A

Bravo14 (http://bravo14.co.uk) Starter Linux N/A 20 N/A N/A 2,000MB N/A

Bravo14 (http://bravo14.co.uk) Starter Windows N/A 20 N/A N/A 2,000MB N/A

Bravo14 (http://bravo14.co.uk) Business Linux N/A 45 N/A N/A 4,000MB N/A

Bravo14 (http://bravo14.co.uk) Business Windows N/A 45 N/A N/A 4,000MB N/A

Bravo14 (http://bravo14.co.uk) Ultimate Linux N/A 60 N/A N/A Unlimited N/A

Bravo14 (http://bravo14.co.uk) Ultimate Windows N/A 60 N/A N/A Unlimited N/A

12 Dual/Quad 160GB
FlexServer2 01628 777730 From 29 10Mbps 99.90% 10 GB
months Core to 2TB

100
BudgetBox III 01628 777730 36 1 month Intel Xeon 3065 1 x 250GB 99.90% 10 GB
Mbps

Quad Core Intel 120GB Intel 100


SSD 4 01628 777730 60 1 month 99.90% 10 GB
Xeon X3430 520 SSD Mbps

2 x Intel Xeon 2 x 500GB 100


Merlin 01628 777730 199 1 month 99.90% 10 GB
Quad Core SATA II Mbps

2 x Intel Xeon 4 x 1TB 100


DS6.5 01628 777730 295 1 month 99.90% 10 GB
Hex Core SATA III Mbps

Gbit
Cloud Server 01628 777730 52 1 month 2 vCPU (4GB) 40GB shared / n/a 99.90% O
node

Gbit
PoundHost Cloud Server 01628 777730 98 1 month 4 vCPU (8GB) 40GB shared / n/a 99.90% O
www.poundhost.com node

Heart Internet (www.heartinternet. Dual Core Xeon 24/7 Ticket


Linux Dual Core 0845 644 7750 79.99 12 months 160GB 99.99%
co.uk/dedicated-servers) 2.33GHz support

Heart Internet (www.heartinternet. Dual Core Xeon 24/7 Ticket


Windows Dual Core 0845 644 7750 89.99 12 months 160GB 99.99%
co.uk/dedicated-servers) 2.33GHz support

Heart Internet (www.heartinternet. Quad Core Xeon 24/7 Ticket


Linux Quad Core 0845 644 7750 129.99 12 months 250GB 99.99%
co.uk/dedicated-servers) 2.5GHz support

12 Quad Core
Unlimited 0208 123 2730 1.79 Unlimited N/A N/A 99.9% N/A N/A
months Xeon

Zyma Unlimited 0208 123 2730 7.95 3 months


Octo Core
Unlimited 99.9%
www.zyma.com Xeon

O = Option

92 www.linuxuser.co.uk
GET YOUR LISTING HIGHLIGHTED! CONTACT RHIAN
rhian.carter@imagine-publishing.co.uk
+44(0)1202586421 Hosting listings
LISTINGS

Dedicated and Shared server listings

PHONE SUPPORT
SHOPPING CART

EMAIL SUPPORT

SERVICE LEVEL
WEB CONTROL
VIRUS FILTER

AGREEMENT
BANDWIDTH
WEB SPACE

ACCOUNTS

DATABASE

FIREWALL
MONTHLY

SUPPORT
PACKAGE

NUMBER
PHONE

PANEL
POP3
COST
NAME AND URL
Minimus
+44 (0)845 5280242 49.95 10GB 200GB Unlimited
Linux / Windows

Medius
+44 (0)845 5280242 89.95 20GB 400GB Unlimited
Linux / Windows
Blacknight Maximus
+44 (0)845 5280242 149.95 30GB 600GB Unlimited
www.blacknight.com Linux / Windows

eHosting (www.ehosting.com) Starter 0844 999 4100 23.88 1GB 25GB 10


eHosting (www.ehosting.com) Personal 0844 999 4100 59.88 2.5GB Unlimited 50

eHosting (www.ehosting.com) Expert 0844 999 4100 95.88 5GB Unlimited 250

eHosting (www.ehosting.com) Virtual 0844 999 4100 227.88 50GB Unlimited Unlimited

Equiphase (www.equiphase.net) Bronze 0121 314 4865 30 200MB 2GB 10

Equiphase (www.equiphase.net) Silver 0121 314 4865 42 400MB 5GB 20

Equiphase (www.equiphase.net) Gold 0121 314 4865 72 800MB 10GB 100

Equiphase (www.equiphase.net) Platinum 0121 314 4865 114 1,200MB 40GB 200

Eurofasthost.com (www.eurofasthost.com) Email Only 02380 249 823 40 1GB 2GB 10

Eurofasthost.com (www.eurofasthost.com) Essential 02380 249 823 75 2GB 5GB 10

Eurofasthost.com (www.eurofasthost.com) Superior 02380 249 823 140 5GB 10GB 25

Eurofasthost.com (www.eurofasthost.com) Premium 02380 249 823 250 10GB 25GB 100

Evohosting (www.evohosting.co.uk) Starter N/A 29.99 500MB 1GB 3

Evohosting (www.evohosting.co.uk) Home N/A 54.99 2.5GB 30GB 50

Evohosting (www.evohosting.co.uk) Business N/A 79.99 6.5GB Unlimited Unlimited

Evohosting (www.evohosting.co.uk) eCommerce N/A 159.99 30GB Unlimited Unlimited

Personal 0808 168 6777 32.87 5GB Unlimited 50

Business Bronze 0808 168 6777 58.38 50GB Unlimited 500 O

Business Silver 0808 168 6777 76.39 Unlimited Unlimited Unlimited O

Business Gold 0808 168 6777 101.89 Unlimited Unlimited Unlimited

WD Starter 0808 168 6777 149.99 20GB Unlimited Unlimited O O


Fasthosts
WD Advanced 0808 168 6777 199.99 Unlimited Unlimited Unlimited
www.fasthosts.co.uk O O

Giacom (www.giacom.com) Business Pro 0800 542 7500 199 100MB 2GB 100
Heart Internet (www.heartinternet.co.uk) Starter Professional 0845 644 7750 29.80 2.5GB 10GB 1,000

Heart Internet (www.heartinternet.co.uk) Home Professional 0845 644 7750 89.99 10GB 50GB 10,000

Heart Internet (www.heartinternet.co.uk) Business Professional 0845 644 7750 129.99 Unlimited Unlimited Unlimited

Heart Internet (www.heartinternet.co.uk) Reseller Professional 0845 644 7750 299.99 Unlimited Unlimited Unlimited

Hostway (www.hostway.co.uk) Silver 0808 180 1880 79.50 150MB 3GB 5 O

WebFusion (www.webfusion.co.uk) Fusion Professional 0845 130 1602 107.40 5GB 50GB 1,000
WebFusion (www.webfusion.co.uk) Fusion Business 0845 130 1602 179.40 10GB 150GB 1,500

WebFusion (www.webfusion.co.uk) Fusion Developer 0845 130 1602 227.40 20GB 300GB 5,000

WebFusion (www.webfusion.co.uk) Fusion Reseller 0845 130 1602 329.99 Unlimited Unlimited Unlimited

Eco Web Hosting (www.ecowebhosting.co.uk) Starter N/A 29.99 200MB 2GB Unlimited

Eco Web Hosting (www.ecowebhosting.co.uk) Standard N/A 54.99 1GB 10GB Unlimited

Eco Web Hosting (www.ecowebhosting.co.uk) Advanced N/A 119.99 20GB 24GB Unlimited

Eco Web Hosting (www.ecowebhosting.co.uk) Reseller Unlimited N/A 199.99 Unlimited Unlimited Unlimited

NameHog (www.namehog.net) Email Only 0845 612 0330 11.75 25MB 1GB 5

NameHog (www.namehog.net) Standard Package 0845 612 0330 35.25 100MB 4.5GB 10

NameHog (www.namehog.net) Professional Package 0845 612 0330 58.75 250MB 8GB 25

O = Option

93 www.linuxuser.co.uk
Your view Your source of Linux news and views
Contact us
Register and post your comments Email us directly
www.linuxuser.co.uk/forum/ linuxuser@imagine-publishing.co.uk

YOUR VIEW

Linux User
Letters
Your opinions about
the magazine, Linux
and open source
Piece of Pisi
I remember a while ago you talked about Pisi
Linux, an alternative to Pardus that was a bit more Pisi Linux is currently in beta
like the original. I was sad to see that DistroWatch reaches stable release theyll add Pisi back to the story, it seems like DistroWatch were duped;
refuses to even list Pisi Linux because someone database, as the older Parduses were some of my however, the folks over at DistroWatch
trolled them, telling them it was not active, favourite distros! havent responded to the Pisi team since their
setting up fake Pisi Linux sites etc. DistroWatch Mark Doyle explanation. The beta for it is out now, but
apparently decided they would remove it from Pisi is not back on DistroWatch just yet. Look
their lists. Very sad and disappointing on the Its a shame that DistroWatch took the out for a review of the full version when its
part of DistroWatch. I hope that when it finally stance. Going by the Pisi teams side of the finally released.

THREAD BARE

Way of the future


Things are heating up in the display server space, as both
Wayland and Canonicals Mir are set to try to replace the
X server shortly. Richard Hillesleys piece on Wayland in issue
127 inspired some debate on the website about replacing X. Join
in the conversation here: bit.ly/LUDWay

Henrik Danielson said:


Wayland was supposed to be that common protocol/API. As far as
I can tell, one problem is that Mir is intentionally incompatible
with Wayland.
Wayland is intended as a simpler replacement for X
Bob Robert said:
I use the network display functionality of X on a regular basis. The things shouldnt be that bad either, because Mir/Wayland support is at
switch to Wayland is fine by me (Im a user, not a programmer) so the toolkit level. The biggest burden will probably be on the toolkits,
long as I can still ssh -Y and launch GUI applications that display on my though: having to have and support two back-ends in addition to X
local machine. That X did network transparency mainline and Wayland (because X will not be totally going away any time soon).
would do it with a plug-in is actually unimportant to me. What matters is
that it DOES it. It is functionality I use, and want. Gene Mosher said:
Keith Packard asks: How many of these applications care about
bwat47 said network transparency, which was one of the original headline
I dont think the situation is quite as bad as it seems. Both Mir features of X? How many of them care about ICCCM compliance? How
and Wayland have several major similarities in their architecture, many of them care about X at all? The answer to all of those questions, of
such as using EGL. For drivers, theoretically it should not be difficult to course, is very few. And if we all are among the very few, then what
support both as long as they provide EGL support. For applications does the future hold for us, Keith?

94 www.linuxuser.co.uk
Your view
Pisi Linux, Wayland vs Mir, Specialist distros, Pi projects
LETTERS

Android Magazine
With more and more
Android features being
merged back into
the Linux kernel, its
becoming easier to
develop for one of the
most popular mobile
operating systems
around. With over 25
billion app downloads,
and over 500 million Android devices worldwide,
theres a huge audience ready to consume
apps. For a more Android-driven editorial,
look to our sister mag Android Magazine, the
only publication dedicated to the platform.
Along with news and reviews to keep you
up to date on everything Android, there are
also tutorials and advice on developing and
hacking your hardware. Find out more at
Some specialist distros are more than a selection of apps www.littlegreenrobot.co.uk.

Specialist distros Raspberry Pi projects you had. I tried out a


couple of them and was pleased with the
Were glad you enjoyed the projects, Phillip.
We always love to hear about Raspberry Pi
Okay, I am a little confused with the whole distro results; there are really so many things you projects ideas from all of our readers, even
designed for specific job trend. If I want to run can do with the Raspberry Pi! I now use my just to feature on their own in the magazine.
audio applications in Windows, Mac or any other Raspberry Pi for all my media centre needs and We usually try to get at least one Raspberry
OS, I install the programs I want. havent looked back I even have a spare SD Pi related tutorial or feature in the magazine
Why oh why with Linux do we see this card for using it as a portable access point for every month for example, in this issue you
approach of just install the audio distro for the when I go travelling. Will you be doing another can find out how to turn that portable access
best audio environment. What a waste! Instead feature like this in the future? If so, will I be point into a secure router with our Onion Pi
of customising an existing distro and having a able to suggest some projects? I have a few in tutorial starting on page 46. You can send
nice aptitude/yum install audio-env we get mind which I feel will properly make use of the any ideas to the email address at the top of
all the overhead of maintaining a distro just for Raspberry Pi. this page.
the applications? Thanks again,
Isnt it time we separated the application from Phillip Cordaro
the OS and ignored any attempts by people to
integrate the two? Raspberry Pi projects
Colin McDermott bring out the practical
side of Linux
Theres no specific reason why you cant do
this anyway a lot of people will probably be
fine with a standard Fedora or Ubuntu install
for any of their specialised needs. However,
some distros do more than just come with
a selection of themed default packages
distros like AV Linux go the extra mile and
customise the kernel specifically for AV
software. Not everyone has the skills to do
that in Linux, so these kind of distros do serve
a purpose. The same with some lightweight
distros. Its about choice, and this offers a lot
more choice for people.

More Pi Facebook: Twitter:


Ive just finished reading issue 129 of your
magazine and was very inspired by the ten Linux User & Developer @linuxusermag
Next issue Whats coming up Look out
for issue 132
on sale 24 Oct THE MAGAZINE FOR
THE GNU GENERATION
Want it sooner?
Subscribe
Imagine Publishing Ltd
Richmond House, 33 Richmond Hill

today!
Bournemouth, Dorset, BH2 6EZ
+44 (0) 1202 586200
Web: www.imagine-publishing.co.uk
www.linuxuser.co.uk
www.greatdigitalmags.com

COMING IN THE NEXT ISSUE Magazine team


Editor Russell Barnes

CLOUD
russell.barnes@imagine-publishing.co.uk
01202 586272
Staff Writer Rob Zwetsloot
Photographer James Sheppard
Senior Art Editor Will Shum
Editor in Chief Nick Jones
Head of Publishing Aaron Asadi

STORAGE
Head of Design Ross Andrews
Contributors
Phil King, Richard Smedley, Jon Masters, Himanshu Arora, Richard
Hillesley, Michael Reed, Gareth Halfacree, Joey Bernard, Simon Brew,
Sandra Vogel, Steve Mumby, Mihalis Tsoukalos, Eden Frankham,
Kunal Deo, Abbi Denney & David Crookes
Advertising

SUPER-TEST
Digital or printed media packs are available on request.
Advertising Director Matthew Balch
01202 586437
matthew.balch@imagine-publishing.co.uk
Head of Sales Hang Deretz
01202 586442
hang.deretz@imagine-publishing.co.uk
Advertising Manager Jennifer Farrell
01202 586430
The ultimate Linux solution revealed jennifer.farrell@imagine-publishing.co.uk
Account Manager Rhian Carter
01202 586421
rhian.carter@imagine-publishing.co.uk
Cover disc
Junior Web Designer Steve Dacombe
ludxtrahelp@imagine-publishing.co.uk
International
Linux User & Developer is available for licensing.
Contact the International department to learn more.
Head of International Licensing Cathy Blackman
+44 (0) 1202 586401
licensing@imagine-publishing.co.uk
Subscriptions
Head of Subscriptions Gill Lambert
For all subscriptions enquiries
0844 249 0282 (UK)
+44 (0) 1795 418661 (Overseas)
Email: LUD@servicehelpline.co.uk
6 issue subscription (UK) 25.15
13 issue subscription (Europe) 70 (ROW) - 80
Circulation
Head of Circulation Darren Pearce
01202 586200
Production
Production Director Jane Hawkins
01202 586200
Founders
Group Managing Director Damian Butt
Group Finance & Commercial Director Steven Boyd
Group Creative Director Mark Kendrick
Printing & Distribution
Printed by William Gibbons, 26 Planetary Road,
Willenhall, West Midlands, WV13 3XT
Distributed in the UK & Eire by Seymour Distribution,
2 East Poultry Avenue, London, EC1A 9PT.
0207 429 4000
Distributed in Australia by Gordon & Gotch,
Gordon & Gotch Corporate Centre, 26 Rodborough Road,
Frenchs Forest, NSW 2086.
+ 61 2 9972 8800
Distributed in the Rest of the World by Marketforce, Blue Fin
Building, 110 Southwark Street, London, SE1 0SU.

Build your own Scrape Wikipedia 0203 148 8105


Disclaimer

Raspberry Pi robot with Python


The publisher cannot accept responsibility for any unsolicited material
lost or damaged in the post. All text and layout is the copyright of
Imagine Publishing Ltd. Nothing in this magazine may be reproduced

Make all your childhood Get a taste for Beautiful in whole or part without the written permission of the publisher.
All copyrights are recognised and used specifically for the purpose

dreams come true Soup in our coding guide of criticism and review. Although the magazine has endeavoured
to ensure all information is correct at time of print, prices and
availability may change. This magazine is fully independent and
not affiliated in any way with the companies mentioned herein.

Master Git in ALSO INSIDE: If you submit material to Imagine Publishing via post, email, social
network or any other means, you automatically grant Imagine Publishing

>> Master the RasPi camera an irrevocable, perpetual, royalty-free license to use the images across

easy steps
its entire portfolio, in print, online and digital, and to deliver the images

>> LTE Open Phone reviewed to existing and future clients, including but not limited to international
licensees for reproduction in international, licensed editions of Imagine

The worlds favourite version control >> Visualise data with Graphviz
products. Any material you submit is sent at your risk and, although
every care is taken, neither Imagine Publishing nor its employees,

system isnt as easy as it could be >> Protect your network with FOSS agents or subcontractors shall be liable for the loss or damage.
Imagine Publishing Ltd 2013
ISSN 2041-3270m

98 www.linuxuser.co.uk
CONVERT
PRINT
CREATE
COMBINE
& MODIFY

100% Standalone - No Office Automation

many MORE

SCAN FOR
20% SAVINGS

You might also like