• No results found

The desktop area enables you to create shortcut icons for commonly used programs and files for easy access. You just need to double-click the icon to start the program, or open the file. By default, only one shortcut icon appears on the desktop—the trash can. You can right-click anywhere on the desktop to create a new folder or file icon.

The LXPanel area is the bar section along the top of the desktop that contains several icons (refer to Figure 2.1). It enables you to place small programs, called applets, on your desktop interface. A lot of applets are available for providing basic system information directly on the LXPanel for you to see; some allow you to quickly launch programs with a single click of the mouse button. The next section digs a little deeper into how the

LXPanel works.

Did You Know?: I Just Want My GUI

Because you can reach the command line via the LXTerminal program, you might want to have your Raspberry Pi boot straight into the GUI. To set this up, follow these steps:

1. At the command prompt, type sudo raspi-config and press the Enter key.

2. In the text-based menu, press the down-arrow key until you reach the Enable boot to Desktop/Scratch menu option; then press the Enter key.

3. When you see the Choose Boot Option window, with the different options for booting, select the Desktop option and then press Tab until you reach the <OK>

option; then press Enter.

4. At the configuration menu, press Tab until you get to the <Finish> option; then press the Enter key.

5. When a new window opens and asks Would you like to reboot now?, press Tab until you reach the <Yes> option and press Enter. The

Raspberry Pi reboots and takes you to the LXDE GUI. You are not required to provide a login name or password.

If you change your mind and want to log in to the command line after the Pi boots again, you can run the LXTerminal program and type sudo raspi-config to change your boot behavior configuration option.

The LXPanel

By default, the Raspberry Pi LXPanel contains 10 applets, as shown in Table 2.2.

Table 2.2 LXPanel Applets

The first icon all the way to the left on the LXPanel is the LXDE Programs Menu icon (the button with the raspberry on it).

When you click this LXDE Programs Menu icon, you get several menu categories and options (see Table 2.3).

Table 2.3 The LXDE Menu

The next LXPanel icon is the Epiphany web browser. It provides basic web browsing capabilities so you can view most websites from your Raspberry Pi desktop.

After that is the PCManFM File Manager icon. The PCManFM window, shown in Figure 2.2, is similar to the Microsoft Windows File Manager in that it allows you to graphically navigate through your files and folders.

Figure 2.2 The LXDE File Manager.

Next is the LXTerminal icon. The LXTerminal program provides a portal to the command-line interface. You can click the LXTerminal icon to start the program. After the window is open, you can type in exactly the same commands as at the command-line prompt. For example, Figure 2.3 shows what happens when you type the whoami command in the LXTerminal. You can see that LXTerminal enables you to stay in the GUI and yet enter command-line commands.

Figure 2.3 The LXTerminal command-line interface.

On the far right side of the LXPanel are four applets that display system information. First, the Network Manager applet shows whether your Raspberry Pi is connected to a network.

Next, the Volume Manager icon shows whether the speakers are muted and allows you to adjust the volume.

After that is the CPU Utilization applet. This shows the current utilization of the system, both as a number and as a graphical chart in the background. The graphical chart is nice in that you can see the recent history of the CPU utilization to spot trends. If a window is sluggish to open in the GUI, glance over at this applet. You might see that your Pi is very busy!

Finally, the Digital Clock icon displays what your Raspberry Pi thinks is the current time.

If you hover the mouse over it, the current date is displayed. You can click the Digital Clock icon to see the current month’s calendar. You can click it again to hide the current month’s calendar.

Try It Yourself: Explore the LXDE Graphical Interface

Now that you have reviewed the various icons on the LXDE graphical interface and the features of the LXPanel, it’s time to play with the GUI yourself. In the

following steps, you get a chance to try items in both the command line and the LXDE GUI, as well as fix some potential problems and irritations:

1. If you have not already done so, connect your Raspberry Pi to your network.

