1. Overview

In the realm of Linux, xeyes stands out as a charming and playful tool that provides a unique window into the capabilities of the X Window System.

In this tutorial, we delve into the purpose of xeyes, its underlying architecture, its compatibility with Wayland, and how to use it as a diagnostic tool for remote systems.

2. Xeyes Purpose

To begin with, let’s discuss what xeyes is and understand its common uses.

2.1. Theoretical Explanation

This friendly tool, known as xeyes, is a graphical program. Furthermore, it showcases the power of the X Window System. In particular, it displays a pair of eyes that follow the mouse cursor‘s movement on the screen.

At first glance, it appears to be a playful experiment. Still, beneath the surface, xeyes serves a deeper purpose. For example, it offers a window into the capabilities and details of the X Window System. In fact, X acts as the windowing system that forms the backbone of various Linux desktop environments.

2.2. Practical Usage

Now, let’s highlight some of the actual uses of xeyes:

  1. security monitoring: xeyes serves as a tool to keep an eye on the activities of a person using our computer; if we suspect unauthorized use, running xeyes enables us to monitor their actions
  2. accessibility support: xeyes can serve as a visual aid for individuals who have difficulty tracking the mouse pointer; its big and high-contrast display simplifies the process for users with visual limitations to locate and follow the cursor on their screen
  3. enjoyable diversions: xeyes offers a source of fun; users can experiment with the program, directing the eyes to follow many objects on the screen, resulting in an engaging and enjoyable user experience

Therefore, it has gained popularity among Linux users for its crucial deliverables to the system’s functionality.

3. Xt Widget Implementation

The core of xeyes lies in its implementation as an Xt Widget. In essence, it’s utilizing the X Toolkit Intrinsics (Xt) library. Moreover, this architectural choice enables xeyes to integrate with the X Window System seamlessly. Accordingly, it helps create a flexible and customizable part of the visual interface.

Let’s check an excerpt of the code that exemplifies xeyes as an Xt Widget:

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <stdio.h>

The above lines include the necessary headers. Next, the resources are defined:

static XtResource resources[] = {
    XtOffsetOf(EyeRec, big),
  // Additional resources...

In the above snippet, there’s a resource named pupils with the type XtRboolean. Hence, it indicates a boolean value. This resource is stored in a structure called EyeRec at the correct offset.

Now, we move on to the main() function:

void main(int argc, char **argv) {
  XtAppContext app;
  Widget toplevel;

  toplevel = XtAppInitialize(&app, "xEyes", NULL, 0, &argc, argv, NULL, resources, NULL, 0);

Finally, let’s go over the main() function:

  • XtAppContext app: declares a context for the Xt application
  • widget toplevel: declares a top-level widget, which is the main window

Overall, this code snippet establishes the foundation for xeyes as an Xt Widget:

  • it defines rules that control the widget’s behavior
  • starts the tool
  • sets up the main window

By employing Xt Widgets, xeyes follows the rules of programming based on events. This enables response to user actions in real time. This architectural choice shows the program’s ability and importance within the X11 environment.

In addition, this code doesn’t produce a visual output. However, it sets the basis for how the pictures will be shown later on the xeyes tool.

4. Remote Systems X11 Verification

Xeyes serves a practical purpose in the realm of system administration. It can be used as a diagnostic tool to verify if X11 is correctly set up on remote systems. Particularly, this is useful when managing headless servers or accessing remote desktops through SSH.

Let’s see an example of a Bash script for remote X11 verification:

$ ssh -X "$REMOTE_USER@$REMOTE_HOST" 'xeyes'

Consequently, we’ll go over the above command:

  • REMOTE_HOST should hold the address of the remote system we wish to verify
  • REMOTE_USER should hold the username we use to log into the remote system
  • ssh establishes an SSH connection to the remote system with X11 forwarding enabled via -X

Finally, we execute the xeyes command. This launches the xeyes tool on the remote system. However, it displays its GUI on our local X11 server. Accordingly, the xeyes tool window shows up locally. Particularly, this indicates that X11 is correctly set up and functioning on the remote system.

5. Wayland and XWayland Compatibility

As Linux evolves, new display servers like Wayland aim to replace the aging X11 system. One might wonder about xeyes‘ compatibility with these new technologies. Fortunately, xeyes still runs in Wayland environments through a compatibility layer known as XWayland.

Let’s see some differences between Wayland and XWayland:

  • Wayland: designed as a modern display protocol to replace X11, prioritizing security and performance
  • XWayland: serves as a compatibility layer, enabling the operation of X11 applications on Wayland-based systems

Furthermore, the XWayland layer allows X11 applications to operate within a Wayland session. This ensures that xeyes can continue to serve its purpose in the modern Linux ecosystem.

To identify which Linux apps use Wayland and which use XWayland, we use the mouse to hover over the app. In essence, the eyes move when we hover on apps using XWayland. On the other hand, since native Wayland windows can’t communicate with the X11 server, their eyes won’t move.

6. Conclusion

In this article, we understood that xeyes may appear as a playful tool at first glance. Still, it serves as a simple tool for knowing the capabilities of the X Window System.

Furthermore, its ability to modern display servers like Wayland, along with its utility as a diagnostic tool for remote systems, showcases the enduring relevance of this seemingly friendly program in the Linux system.

Finally, by exploring its underlying code and practical tools, we gain extra information on the complex architecture of X11 and its role in shaping the Linux graphical interface.

Comments are closed on this article!