softarchive.net linuxformatukfebruary2014truepdf

Download Softarchive.net LinuxFormatUKFebruary2014TruePDF

If you can't read please download the document

Upload: ganishiang

Post on 08-Apr-2016

67 views

Category:

Documents


0 download

TRANSCRIPT

  • 84 LXF180 February 2014 www.linuxformat.com

    Our expert

    Scratch is available across many platforms. It comes pre-loaded on every Raspberry Pi running Raspbian and is available for download from http://scratch.mit.edu. But did you know that there is an online version that provides all of the functionality present in the desktop version, but requires no installation or download? Head over to the MIT website (above) and youll be

    greeted with the same interface and blocks of code, but with a few subtle differences. This is the latest version of Scratch and you can save all of your work in the cloud ready to be used on any PC you come across. If you wish to use the code built online on a PC that does not have an internet connection. Then you can download your project and run it offline.

    You can also download the latest version of Scratch from their website. This latest version is still in beta but reports show that it is very stable and ready for use. Scratch 2.0 uses Adobe Air and is available across all platforms including Linux. Adobe dropped support for Air on Linux a few years ago but you can still download the packages necessary for Scratch 2.0 to work.

    Scratch online

    Scratch

    Les Pounder enjoys tinkering with lots of new languages and gadgets and finds jQuery great fun.

    Les Pounder runs through the basics of Scratch for those itching to code or looking for ways to teach others to code.

    Scratch: and go

    How did you learn to program? Typically, we think of a person sitting in front of a glowing screen fingers slowly typing in magic words that, initially, mean nothing to the typist. And in the early days of coding that was the typical scene with enthusiasts leaning by rote, typing in reams of code printed in magazines.

    In this modern era where children are now encouraged to learn coding concepts as part of their primary school education, we see new tools being used to introduce coding to a younger generation and the most popular tool is the subject of this very tutorial.

    Scratch, created by MIT, is a visual programming environment that promotes the use of coloured blocks over chunks of code. Each set of blocks provides different functionality and introduces the concepts of coding in a gentle and fun way. Children as young as six are able to use Scratch and its now being heavily used in the UK as part of the curriculum for key stages 1 to 3 (6- to 14-years-old) and as part of the Code Club scheme of work.

    For the purpose of this tutorial, we are using the current stable version of Scratch, which at the time of writing is 1.4. Version 2 of Scratch is available as a beta and reports suggest that its very stable to use, but there are a number of

    differences between the locations of blocks when comparing version 1.4 to version 2.

    As mentioned, Scratch uses a block-based system to teach users how different functions work in a program. This can be broken down into the following groups and colours:

    Motion (Dark Blue) This enables you to move and control sprites in your game.

    Control (Orange) These blocks contains the logic to control your program (loops and statements) and the events needed to trigger actions, such as pressing a key. In Scratch 2.0 the events stored in Control have their own group called Events.

    Looks (Purple) These blocks can alter the colour, size or costume of a sprite and introduce interactive elements such as speech bubbles.

    Sensing (Light Blue) For sensing handles the general input needed for your program, for example, keystrokes, sprite collision detection and position of sprite on the screen.

    Sound (Light Purple) Adds music and sound effects to your program.

    Operators (Green) This enables you to use mathematical logic in your program, such as Booleans, conditionals and random numbers.

    Pen (Dark Green) This is for drawing on the screen in much the same way that logo or turtle enable you to do so.

    Variables (Dark Orange) Creates and manipulates containers that can store data in your program.

    By breaking the language down into colour coded blocks Scratch enables anyone to quickly identify the block they

    Scratch uses a three-cloumn UI from left to right: Block Palette, Script Area and The Stage

    Fig 1.0 The logic for our LXF logo sprite.

    Fig 1.2 This is the code that clears effects.

  • www.tuxradar.com February 2014 LXF180 85

    Scratch

    need. Children typically work via the colour coding system at first and then through the natural process of playing they understand the link between each of the blocks and how they work together.

    The environmentScratch uses a clear and structured layout, which is divided into three columns.

    The first column is: Block Palette

    This is where our blocks of code are stored and sorted by their function.

    Script Area In the second column is an area, where you can drag our blocks of code

    from the Block Palette to add code to our program. The Stage The third and final column shows the results of

    your programming and can be used to interact with the game world. At the bottom of this column you will also find the very handy Sprites Pane. This shows the sprites and assets that belong to your particular program. Clicking on a sprite will change the focus to that sprite, enabling you to write code for that sprite only.

    Building our gameTo write code with Scratch, we need to move blocks of code from the Block Palette to the Script Area for each sprite or background that we want to use in our program.

    For this tutorial, we are going to make a quiz game, using Matt and Neil as our quiz masters. The purpose of the game is to score more than 3 points and you must answer the question correctly to progress to the next round. If you receive three wrong answers in the game, then its game over. Each of our sprites has their own scripts assigned to run once an event triggers it. An event is typically clicking on the green flag to start the game but it can be as complex as listening for a trigger from another sprite.

    Weve given our four games sprites names: Neil is Sprite6, Matt is Sprite7, the LXF Logo is Sprite5 and the Game Over image is Sprite8. Each of these sprites has their own scripts associated with them, so lets look at what they each do; starting with the LXF Logo. I wanted this logo to appear right at the start of the game, but not be visible straight away, so my logic was as follows:When Green Flag clicked. Hide.Wait for 2 seconds. Show. Double in size. Loop 10 times and each time reduce size by 15%

    You can see this as Scratch presents it visually in Fig 1.0.Now lets look at the logic for Matts sprite. Matt has five

    sections of code that react to something called a broadcast, which is basically a way to chain trigger events between sprites in the program (you can find broadcast under control) So we have a number of actions to perform once we receive these broadcasts from Neil and the Stage.

    player_name The Stage sends a broadcast once the player has entered their name.

    support Neil sends a broadcast to Matt once the player has

    answered a question correctly. insult Neil sends a broadcast to

    Matt to taunt the player. Score Neil sends a broadcast to

    Matt triggering Matt to tell the player their score.

    game_over Neil sends Matt a broadcast to trigger the end of the game.

    As we can see (Fig 1.1, left) for each of these broadcasts Matt is triggered to run a certain sequence of code. Matt also has a script thats run in the event of clicking on the green flag. Fig 1.2 (see left, p84) shows the code that clears any special effects used on his sprite.

    Lets move on to Neil. This sprite has a lot more code than Matt. This is because hes the main part of our game.

    First, theres the Green Flag event. What this does is triggers Neils sprite to reset any special effects that may be in use and then stores 0 in the variable called guesses (see Fig 1.3, above right).

    The second part, is the loop that controls our game. This large loop is triggered once we receive the name of the player, which is handled via the code associated with The Stage, which we will come to later.

    Ive broken Matts main loop into three parts. At the start of the game, theres a section of code associated with The Stage that asks for the players name. It then stores that as a variable called Answer, which is stored in the Sensing category of blocks. Once the user enters their name, the script associated to the stage sends a broadcast called player_name. Neils code is waiting to receive this broadcast as a trigger event. Once the code is triggered Neil will say hello to the player by their name, using the Answer variable.

    Once we have the formalities out of the way, we move on to the main loop that controls the first question. We wrap the question in a loop that will repeat until the correct answer is given, which is repeat until answer = ubuntu.

    We then ask the question and run another loop inside of the main loop (see Fig.5, below). This second loop is an if statement which uses a condition to perform a certain sequence of code if a condition is true, or if it is false it will run the code associated with else. In the case of the answer being

    Fig 1.4 Part 1 of the main game code.

    Fig 1.1 The code used for Matt to receive broadcasts.

    Fig 1.5 The second loop of Neils code inside the main loop.

    Fig 1.3 This resets Neils sprite and the guesses variable.

    Right-clicking on a block of code is a quick way to duplicate or delete your code.

    Quicktip

  • www.linuxformat.com86 LXF180 February 2014

    Scratch

    correct, Neil will say that the answer is correct, play a sound to reward the player then alter the variable score by 1 point and, finally, broadcast support to Matt who will say something nice. If the player provides an incorrect answer then Neil will say Incorrect play a gong sound effect and then increment the guesses variable by 1 and then send a broadcast to Matt who will taunt the player.

    Part two of the code is exactly the same as the main loop of part one and the reason why is because we duplicated the code and changed the question and expected answer. To duplicate code in Scratch you can simply right click on the blocks of code and select duplicate, hey presto you have doubled your code in just one click.

    The first section of the third part is exactly the same as the main loop from the previous two parts. So lets move down to the last four blocks of code (see Fig 1.6, below). Our first block is a broadcast score to Matt, this will trigger Matt to tell us the score, we then pause for three seconds to allow Matt to finish speaking. Then we send another broadcast to Matt who will then run thorough the end of game code associated with that broadcast. Lastly, we use stop all to stop any scripts in the game.

    The Green Flag event is the code that controls the number of guesses that the player has. We use conditional logic to say that when the number of guesses is equal to 3 then we

    broadcast game_over to Matt, which, in turn, triggers the end of game script.

    The Game Over sprite has two scripts associated with it. The first is simply when the green flag is clicked to hide the sprite. The second script is triggered when the game_over broadcast is sent. It triggers the sprite to reveal itself and set its size to 100%. We then use a loop that will repeat 10 times to change the size and rotation of the sprite, giving us a rotating zooming effect just like what youd see in the classic 8-bit games of the 1980s.

    The StageAs well as being the home of our sprites, The Stage can also contain its own scripts (see Fig 1.7, above). For our game we have two sections of code on The Stage. Both sections of code are triggered by the click on Green Flag event. The first part resets two variables called guesses and score. We then ask the player to provide their name, which is then broadcast to Matt and Neil and starts the main code loop assigned to Neil. The second section of code is an infinite loop that will play the loop DrumMachine continuously and set its volume to 50%.

    As I mentioned earlier on, variables are a great way to store data. But before we can use one we need to create it. To create a variable we need to use the Variables button from the Block Palette. In there you will find the make a variable button, click on it and you will see Fig 1.9 (see right, p87).

    In our game we used two variables, score and guesses and we want them both to be available for all sprites, so that Matt and Neil can use them both. Once created, we can easily

    Using Scratch is great fun but did you realise that you are also learning to code? No matter what language you use, the underlying concepts of coding provide a firm foundation. And once learnt they can be applied to any coding project. The main concepts are:

    Sequences: A series of tasks required to be completed in a certain order. For example the steps needed to solve a maze. Loops: A way to repeat a sequence. They can be run forever (while true) or controlled using a for statement (for x in range(0,3)). We have used many loops to control the players progress in our game.

    Parrallelism: This is the principle of running more than one sequence of code at the same time. Weve used that a lot in our Scratch game as each sprite has its own code that runs in parallel to each other.

    Events: This is a trigger that starts a sequence of code and the most visible event in our Scratch game is clicking on the green flag to start the game.

    Data: We use a variable to store the value of our score and we can later retrieve and manipulate the score to show the players progress through the game.

    Operators: These are the basic mathematical

    rules that we all learn in school. We can apply operators to text and numbers, which enables us to perform calculations in our code and iterate data if required.

    Conditionals: These form the basis of our logic and provide a method for us to compare data against the input that is given by the player. We have used conditionals in our game to compare the answer given to the expected answer. If they both matched, which in Boolean logic would be classed as True, the player would be awarded a point. If they did not match, which would be defined as False, the player would have to try again.

    Programming concepts

    Fig 1.6 The last part of the main code associated with Neil.

    Fig 1.7 The Stage contains the sprites but can also have its own scripts.

    Blocks that can be linked together will have a white halo indicating they can be connected.

    Quicktip

  • www.tuxradar.com February 2014 LXF180 87

    Scratch

    drop these variables into our code enabling us to reuse their value many times in the game, see Fig 1.8 below for the example that we made for our game.

    Pseudo codeWhen trying to understand the logic of my game we like to write pseudo code. Pseudo what? we hear you say. This is when you write down the logic of how your program will work. Lets look at a simple example:a has the value of 0while a is less than 10:print on the screen the value of aincrement a by 1

    So we have our psuedo code, but how do I express this in a programming language? First, lets do this with Scratch followed by Python. In Scratch our code will look like this.[When Green Flag is clicked]Set variable a to 0forever if a < 10 say a for 2 secs change a by 1

    This will give the variable a the value of 0. We then create a conditional loop that will only loop while a is less than 10. Inside the loop we ask Scratch to print the value of a for 2 seconds, then increment the value of a by 1. This loop will continue until we reach a = 9 and then it will stop as the next value, 10 is not less than 10.

    In Python our code looks like thisa = 0while a < 10: print a a = a + 1

    So why did we include that piece of Python code in a Scratch tutorial? It simply illustrates that there isnt a lot of difference in the logic between the two languages and that Scratch can be used to help understand the logic that powers many applications. In both Scratch and Python we create a variable called a and set its value to be 0, from there we create a loop that will continue to iterate round until it reaches 9 (which is less than 10). Every time we go round the loop, we iterate a by 1, allowing us to count the number of times that we have been around the loop.

    Testing our gameWeve done it! Weve made a game. So now lets play our game. The flow of the game should be as follows:Click on green flag.You will be asked for your name.Matt says hello and Neil says hello and your name.They both welcome you to the quiz.Matt prompts Neil to ask the first question.Neil asks a question.A box will appear for you to type your answer.If answer correct, then Neil will say so, Matt will also say something nice.Your score will increase by one.Else if your answer is wrong, you will be taunted by Matt and the number of guesses will increase by 1, leaving you with only 2 guesses left. You will then have another chance to answer the question.If you guess correctly, you will move on to the next question, and this will happen twice as there are 3 questions.If you answer all the questions correctly, Matt will tell you your final score and then say Game Over.The Game Over sprite will appear on screen and all of the scripts in the game will be turned off.If the number of guesses made reaches 3 at any point in the game, then the game will automatically skip to the Game Over screen.

    But this is just the start of our adventures with what you can do with Scratch. In our next issue we will be using Scratch to control electronics via everyones favourite hackable computer the Raspberry Pi. We hope youve enjoyed learning Scratch; its a great tool to understand coding but its also great fun to learn. LXF

    Fig 1.9 Hit the Make a Variable button to create a variable.

    Fig 1.8 As you can see, there are two variables in our game: guesses and score.

    You can share your projects online across many platforms via http://scratch.mit.edu.

    Quicktip

  • 88 LXF180 February 2014 www.linuxformat.com

    Squeak

    Our expert

    Juliet Kemp was thrown by all the graphics at first, but was won over by the ease of producing working code.

    part has a rather out-of-date look, and is not really maintained any more. Morphic does all the same stuff with more on top, and looks better too, so its best just to go ahead and use that. Morphic is also available in other languages (eg Self), and is designed to be good for creating GUIs.

    To get started with some actual code, click on the project window background, and youll get a World menu. Choose Workspace from this to get a workspace window (where youll create the code) and Transcript to get a transcript window (where code results and errors will be output). Alternatively, you can click on the Tools tab at the far right, and drag a Workspace and Transcript window out from there.

    In the Workspace window, type:Transcript show: Hello World.

    You must use single, not double, quotes. (Double quotes in Squeak denote comments, and you need one at each end of a comment.) Select, right-click and choose Do It to run it, and youll see Hello World appear in the transcript window. The full stop at the end, which concludes a code statement, isnt necessary with a single line, but it is with multi-line code so you might as well use it straight away.

    Alternatively, theres an even quicker option: type this into the Workspace:Hello World

    Then highlight it, right-click, and choose print. Hello World will appear directly in the Workspace print also acts as an evaluator. Try typing in a mathematical expression, e.g. 65*30, highlight and print, to see the result appear in the Workspace.

    Squeak grammarBeing able to evaluate little snippets of code can be handy, but the Transcript show line demonstrates Squeak grammar a bit better. Squeak is an entirely object-oriented language; everything in Squeak is an object. So the basic Squeak code sentence is: object message.. Here, Transcript is the object (the Transcript window), and show: Hello World is the message. Specifically, the message in this case consists of a method (show) and an argument, but the details will vary depending on what youre doing.

    Since Squeak is so good at graphics, we can also easily create a Hello World button:button := SimpleButtonMorph new. button color: Color green. button label: Say hello. button addMouseUpActionWith: Transcript show: Hello World .. button openInWorld.

    This creates a new SimpleButtonMorph object, button, colours it green, and assigns it a label. The button called addMouseUpActionWith does roughly what it says: adds an action to perform when a MouseUp is detected (ie after a user has finished clicking on the button, which is the norm for

    Squeak, a free version of Smalltalk with its own VM, is highly portable, very object-oriented and provides an interestingly different coding environment for Juliet Kemp this month.

    Squeak is an open-source implementation of Smalltalk, a language thats itself over 35 years old, and arguably the first truly object-oriented language. Everything in Smalltalk is an object and everything is done by sending messages to objects. Squeak provides a highly self-reflective development environment: everything in your Squeak project is also written in Smalltalk, and can be examined, including graphics objects and the Squeak VM itself. Its particularly used in educational contexts, although it also shows up in many other projects. Read on to try it out with an implementation of a short game.

    Getting startedYou can install Squeak either via your packaging system (squeak-vm on Debian/Ubuntu), or as a single ZIP file from the website. If you download via your packaging system, youll also have to download a Squeak image from the Squeak website. Alternatively, if you use the ZIP website download, just unzip the SH file, cd into the unzipped directory and type ./squeak.sh.

    When you fire up Squeak, you get a big window with lots of little windows containing some basic Squeak info. The first thing to do is to create a new project. Choose Projects > New Project > New MorphicProject and youll get a new project, which is a Squeak window with all its sub-windows and various tabs dotted around the edges (See The Squeak Environment, p89 for a run-down on the various parts of a Squeak project window).

    Although Smalltalk does include an option for MVC projects (the MVC toolkit from Smalltalk-80), the MVC-alone

    Workspace and Transcript windows with that all-important first program.

    Squeak: An intro

  • www.tuxradar.com February 2014 LXF180 89

    Squeak

    Adding the first class. Note the red warning message at the bottom I havent added a comment yet. (Bad coder, no biscuit.)

    see a red message pop up at the bottom warning you that theres no comment on the class. To add a brief comment, click on the ? button between the instance and class buttons in the System Browser pane, write a comment, and choose Accept again.

    Next, we can write some actual methods. The first one we want is an initialise method, which sets up a new blank cell. Select TTTCell in the class list, then all in the protocols list next to it. Youll get a template method in the editing pane below. Replace that with this code:initialize super initialize. self label: . self borderWidth: 5. self width: 50. self height: 50. color := Color paleBlue. self useSquareCorners.

    This method starts out by calling the superclass initialize method, which will set any sensible defaults that the superclass has. We then set the cell label (to the empty string again, thats two single quotes, not a double quote), its border, size, colour, and so on. Most of this is fairly self-explanatory. Effectively, each line is a message sent to the objects self.

    You can try this out for yourself by opening a Workspace and entering this:t := TTTCell new. t openInWorld.

    click actions). The action is our Transcript line from earlier. However, this time the string needs double quotes (but these are two single quotes, *not* a double quote character). Finally, openInWorld shows the button in the Squeak World ie within the Squeak window.

    Select the code and do it and youll see the button appear.You could also get the button to change its label:button addMouseUpActionWith: self label: Hello World! ..

    Writing a programLets head on to something a bit more substantial. Were going to write a little program to play Tic-Tac-Toe (aka noughts and crosses). Well create a 3x3 game board, which will add a 0 or an X when you click on it. There will be a class for the board, and a class for the cells, so well find out how Squeak uses classes.

    First, create a new Squeak project so you have a clean area to work with. Now, were going to add a class category, to store our classes in. Go to Tools > System Browser, and youll see a browser which shows you all the Squeak classes. Right-click on the left-hand pane, which shows all the categories, and choose Add item. Give it the name Tic-Tac-Toe, and hit Accept. Youll see the new category appear in the list, though it doesnt have any members yet.

    What it does have is a template in the bottom pane, which is the class editing pane. This template is for a method which sends a subclass message to the Object class, with the parameter #NameOfSubclass so the Object class will create a new subclass of itself, with the specified name. (You could also describe this as calling the subclass method of the Object class; but in Smalltalk we talk about objects and messages, not methods.)

    Well edit this to create our game cell class. Edit it to look like this:SimpleButtonMorph subclass: #TTTCell instanceVariableNames: mouseAction classVariableNames: poolDictionaries: category: Tic-Tac-Toe

    So now instead of creating a subclass of Object, were creating a subclass of SimpleButtonMorph (a basic clickable button) called TTTCell. Were also adding a mouseAction instance variable (a variable which exists in each instance of the class) to the class, so we can act on the cell depending on what the mouse does.

    To save these changes, right-click and click Accept. Youll

    The green button has just been resized with the yellow button in the halo; and the Objects box is ready to provide objects.

    The Squeak environmentIf youre used to command-line programming and a standard editor, this is all going to look a bit unusual. (Which is to say: it baffled me for a bit.)

    First, a note on mice. Squeak assumes that you have three mouse buttons. As not all mice do, how the menus are mapped varies between systems. The left mouse button is consistently used for selecting things, the right mouse button will usually bring up an options menu, and middle button (or alt-left, or ctrl-left) will bring up the halo of buttons around an object. However, these last two (also referred to as yellow and blue) are sometimes swapped; so experiment to work out which is which with your install.

    When you open a Squeak project, there are several tabs around the screen. Objects gives you

    objects (like buttons and arrows) that you can drag into the screen; Tools gives you useful objects; Widgets and Supplies are further useful subsets of Objects. Any of them can be dragged onto the screen to instantiate them. You can then middle-click or right-click to bring up various options. Right-click and inspect or explore will show you information about an object, with a code window at the bottom where you can try out code. This tutorial will focus on coding using the System Browser, which enables you to add classes and code in a way that will be familiar if you have any other coding experience; but its possible to do a lot using the Morphic graphics system. (See the Squeak for Kids! on p91) Its certainly worth playing around with it a bit to see what you can do with it.

    Squeak is the implementation and the environment, and Smalltalk is the language, although theres some overlap in customary usage, which youll notice is reflected in the rest of the tutorial.

    Quicktip

  • 90 LXF180 February 2014 www.linuxformat.com

    Squeak

    Highlight it and choose Do It to generate a new cell. You could also just type TTTCell new, choose Inspect It, then type self openInWorld. in the pane at the bottom of the inspection window, then choose Do It on that. The inspection window also allows you to check out various other aspects of the object, so its good to play around with it a bit.

    Game boardOur cell doesnt do anything yet, but well leave it for now and move onto the game board. To create our game board class, click on the Tic-Tac-Toe class category again, and youll get another of those subclass templates. This time, edit it to look like this:BorderedMorph subclass: #TTTBoard instanceVariableNames: classVariableNames: poolDictionaries: category: Tic-Tac-Toe

    A BorderedMorph is just that, a morph (graphics object) which has a border. Accept this method, then create an initialise method:initialize | singleCell width height n | super initialize. n := self cellsPerSide. singleCell := TTTCell new. width := singleCell width. height := singleCell height. self bounds: (10@10 extent: ((width*n) @(height*n)) + (2 * self borderWidth)). cellGrid := Matrix new: n tabulate: [ :i :j | self newCellAt: i at: j ].

    This time, when you choose accept, Squeak will complain. The first thing it complains about is cellsPerSide; confirm that and we will write it in a moment. The second thing is cellGrid; choose Declare Instance for this, as it will be an instance variable. Finally, newCellAt again, confirm this and well write it shortly.

    The first line of this method declares four temporary variables. Its good practice to declare variables that only exist within a method as temporary, to avoid cluttering up the Squeak project with unnecessary global variables, and reduce the likelihood of accidentally overwriting variables.

    We then define all of these temporary variables. We set the bounds of the gameboard (this looks long but just works out the expected size of the board based on cell size). Finally, we create a matrix of cells with the correct number of cells.

    The most complicated line, though, is that final one. cellGrid (which, remember, weve now defined as an instance variable, so its accessible throughout the class) is where we will store the grid of cells. We generate this with Matrix>>new:tabulate:. This is the new method of the Matrix class. The Class>>method notation is used when talking about Squeak code, although you dont use it in the code itself. Whats that tabulate doing there, though? In Squeak, you know how many arguments a method takes by how many colons it has in its name. Here, two colons mean two arguments. The first one gives the rows and columns of the Matrix, and the second specifies what object is at each (i, j)th position of the matrix. This last uses the newCellAt message, so each (i, j)th cell consists of whatever is returned by newCellAt: i at: j.

    (With thanks to the authors of the excellent Squeak By Example for parts of this and a couple of other methods used in this tutorial.)

    More methodsAll of that means that we need some more methods. Click the class name and youll get another method template. We have two methods to write:cellsPerSide Number of cells on each side of the board ^3newCellAt: i at: j Create a cell at position i,j and add it to the screen | cell origin | cell := TTTCell new. origin := self innerBounds origin. self addMorph: cell. cell position: i - 1 * cell width @ (j - 1 * cell height) + origin. cell mouseAction: [self playMove: i at: j]. ^cell

    cellsPerSide just returns 3 (the ^ operator means return this value). newCellAt does what it says in the comment. It creates a new TTTCell, and defines origin, which is the origin of the TTTBoards inside boundary. (If you think of the board as a grid, this is the top left inner corner. This method is

    The TTTCell is up in the top left corner. You can also see its inspector further down, and the System Browser behind that.

    Saving and quittingThere seem to be several different save options, but I could only make one of them work. If you click Projects > Save Project, it seemed in all my trials to hang. Clicking the Squeak tab and Save, or the Squeak menu and Save, or the Squeak menu, Quit, and answering Yes to save, all seemed to work fine; when I reopened Squeak, my code was still there.

    You can also save your project as a specific image, but the squeak.sh script has the startup image hard-coded, so youll need to edit that, write your own script, or use this code to start Squeak:exec Contents/Linux-i686/bin/squeak my.image

    If you do lose some code, it should all be saved under Recover Changes when you start up again, as Squeak logs everything as it goes along. Go to Extras > Recover Changes, highlight the changes you want, then right-click and choose filein selections.

    You can use the System Browser to examine any of the Squeak classes. Right-click and choose find on the top left window to search for a class, and use the ? button to see its documentation.

    Quicktip

  • www.tuxradar.com February 2014 LXF180 91

    Squeak

    The game in action! You can select it and get the halo around it to move/inspect/etc. You can also see the System Browser with some code underneath.

    inherited from the superclass BoundedMorph. We then calculate and set the cells position by working out how far across the board it is and adding that to the origin to place it on the Squeak window.

    The important part is the next-to-last line. This sets what the cell should do in response to a mouse action; apply the TTTBoard>>playMove:at: method. This is the basic game logic, and well write it in a moment. Finally, we return the newly created cell.

    We now have even more methods to write to make all of this work. TTTBoard>>playMove:at: is the next one:playMove: i at: j (cellGrid at: i at: j) move: player. self switchPlayer.

    If you accept that, though, Squeak will complain that it doesnt know about player. Add it as an instance, and well handle it in a moment; switchPlayer just confirm, and well write that method shortly too. cellGrid is a matrix, so inherits matrix methods; specifically the at:at: method to identify a particular cell in the matrix. Having got that cell, we apply the move method, with the player argument; then switch player.

    Next we need player to hold a value showing which player is currently having their turn, X or O. X always starts, so we just add a line to initialize:initialize super initialize. player := x. rest as before

    We also need switchPlayer:switchPlayer player = x ifTrue: [player := o] ifFalse: [player := x]

    The first line is evaluated to either true or false (Boolean value). If it is true, the ifTrue line is executed, and player is set to O (it is Os turn now). If false, it is set to X. Note that this doesnt do any error checking for you, which means you might want to add something to check that it hasnt been set to anything strange.

    Thats all for the TTTBoard class. However, we still have a couple of TTTCell methods to write and to handle the mouse click events.

    Mouse actionsBack to TTTCell, to handle mouse actions and that move method.mouseAction: aBlock ^ mouseAction := aBlock.mouseUp: anEvent mouseAction value.

    The mouseAction: method is what is called on the cell when it is clicked, from the TTTBoard>>newCellAt:at: method. Its also an instance variable, if you look back at the code used to set up the TTTCell class. The mouseAction: method, then, is just a setter method: and it sets the instance variable mouseAction to the argument passed in. It then returns it. So a Smalltalk setter method is variable:, and the getter method is variable (note: it doesnt have a colon), rather than setVariable and getVariable as in other languages. These methods are called accessor methods and should be placed in the accessing protocol when you are categorising your methods.

    mouseUp: defines what happens when a mouseUp event is detected by the user interface. Here, we send the message

    value to mouseAction. This method was set, in TTTBoard>>newCellAt:at:, as [self playMove: i at: j] (that is, TTTBoard>>playMove: i at: j). The value message tells Squeak to evaluate that expression, so that playMove:at: will be executed.

    TTTBoard>>playMove calls TTTCell>>move, so thats the final method we need to write: move: player self label: player. self height: 50. self width: 50.

    This sets the player argument as the cells label. It then resizes the cell, since setting the label resizes the cell to the size of the label, which we dont want. For more portability and better maintenance, it would be good to have height and width as instance variables.

    The game is finished! Now run it and see what happens. As ever, theres plenty more you could do to improve this game, so get stuck in and see what else you can do. Squeak was a little bit of a departure for me, as its heavily graphics-oriented and my inclination is towards the command line. But its a great language and a great environment once you get the hang of it. It could also be interesting to try using more of the drag-and-drop graphics widgets to construct code. If youd like to investigate further, Squeak By Example is a great book providing a thorough introduction to Squeak, and is available free online. LXF

    Squeak... For kids!One appealing aspect of Squeak is that its very accessible for kids. Even kids who arent yet ready to try coding with Smalltalk can draw on the Squeak surface and drag widgets and scripted commands around.

    This sort of coding allows scripts to be created and joined without the user having to type, which gives young children more freedom to begin experimenting with programming.

    If youre interested in this, the Etoys system (www.squeakland.org), which is aimed specifically at children and used heavily in the One Laptop Per Child project, is part of Squeak. A similar option, based on Squeak/Smalltalk and developed by MIT, Scratch, which can be used online. Squeak, Etoys, and Scratch all provide a great opportunity for kids to start hacking on software, not just consuming it.

    To arrange your method neatly, you can right-click, click more, then click prettyprint. You can also shift-right-click to get straight to the more menu.

    Quicktip

  • #1 for Free Software

    Win!

    Got a question about open source? Whatever your level, email it to [email protected] for a solution.

    1 Ubuntu One annoyance2 Removing duplicate files3 Canon printer problems

    4 PinguyOS problems5 MEI module errors

    Seeking a recovery ISO

    1 Ubuntu 1, User 0

    QEvery time I boot up, I get the pop-up trying to entice me to sign up for Ubuntu One. I have ignored it for a while but I am becoming annoyed by it. Can you please tell me how to eradicate it?catgateFrom the forums

    A If you want to completely remove it from your system, use the following terminal commands:killall ubuntuone-login ubuntuone-preferences ubuntuone-syncdaemon

    This kills all running Ubuntu One processes, which is necessary before you run the following steps to remove its files, otherwise it may recreate them when it exits.sudo rm -rf ~/.local/share/ubuntuonerm -rf ~/.cache/ubuntuone

    rm -rf ~/.config/ubuntuonemv ~/Ubuntu\ One/ ~/UbuntuOne_old/

    The last line moves your Ubuntu One folder, but if you have no content in it you could just as easily delete it. Finally, you uninstall all Ubuntu One packages and their configuration files withsudo apt-get remove --purge ubuntuone-*

    You may need to escape the wildcard in that command, depending on your shell and its configuration. It should be fine with a stock Bash setup, but if you get an error along the lines of could not find ubuntuone-* in your terminal, precede the wildcard with a backslash to stop the shell trying to interpret it.sudo apt-get remove --purge ubuntuone-\*

    2 Finding duplicates

    Q I am looking for a utility to locate and remove duplicate files.Alex01UKFrom the forums

    A The program you need is called fdupes (http://netdial.caribe.net/~adrian2/fdupes.html). This command compares all the files in the directories it is given and outputs a list of files that are duplicates of one another. It first of all checks file sizes and then, when it finds files of the same size, compares checksums of the files. Getting the size of a file is instant, calculating its checksum is not, so the scan will take longer if you have a number of large, equally sized files. The filenames are not considered, only the content, which makes for a thorough scan. The normal invocation is

    Enter our competition

    Linux Format is the biggest and best magazine about Linux and free software.

    We did a rough word count of LXF173 and it contained 67,659 words. About as much as Heart of Darkness and Animal Farm combined, but with considerably more Linux, coding and free software!

    Thats many more than our competitors, and thats how we know that were the biggest. As for the best, well thats a subjective claim, but its one were happy to stand by.

    if ($letter == winner) get $books

    Because were nice chaps as well as Linux gurus, and because our offices have very little storage space, were giving one lucky reader each issue the chance to win some of the books that get sent to us for review. Theyre mostly reference books that will give your shelves an air of computational gravitas. For a chance to win, email your question to [email protected], or post it to www.linuxformat.com/forums to seek help from our lively community of readers. See page 94 for our star question.

    Get your questions answered and exploit our generosity.

    This month we answer questions on:

    Ubuntu really want you to sign up for Ubuntu One, but it is possible to stop them asking you.

    92 LXF180 February 2014 www.linuxformat.com

  • Part of Linuxs safety comes from running as a user without administrative privileges. However,

    there are times when you need those privileges, usually for administrative purposes, so you need to switch to the superuser (or root). This is traditionally done with the su (switch user) command, but that gives full root access, allowing the user to do anything that root could for as long as they are logged in. It also requires them to have the root password. Wouldnt it be safer if users were allowed to run as root only for the commands they need?

    This is what sudo does. The configuration

    file, /etc/sudoers, contains a list of commands that each user is allowed to execute with root privileges. Runningsudo somecommand

    prompts the user for their password and runs the command. It is the users password that sudo needs, not the root password, you dont need to divulge that to anyone. This, combined with the fact that only specified commands can be run, greatly improves security. This is the way Ubuntu works, which is why you dont need a root password with it, but sudo is worth using on all distros.

    A typical entry in /etc/sudoers may look something like:nelz ALL = PASSWD: /bin/mount, /bin/umount

    This lets the user nelz run mount or umount on all hosts. You can remove the need for them to enter a password, like thisnelz ALL = NOPASSWD: /bin/mount, /bin/umount

    Use this with care! You can define aliases for groups of users or commands, to make administering a complex setup more simple. You should not edit /etc/sudoers directly, use the visudo command, as root, to edit it. Contrary to the name, this does not necessarily use vi to edit the file, it uses whatever youve set in the $EDITOR environment variable. visudo checks the syntax of your edits before writing them to /etc/sudoers, saving you the shame of getting locked out by a typo.

    expect, as fdupes does not process files in alphabetical order but so-called natural order, the order the files appear in on the disk, which is more efficient but less intuitive. Alternatively, you could redirect the output to a file and then use something such as awk to produce a list of files to remove, after you have checked the list.

    3 A-verse to printing

    QDo people find it comical, that Canon and Canonical, make it so hard for us, tedious and arduous, to work together 12.04LTS and Pixma 2550?Tom Healy

    AThank you for the poetic and clearly heartfelt plea. I tried to reply in rhyme but, much like your all-in-one device, it would not scan!

    Anyway, to get this printer working as a printer, you need to install the drivers from the Canon website at http://bit.ly/19gO7Yv

    On that page, select the Software option, pick Linux as your OS and hit Search. This will give you several options you want the two Debian package archives, one called MG2500 series IJ Printer Driver and one called MG2500 series ScanGear MP. Save these to your Downloads directory then open a terminal (Ctrl+Alt+T) and runcd Downloadstar xf cnijfilter-mg2500series-4.00-1-deb.tar.gztar xf scangearmp-mg2500series-2.20-1-deb.tar.gz

    to unpack the two archives. Each is unpacked into a directory containing software packages and an install script, so install each set of drivers withcd cnijfilter-mg2500series-4.00-1-deb./installcd ../scangearmp-mg2500series-2.20-1-deb./install

    The install script uses sudo to put files in

    system directories, so you will be prompted for your password. This is a very long-winded way of installing a couple of .deb packages, after scrolling through a lengthy licence agreement just to be able to use the printer you paid good money for. Canon is one of those companies that doesnt get open source and insist on making extra work for you and themselves by working against the system rather than with it, because thats the Windows way.

    Once your drivers are installed, you can set up your printer in the usual way, by going to the Printers section of System Settings. The scanner should be auto-detected the next time you use a scanning application, either through Simple Scan or the scanner options in Gimp. Because the drivers were not installed from a repository, they will not be covered by the update manager, so it would be worth bookmarking the driver download page and checking for updates from time to time.

    4 Silent failure

    QWhat do I do when the recommended PinguyOS from the coverdisc fails at the end of a clean install on a Lenovo X61, and fails to report a fault? Or how do I install birdfont (HotPicks LXF175) from the download into Xubuntu (thats what I hoped PinguyOS would provide access to)? Simply opening the download gives 21 files (birdfont, birdfont/export, icons, etc). The README is incomprehensible, instructions in type this here mode would be appreciated.D Heckle

    A It is not good to fail without showing the error, but it is almost certainly logged somewhere. If you press Ctrl+Alt+F1 from the PinguyOS live desktop, you will switch to a virtual console, already logged in as the guest user. From here, you can

    fdupes -r directory1 directory2 ...The output is filenames, one per line, with a

    blank line separating each group of duplicates, something likefileX1fileX2fileY1fileY2fileY3

    If no duplicates are found, it returns to a command prompt without giving any output. You can also have it output all copies of a file on a single line, separated by spaces, by adding the -1 or --sameline argument.fileX1 fileX2fileY1 fileY2 fileY3

    Deletion is also possible, but be careful when expecting a program to make intelligent decisions about which version of a file should be kept. If you add the -d or --delete option, you will be prompted which to keep, but if you combine this with --noprompt, the first file in each set of duplicates will be kept and the rest deleted. This may not give the results you

    A quick reference to...

    Terminals and superusers

    We often give a solution as commands to type in a terminal. While it is usually possible to do the same with a distros graphical tools, the differences between these mean that such solutions are very specific. The terminal commands are more flexible and, most importantly, can be used with all distributions.

    System configuration commands often have to be run as the superuser, often called root. There are two main ways of doing this, depending on your distro. Many, especially Ubuntu and its derivatives, prefix the command with sudo, which asks for the user password and sets up root privileges for the duration of the command only. Other distros use su, which requires the root password and gives full root access until you type logout. If your distro uses su, run this once and then run any given commands without the preceding sudo.

    sudo

    Answers

    www.tuxradar.com February 2014 LXF180 93

    Answers

  • StarQuestion

    libraries or programs needed to use that software, the -dev package contains extra files needed only when compiling software that uses it, which is why -dev packages are not installed by default. You may have to repeat this process several times, as configure reports only the first missing package it finds; install that and it finds the next, and so on. This is the most reliable method, if one of the least user-friendly. Once configure has completed, rundoitsudo ./install

    The first command builds the software, the second installs it (which is why it needs sudo).

    5 Kernel spam

    Q I recently swapped to Sabayon as a change from Fedora, which I had been using for quite a while. An

    issue arose that I always got in Fedora, which was the MEI module of the kernel spamming dmesg massively with the following error:[ 4948.024031] mei_me 0000:00:03.0: reset: connect/disconnect timeout.[ 4948.024036] mei_me 0000:00:03.0: unexpected reset: dev_state = RESETTING

    In Fedora, this was an easy fix blacklist the MEI module. In Sabayon, its a bit harder, as the MEI component is compiled into the kernel. I could recompile the kernel, but I would have to do this after every update, which at the current four-week rate is not something I wish to do. I do have a fix that locates the relevant part and unbinds it:echo $(find /sys/bus/pci/drivers/mei_me/ -type l|sed s#^.*/##) >/sys/bus/pci/drivers/mei_me/unbind

    It took a while to find this solution and, as long as I remember to run it, it works fine but I cant get it to run at boot on Sabayon. A friend has told me of Cron, that allows things to run at boot. If I could fix the error, with a BIOS tweak or something, this would be much better. I have a Dell Optiplex 755 machine on the latest BIOS release.Neil Williams.

    AThis is a known issue, usually worked around by blacklisting the module. However, at some point the default kernel setting for this switched from a module to built-in. As you have discovered, this defeats the blacklisting approach. As you say, recompiling the kernel is an option, in which case you could disable the option entirely to avoid the need to blacklist the module. This

    Looking for extundelete

    QWell, it has finally happened. I have gone and accidentally deleted a bunch of files from my home account on the separate /home hard disk, which uses ext3. So far, I have been able to refrain from placing new files on /home.

    I know that there is a utility called extundelete, which can recover (some) files from an ext3 partition. What I have not been able to find so far is some sort of recovery ISO built around this and similar tools that can be burned to CD/DVD. Do you know of such an ISO and from where it can be downloaded ?Stuart

    AFirst, the bad news: you have almost certainly written to your home directory. Simply logging in as you causes files to be written or updated, running a desktop even more so. However, if you have plenty of free space, you may still be able to

    This months winner is Stuart. Get in touch with us to claim your glittering prize!Winner!

    recover most, if not all, of your files. My favourite rescue disc is System Rescue Cd which, as it happens, I have booted right now on a computer with a damaged hard drive. It does, indeed, have extundelete and you can download it from www.sysresccd.org. If you have Linux Format 178, you already have System Rescue Cd it is on the cover DVD and can be booted directly from there.

    That CD also contains ext3grep, which performs a similar task, and photorec, which is part of the testdisk (www.cgsecurity.org/wiki/TestDisk) suite of tools. The name indicates photorecs history, but it is able to recover all sorts of files.

    These programs will work on an unmounted partition or a backup copy. The latter is the safest option, provided you have sufficient free space on another partition or disk to store a file the size of your /home partition. It has to hold the size of the partition, not just the files it contains. Make sure the /home partition is

    unmounted first and then back it up with the dd command:dd if=/dev/sdaN of=/media/external/home.img bs=4M

    where sdaN is the partition containing /home. Now you can remount /home and continue to use your system while running extundelete on the backup copy with something like:extundelete /media/external/home.img

    Behind the PinguyOS desktop is a consle where you can see what is really going on.

    inspect the system log files. The error is probably written to /var/log/syslog, so typeless /var/log/syslog

    and press Shift+ g to go to the end of the file. There, you should see the error, and once you have that you can search for a solution. If the error is not written to that file, try runningls -lrt /var/log

    to show all the files in /var/log in time order. The last file shown is the most recently written to, and should contain what you need. If the error message is too many open files, this has been reported by a few people, but does not affect most. There is a fix, which is included on this months DVD. Run the script on the DVD while in the live environment (youll need to copy it to a USB stick unless you have more than one DVD drive) withsudo bash /path/to/dvd/Answers/ubiquity_apt-cache_autogc.sh

    The birdfont file on DVD175 contains the source code for the program, which must be compiled to use it. Open a terminal and typetar xf birdfont-0.21.tar.gzcd birdfont-0.21.tar.gz./configure

    This unpacks the archive and runs the configure script, which checks that you have all dependencies installed. If it complains about a missing package, install it from your package manager. If the package appears to be installed already, install the corresponding -dev package. For example, if it complains about missing libvala and you already have libvala installed, you also need libvala-dev. The difference is that the first package contains the

    Extundelete does what it says, as long as you havent written to the drive.

    Answers

    94 LXF180 February 2014 www.linuxformat.com

    Answers

  • Help us to help you

    I have a kernel, why would I want to compile a new one?Kernels supplied with distros contain support for a wide range of hardware, but not everything. You may need to add support for something you own. Or you may want to remove support for all the hardware you do not have. Building your kernel from the kernel.org sources will usually give you a later version, which may be important.

    Where do I get kernel sources?You can download the standard kernel sources from www.kernel.org, or find them on each months coverdisc. Most distros use patched sources, and some of their tools can rely on these patches. You can install a source package to match your current kernel using your distros usual package management tools. Look for a package named something

    like kernel-source or linux-sources. Compatible versions are usually available from your distros testing repository.

    Which should I use?The sources patched for your distro are usually best. If you want to apply your own patches, or use the latest kernel, it may be better to use the kernel.org sources.

    How do I compile and install a kernel?To install from a kernel.org tarball, download it and do the following as root:cd /usr/srctar xjf /path/to/downloaded/linux-

    x-y-z.bz2rm -f linuxln -s linux-x.y.z linux

    where x.y.z is the kernel version, say 2.6.28. If you install from a distro package, these steps should

    be taken care of for you. Whichever method you used, now docd /usr/src/linuxmake menuconfig

    to start the configuration menu. Most options should have sensible defaults, but if you wanted to stick with the default, you wouldnt be doing this. So, go through the options and set them to your needs. If you need a specific option, the 2.6 kernel menus have a search option. Press / and type a search string; you will be shown which options cover this and where to set them. If you prefer a point-and-click interface, use make xconfig. When you have finished, exit the menu, accept the option to save settings, and its time to compile and install.

    How do I do that?If you have a separate /boot partition, make sure its mounted, then domakemake modules_install

    make installor combine the three steps asmake modules_install install

    The first step compiles the kernel and modules, the second installs the modules, the third installs the kernel to /boot. The kernel is also symlinked to /boot/vmlinuz and your previous kernel is symlinked to /boot/vmlinuz.old. If you have options for these two kernels in your bootloader menu, you will always be able to choose between your new kernel and the previous one, which is essential if your new kernel fails to boot. The install command also backs up your kernel configuration to /boot.

    Is that all there is to it?

    If you use the Grub bootloader, yes. If you use LILO, you need to run /sbin/lilo, even though you havent changed the name of the kernel, because LILO uses the position of the file on the disk, not its name, so it would still boot the previous kernel otherwise.

    instructions they supply didnt work, so I had a look on the web, and found instructions on how to set up CUPS on the Mint forum. I followed the instructions and came up with an error that /usr/lib/cups/filter/rastertospl was missing. I got that from the Samsung site and installed. When I try to print it does nothing and there are no error messages. I have attached the troubleshoot text, do you have any suggestions of what is wrong and how to fix it?James Mess

    ALooking at the install script for the Samsung printers, it appears to install rastertospl to the correct location. Did you run the install script as root or with sudo? If you did not, it would not have been able to install the files, because a normal user does not have permission to write to /usr/lib. Even worse, if you ran the script by clicking on an icon, it would not have been able to tell you this. This is one of the drawbacks of using proprietary drivers you are reliant on their install system, which in this case does not check it is being run with sufficient privileges. To install as root, open a terminal and run:tar xf ULD_Linux_V1.00.06.tar.gzcd uldsudo ./install.sh

    An alternative would be to try the Splix drivers, a set of third-party, open source drivers for Samsung printers. Your model is not listed, but others in the CPL-300 series are shown as working. SPL is Samsung Printer Language, a

    may mean you need to do it on each update, at least until the default kernel configuration is switched back to building this as a module. It may be fixed by the next kernel update, either in the module setting or even the fault causing the error messages themselves.

    There are a couple of other options on some systems you can disable the Management Engine Interface in your BIOS. This could be well hidden, you may need to turn on Management Extensions first. Some systems let you go straight to the Management Extension BIOS by pressing Ctrl+P at boot, skipping the standard BIOS screens.

    You can also execute the command you gave at each boot, but cron is not the correct tool for this. Cron executes tasks at set times, whereas you want it run once, when you boot, which is a job for the init system. Sabayon uses OpenRC for its init system, and this executes any scripts in /etc/local.d that end with .start when it boots (and .stop scripts when it shuts down). Put that one line in a file in that directory, say /etc/local.d/mei.start, and make it executable to run it each time you boot. There is a README file in /etc/local.d that explains the process.

    6 Reluctant printer

    Q I use Mint 13 but will be upgrading to 15. I have a problem setting up my new printer, a Samsung CPL-360. It was bought as Samsung say on their website they have drivers. The installation

    We receive several questions each month that we are unable to answer, because they give insufficient detail about the problem. In order to give the best answers to your questions, we need to know as much as possible.

    If you get an error message, please tell us the exact message and precisely what you did to invoke it. If you have a hardware problem, let us know about the hardware. If Linux is already running, you can use the Hardinfo program (http://hardinfo.berlios.de) that gives a full report on your hardware and system as an HTML file you can send us.

    Alternatively, the output from lshw is just as useful (http://ezix.org/project/wiki/HardwareLiSter). One or both of these should be in your distros repositories. If you are unwilling, or unable, to install these, run the following commands in a root terminal and attach the system.txt file to your email. This will still be a great help in diagnosing your problem.

    uname -a >system.txtlspci >>system.txtlspci -vv >>system.txt

    Frequently asked questions

    common language for their printers, so if it works for one printer in a line it ought to work for others. Splix is in most distros repositories, so you should be able to install it in the standard way, either from the graphical package manager or from a terminal, withsudo apt-get install splix

    It is not good to have two sets of drivers for the same printer installed, so if splix does not work, uninstall it before trying again with the Samsung package. Incidentally, CUPS sends its error messages to /var/log/cups/error_log, so check there if you have problems. LXF

    Compiling a kernel

    Answers

    www.tuxradar.com February 2014 LXF180 95

    Answers

  • 96 LXF180 February 2014 www.linuxformat.com

    Distros, apps, games, podcasts, miscellany and more

    On the disc

    OpenSUSE 13.1Do we have too many distros? Are all the respins of Ubuntu really necessary? Taking a distro, changing the desktop and repackaging the ISO doesnt really count as a distro. Whats wrong with releasing a theme or meta-package that can be installed on the base distro to give the new appearance? A new distro should bring something new, whether its a package manager, set of configuration tools or a different philosophy to the distro from which its derived.

    Not that deriving from another distro is inherently bad, Ubuntu has come a long way since first starting out as repackaged Debian Testing. SUSE has come even further since its original Slackware derivation. New is good when it offers a real choice or opportunity for development, not so good when its just a paint job.

    Would you be more likely to try an enhancement of whatever distro you like, if it was supplied as a package to be installed rather than having to be reinstalled? Of course, such an enhancement may not make it onto Distrowatch or other news pages, do we need a way for these to be shown off distro-look.org anyone? Or are you happy with the way things are?

    The best of the internet, crammed into a massive 4GB of quality DVD.

    Linux distribution

    Linux distribution

    We have to be thankful to the kind folks at openSUSE for timing their release to fit exactly between Ubuntu 13.10 last month and Fedora 20 next month. This means that we can bring you a major distro each month without them competing for the available space on the disc. This new

    release, 13.1, comes as two live disc variants, one using KDE 4.11 and one with Gnome 3.10. OpenSUSE is one of the few distros to still use KDE as its main desktop. It wouldnt be fair for us to tell you which to use, so weve supplied both, select the one you want from the boot menu.

    For a while, its seemed that every new distro has been derived from Ubuntu or Debian, but thats beginning to change. There are an increasing number of distros that are based on Arch Linux, one of which is Manjaro. This new distro is available with various desktops, but we have included the OpenBox version (KDE and GNOME desktop fans are already catered for with OpenSUSE this month).

    OpenBox is a much overlooked alternative, a window manager that supplies a desktop even faster and lighter than Xfce. Combined with the fast Systemd boot provided by Arch and this distro will be up and running in seconds, and just as fast in general use.

    Defective discsIn the unlikely event of your Linux Format coverdisc being in any way defective, please visit our support site at www.linuxformat.com/dvdsupport for further assistance. If you would prefer to talk to a member of our reader support team, email us at [email protected] or telephone +44 (0) 1225 822743.

    ImportantNOTICE!

    Enhance

    Life doesnt always go to plan, so backups are always a good plan. Clonezilla is one of the best full-disk backup alternatives around, and you can run it direct from this months LXFDVD. Dont wait too long, backup your system and files now!

    Manjaro 0.8.8

  • www.tuxradar.com February 2014 LXF180 97

    New to Linux?Start here

    Are you reading this on a tablet?Download your DVD from www.linuxformat.com

    Extra hot additions Calling all Top Guns Get 20 extra FlightGear aircraft.

    Tutorial codeSqueak and Scratch code and software.

    RoundupWe assess them, now setup your hosted sharing service.

    From the magazine

    What is Linux? How do I install it? Is there an equivalent of MS Office? Whats this command line all about? How do I install software?

    Open Index.html on the disc to find out

    FlightGearA very sophisticated and open flight simulator, with several extra aircraft for you.

    AlienArenaCombing some of the best things you loved about Quake 3 Arena (the other one Un-something).

    BleachBitClean up caches and help preserve your privacy cheaper than a trip to Rekall or a ticket to Mars.

    FreeMindThe popular mind-mapping suite written in Java.

    MuseScoreUnleash your Bach inside you. Create, play and print beautiful sheet music.

    NightingaleGet support for a wide range of audio formats with this multi-platform graphical audio player

    PandocThe self-claimed Swiss army knife of document markup converters: from EPUB to XML.

    PyCharmThe smart coders Python IDE with unique code assistance.

    TrueCryptUse on-the-fly-encrypted data storage (just dont ask who developed it).

    TupiA 2D animation design and authoring tool for digital artists of all ages.

    NixNoteA Linux client for Evernote.

    And more!System toolsEssentialsCheckinstall Install tarballs with your package manager.

    GNU Core Utils The basic utilities that should exist on every operating system.

    Hardinfo A system benchmarking tool.

    Kernel The source code to the latest kernel release.

    Memtest86+ Check your RAM for faults or errors.

    Plop A simple boot manager to start operating systems.

    RaWrite Create bootable floppy disks in Windows.

    SBM An OS-independent boot manager with an easy-to-use interface.

    WvDial Connect to the internet with a dial-up modem.

    Reading matterBookshelfThe Cathedral and the Bazaar Eric S Raymonds classic text explaining the advantages of open development.

    Intro to Linux A beginners guide.

    Linux Kernel in a Nutshell An introduction to the kernel written by master-hacker Greg Kroah-Hartman.

    Debian Administrators Handbook An essential guide for sysadmins.

    Linux Dictionary The A-Z of everything to do with Linux.

    Dive Into Python A masterclass in this popular language.

    Bourne Shell Scripting Guide Get started with shell scripting.

    Advance Bash Scripting Guide With more for power users.

    System Administrators Guide The basics of running your system.

    TuxRadar

    PodcastsStay tuned... Season 6 coming soonNew team, new podcast The new season of the TuxRadar podcast will be launching soon. A freshly regenerated team will be taking the reins like a gaggle of Time Lords, taking you on a journey through all of GNU/Linux and free and open source software.

    Expect old favourites, brand new features and plenty of surprises when the TuxRadar podcast returns. Keep an eye on www.tuxradar.com for news on when you can expect the new episode.

  • 98 LXF180 February 2014 www.linuxformat.com

    #1 for Free Software

    Contents of future issues subject to change we might be creating Raspberry Pi-controlled turret guns.

    Exploring GCC The legacy and future of GCC: What can we expect from the GNU Compiler Collection?

    The best VoIP toolsTested: The top 5 chat tools for talking to friends and family across the globe.

    Free Android from Google Do what you want with your Android device not want Google wants you to do.

    Do more with your Raspberry Pi. Well show you how you can become a Pi pro with some brilliant tips and expert tutorials.

    We are committed to only using magazine paper which is derived from well-managed, certified forestry and chlorine-free manufacture. Future Publishing and its paper suppliers have been independently certified in accordance with the rules of the FSC (Forest Stewardship Council).

    Future produces high-quality multimedia products which reach our audiences online, on mobile and in print. Future attracts over 50 million consumers to

    Technology, Entertainment, Music, Creative and Sports & Auto. We export and license our publications to 89 countries around the world.

    Future plc is a public company quoted on the London Stock Exchange

    www.futureplc.com

    Chief executive Mark Wood Non-executive chairman Peter Allen

    Graham Harding

    LXF181 will be on sale Tuesday 4 February 2014

    Future Publishing Ltd, 30 Monmouth Street, Bath BA1 2BW Tel 01225 442244 Email [email protected]

    21,784 January December 2012 A member of the Audited Bureau of Circulations.

    EDITORIALEditor Neil Mohr [email protected] editor Matthew [email protected] editor Chris [email protected] editor Efrain Hernandez-Mendoza [email protected] contributors Jono Bacon, Neil Bothwick, Chris Brown, Marco Fioretti, Andrew Gregory, David Hayward, Joe Jordan, Juliet Kemp, Les Pounder, Jem Roberts, Mayank Sharma, Shashank SharmaArt assistance Nick AspellIllustrations Shane Collinge, Simon Middleweek

    ADVERTISING SALESAdvertising sales director Nick Weatherall020 7042 4155 [email protected] sales manager Ricardo Sidoli020 7042 4124 [email protected]

    MANAGERIAL & MARKETINGCampaign manager Sam BookHead of Computing Group Ian Robson UK chief operating officer Mark Wood

    PRODUCTION AND DISTRIBUTION Production co-ordinator Ian Wardle Production manager Mark ConstanceTrade marketing manager Colin Hornby Distributed by Seymour Distribution Ltd, 2 East Poultry Avenue, London EC1A 9PT Tel 020 7429 4000 Overseas distribution by Future Publishing Ltd Tel +44 (0)1225 442244

    LICENSINGLicensing & syndication manager Regina [email protected] Tel +44 (0)1225 732359

    CIRCULATIONInternational account manager Rebecca [email protected]

    SUBSCRIPTIONS & BACK ISSUESUK readers order line 0844 848 2852 General UK enquiries 0844 848 1602 Overseas readers +44 (0)1604 251045Online enquiries www.myfavouritemagazines.co.uk Email [email protected]

    ADDITIONAL MANAGEMENTEditorial director Jim DouglasCreative director Bob AbbottGroup art editor Steve Gotobed

    LINUX is a trademark of Linus Torvalds, GNU/Linux is abbreviated to Linux throughout for brevity. All other trademarks are the property of their respective owners. All the code printed in this magazine is licensed under the GNU GPL v3 or later. See www.gnu.org/copyleft/gpl.html.

    Copyright No part of this publication may be reproduced without written permission from our publisher. We assume all letters sent by email, fax or post are for publication unless otherwise stated, and reserve the right to edit contributions. All contributions to Linux Format are submitted and accepted on the basis of non-exclusive worldwide licence to publish or license others to do so unless otherwise agreed in advance in writing. Linux Format recognises all copyrights in this issue. Where possible, we have acknowledged the copyright holder. Contact us if we havent credited your copyright and we will always correct any oversight. We cannot be held responsible for mistakes or misprints.All DVD demos and reader submissions are supplied to us on the assumption they can be incorporated into a future covermounted DVD, unless stated to the contrary.Disclaimer All tips in this magazine are used at your own risk. We accept no liability for any loss of data or damage to your computer, peripherals or software through the use of any tips or advice.Printed in the UK by William Gibbons. Future Publishing Ltd 2014

    Mastering Raspberry Pi

    Next month

  • 9000

    9001