Watch Out!: Wired Versus Wi-Fi

In the next few steps, you will update your Raspbian Linux distribution software.

When you do this, you should use a wired network connection. A Wi-Fi connection can be a little fussy and cause you a great deal of unnecessary work due to software bugs. The safest way to proceed is to connect to a wired network, update your software, and then attempt to connect to your Wi-Fi.

2. Power up your Raspberry Pi.

3. At the raspberrypi login: prompt, type pi and press the Enter key. You should now see a Password: prompt.

4. At the Password: prompt, type raspberry or the password you created in the last “Try it Yourself” section; then press the Enter key. You should see the pi@raspberry~$ prompt.

Watch Out!: Did You Change Your Password?

Earlier this hour, you may have changed your password from raspberry to something else. If you are following along with the “Try It Yourself” steps, be sure to enter that password in step 4.

5. At the pi@raspberry~$ prompt, type startx and press the Enter key to start Raspbian’s LXDE graphical interface.

6. Once you are in the LXDE graphical interface, click the LXTerminal icon in the LXPanel to open a command-line interface. You should see the familiar

pi@rasbperry~$ prompt displayed in the LXTerminal window.

7. Click the LXTerminal window with your mouse to select it. Type whoami and press the Enter key. You should see the response pi displayed along with another prompt, just as you saw when you were typing in commands at the command line.

8. To get your Raspbian Linux distribution software up-to-date, in the same LXTerminal window, type the command sudo apt-get dist-upgrade and press the Enter key. You should see several messages concerning the

software update and then the question Do you want to continue [Y/n]?

9. Type Y and press the Enter key. If your software was already up-to-date, you will get a message similar to “0 upgraded, 0 newly installed…” However, if your software was terribly out-of-date, this can take several minutes! The software update will continue on its merry way until the software is all updated.

Watch Out!: Problems Fetching Archives

If your software update ends quickly and you get a message similar to E: Unable to fetch some archives…, then your Raspberry Pi is not connected to the network properly or is unable to reach the Internet. For the update to work

correctly, you must be able to access the Internet from your Raspberry Pi.

10. Now that your system is up-to-date, you will be adding an extra package to your Raspberry Pi. For the ScreenLock on the LXPanel to work correctly, you need a screensaver software package installed. In the LXTerminal window, type sudo apt-get install xscreensaver and press the Enter key.

11. You should see several messages concerning the software update and then the question Do you want to continue [Y/n]? Type Y and then press the Enter key. When you get the prompt back, your screensaver has been installed.

12. Leave the LXTerminal window open for now and click the LXDE Programs Menu icon on the far left of the LXPanel to open the menu.

13. Hover over Preferences in the LXDE menu to open the submenu, and then click Screensaver. The Screensaver Preferences window appears, as shown in Figure 2.4.

Figure 2.4 The LXDE Screensaver Preferences window.

By the Way: Sluggish Windows

Don’t be surprised if the windows in the GUI open a little slowly. Your Raspberry Pi is working with all its might to get them opened quickly. If a window seems slow, look at the CPU Monitor Graph on the near right side of the LXPanel to see whether your Pi is busy processing.

14. If you see another window that says The XScreenSaver daemon

doesn't seem to be running on display "o:" Launch it now?, click the OK button on that window.

15. On the Screensaver Preferences window, make sure the Display Modes tab is selected, as shown in Figure 2.4.

16. Click the Modes drop-down, and select Only One Screen Saver.

17. Still in the Screensaver Preferences window, under the Modes section, scroll through the screensavers until you find Fiberlamp. Then click it to select it.

18. Now click the Preview button in the Screensaver Preferences window, and wait a few seconds. You should see the screensaver in action.

19. Click anywhere on the screensaver window to return to the LXDE graphical

interface.

20. Now close the Screensaver Preferences window by clicking the white X in the right corner of the window; give it a few seconds to close.

