Raspberry pi projects 2015

Page 88

Linux

WorldMags.net

Graphics How your Linux box stays looking so tickety-boo.

T

he X Window System is the standard basis for providing a graphical interface. While the likes of KDE and Gnome provide the user interface and eye candy, it is through X that they communicate with the hardware. For many years, this was a mass of arcane configuration options and required a lengthy configuration file containing things such as modelines that specified the likes of pixel clock rates and sync frequencies. These days, most systems will run without any configuration file at all. Massive improvements in hardware detection mean that a system with a single video card and single display will ‘just work’. You may need to install extra drivers to get 3D acceleration if you are using, for example, an Nvidia card, but otherwise you just boot the computer and start clicking your mouse. X has a client/server

architecture. X itself runs as the server, maintaining the display; client programs then communicate with the server, telling it what to draw and where.

Legacy features This may seem excessively complex, but it uses local sockets to communicate between the clients and server, so there is no significant performance hit. One clear advantage of this method is that the client and server do not have to be running on the same computer. You can connect to another computer by SSH and, providing the configuration gives permission for this, run a program on the remote computer and have its GUI displayed on your local screen. This is different from the likes of VNC because only the one application’s window is displayed locally, and it only appears locally – not on the remote computer. A VNC connection mirrors the whole desktop on both computers. Some consider the client/server architecture to be overly complex, so there are moves to develop more simple methods of running a graphical display. The most advanced is Wayland. This takes a different approach; not only is the old client/server setup gone, but Wayland leaves the rendering of windows and other display elements to the client applications, usually using OpenGL and Cairo. This simplifies Wayland; X contains a lot of legacy rendering code that’s required by the X specification but never used. By giving control to the clients, Wayland can be lighter, more efficient and future-proof. It also means your graphical software has more control over how the GUI is displayed.

“These days, most systems will run without any configuration file”

Tools such as KDE’s monitor settings help with things like setting up dual monitors, but for a single display you shouldn’t need to configure X at all.

Daemons If you ever disable the splash screen most distros use to cover the boot messages, you will see a screen full of information about services being started. What are these services, and are they all necessary? The services are the programs that run in the background, making the computer as useful as it is. Some deal with networking, others handle hardware detection and configuration, while more are the traditional software services, or daemons, that provide functions to other programs when needed. The answer to the second part of that question is most likely to be “no”. While some of these services are used by almost all systems, such as the syslog daemon that handles writing information to system log files, others may not be needed. There is no need to start CUPS, the printing system, if you don’t have a printer available. Similarly, the MySQL database server may not be needed, nor the SSH daemon if you

88 | Raspberry Pi Projects

have only one computer on your network. So spending half an hour experimenting could shave a second off your boot time. You may also save some resources by not starting unnecessary services, but once loaded these daemons consume almost no system resources, and even the memory that they use can be swapped out if they are not called. So only disable those services you know you will never need. Having them patiently listening on a network port or socket makes the operation of your client programs that bit more efficient. Programs don’t need to include, or load, code for opening, writing to and closing log files, they just call the syslog() function with the log text, and the daemon takes care of the rest. Syslog is an important service – when something goes wrong, this is often the first place to look, as most programs send error messages to the system log (usually at /var/log/messages).

WorldMags.net

It is possible to reduce your boot time by only running the services you need.

Why are background services called daemons? There are a few explanations; we prefer the story that daemons were beings in Greek mythology that handled tasks that the gods could not be bothered with.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.