21. Test your screen lock by letting the desktop sit idle for the time you specified in the settings. In a few seconds, the screensaver should appear.

22. Click anywhere on the screensaver window. This should return you to your desktop. If you selected the Lock option in the screensaver settings, you won’t return to the LXDE graphical interface. Instead, a new window will pop up, stating Please enter your password.

23. Type in your password and press the Enter key.

Watch Out!: Did You Change Your Password?

Earlier this hour, you may have changed your password from raspberry to something else. If you are following along with the “Try It Yourself” steps in this chapter, remember that you changed the password from raspberry to something else earlier in this chapter! Be sure to enter that password here in this step 23.

24. When the LXDE graphical interface appears again, click the LXTerminal window to select it.

25. In the LXTerminal window, type exit and press Enter to close the window.

Good work! Now you know how to use the LXDE graphical interface to change various items to your liking.

Summary

In this hour, you read about the Raspbian Linux distribution. You can now enter

commands at the Linux command line as well as navigate through the LXDE GUI. You know about various Debian and Raspbian documentation resources, and you know how to update the software packages on your Raspberry Pi. Now that you have looked around your Pi, in Hour 3, “Setting Up a Programming Environment,” you will learn how to set up and explore the Python programming environment.

Q&A

Q. I don’t like entering commands at the Linux command line. Do I have to do this?

A. Nope. The LXDE GUI can handle a lot of the commands you enter at the Linux command line. However, if you know how to use both the command line and the GUI, you will have the most flexibility and troubleshooting capabilities.

Q. Can I install a different graphical interface besides LXDE?

A. Yes, you can! Some Raspberry Pi users prefer the Xfce desktop. See

http://www.raspbian.org/ RaspbianForums for help on obtaining a new interface.

Q. Does this book focus on Python programming in the command line or the GUI?

A. The book primarily focuses on teaching you Python programming using the GUI.

(You can breathe a sigh of relief now.)

Workshop Quiz

1. Raspbian is based on the Debian distribution, with Linux at its core. True or false?

2. Which command entered at the Linux command line will reboot your Raspberry Pi?

a. reboot b. restart c. sudo reboot

3. Which graphical interface desktop environment comes with Raspbian by default?

4. What user account must you log into the Raspberry Pi with after loading the software?

a. admin b. pi c. system d. test

5. What command line command displays the contents of a file?

6. What command allows you to run a program with the root user account’s privileges?

7. The startx command line command starts the LXDE window. True or False?

8. What do you call the bar that appears along the top of a LXDE window?

a. LXPanel

b. Task Manager c. Launcher

d. Start bar

9. What utility should you use to change the Raspberry Pi to start the LXDE graphical desktop automatically?

10. The Firefox browser is installed on the Raspberry Pi by default. True or False?

Answers

1. True. Raspbian is based on the Debian Linux distribution.

2. To reboot your Raspberry Pi from the command line, enter the command sudo reboot.

3. The Lightweight X11 Desktop Environment (LXDE) graphical interface comes with Raspbian by default.

4. You must log in using the Pi user account after first installing Raspbian.

5. The cat command line command displays the contents of a text file.

6. The sudo command line command allows you to run a program with the root user privileges.

7. True. The startx command launches the LXDE graphical desktop program.

8. The LXPanel appears as a bar along the top of the desktop, and contains the menu, program icons, and applets.

9. The raspi-config utility allows you to change basic settings in the Raspberry Pi system.

10. False. The Raspberry Pi uses the Epiphany browser as the default browser in the LXDE graphical desktop.

Hour 3. Setting Up a Programming Environment

What You’ll Learn in This Hour:

Where Python originated

How to check your Python environment The Python interactive shell

Using a Python development environment How to create and run a Python script

This hour, you explore the Python programming environment. You learn about the various tools that can help as you learn how to program in Python. By the end of this hour, you will be familiar with the Python interactive shell and a Python development environment.

In addition, you will have written your first line of Python code!