X session manager

Last updated

In the X Window System, an X session manager is a session management program, a program that can save and restore the current state of a set of running applications, including window manager.

Contents

Overview

From the point of view of an X session manager, a session is a “state of the desktop” at a given time: a set of windows with their current content. More precisely, a session is the set of clients managing these windows or related to them and the information that allows these applications to restore the condition of these windows if required.

The most recognizable effect of using a session manager is the possibility of logging out from an interactive session and then finding exactly the same windows in the same state when logging in again. For this to work, the session manager program stores the names of applications that are running at logout and starts them again at login. Moreover, for the state of the applications to be restored as well (which is needed to restore the content of windows), the applications must be able to save their state of execution upon request from the session manager and load it back when started again.

In general, a session can be saved or loaded at any time, even if the user is not logging in or out. It is also possible to save a number of different sessions and loading one of them at user's choice. Sessions can also be specified by providing the list of applications that compose the session. As a result, the user has the possibility of saving a set of different sessions, either by storing the state of execution of the currently running applications or by explicitly listing the applications that compose a session. This way, the user can later decide to load a given session.

XSMP Protocol

In order for a session to include the state of an application, the application must be able to store and load its current state when session manager request to do so (usually on user login or logout). A protocol named X Session Management Protocol (XSMP) specifies how applications and session managers interact. The XSMP message format is the same as Interactive Connectivity Establishment (ICE) message format. [1] Of particular importance is that the window manager is able to communicate with the session manager, as the window manager is responsible for the placement of windows and the existence of icons. Applications that cannot store their state can be included in a session, but they do not preserve their state across sessions.

The Protocol

The XSMP is a subprotocol of the Inter-Client Exchange Protocol. The client starts the protocol by connecting to the session manager. How the session manager is located on the network is system-dependent: in a POSIX system, the environment contains a variable SESSION_MANAGER. Therefore, when a client is launched, its environment must contain this variable with an appropriate value.

Identifiers

The protocol takes into account two facts:

  1. in order for a session to be restarted properly, not only the applications running in it must be restarted, but they must also be restarted in such a way they restore their previous state;
  2. the same application may be running more than once in the same or different session.
A session with two instances of xedit open on different files Editors.png
A session with two instances of xedit open on different files

Different instances of the same application may be active at the same time in the same or in different sessions, and these instances most likely have different states of execution. For example, the user may have launched a text editor on file /etc/passwd, then on file letter.txt in the same session, and then on file todo.txt in another session.

In order for the sessions to be restored properly, different instances of the same application must be recognized as different by the session manager. For this reason, the session manager chooses a unique identifier for each instance of each application. This way, the session manager is able to distinguish between the text editor that is running on /etc/passwd and the text editor running on todo.txt, even if they are two instances of the same program.

The identifiers must be unique. In particular, they must be unique across all sessions managed by the session manager: the identifier of the text editor running on /etc/passwd is different not only from the same text editor running on letter.txt but also different from the text editor running on todo.txt in another session. The identifier of a client remains the same even if the session is shut down and restarted.

The main parts of the protocol

The main parts of the protocol of session management are:

  1. the session manager chooses a unique identifier for every client
  2. the session manager requests clients to save their state
  3. a client specifies how it has to be started again in order for the state to be restored (e.g., the command line to be used to start the process)

The last point is possible because the session manager maintains a set of properties for every client (in the X Window System terminology, a property is simply a container for data). These pieces of information can be modified by the client at any time. One of these properties is named RestartCommand, and contains the information on how the client has to be started again.

When the session manager requests a client to save its state, the application proceeds as follows:

  1. it saves its state in such a way that the states of two different instances can be distinguished; this can be obtained for example by saving the state in a file whose name contains its identifier
  2. it stores the specification of how it has to be started again in the RestartCommand property; this property must contain the client identifier because:
    1. the application must retain its identifier when started again
    2. the identifier is needed to restore the state (for example, it is needed to find the file where its state is stored)

The session manager maintains other properties beside RestartCommand. For example, a property specifies how to run the application if the session is destroyed.

Local and global state

When asking a client to save its state, the window manager can specify whether the local or global state (or both) has to be saved. The difference is whether the result of the save should be visible to the other applications or not.

In the case of the text editor, saving the global state means saving the file normally, so that other applications can use the new version of the file. Saving the local state means that a local copy of the file has to be saved, so that other applications can see the file in its original version.

An example

The following are the main steps in the interaction of a session manager with the hypothetical text editor xyz when this application is started for the first time in a session, then the user logs out and then in again:

  1. the application connects to the session manager via the Inter-Client Exchange Protocol
  2. the application tells the session manager that this is the first time it is started, and therefore it has no previous identifier (and, therefore, no previous state)
  3. the session manager replies by sending the client its unique identifier, say 4324;
  4. the session manager immediately asks the client to save its local state (only because the client has been started for the first time)
  5. the client stores the command line xyz -sid 4324 as the property RestartCommand in the session manager (this is also system-dependent: in a POSIX system, this property actually contains the argv array)
  6. the client stores its state locally; for example, it may store the name of the edited file and all other information (such as the current line) in the local file .temp-4324
  7. when the user logs out, the session manager sends a message to all client notifying that they have to save their state
  8. the client 4324 complies again
  9. when all clients have communicated the session manager that their state is saved, the session manager shuts down the session

When the client is told to save its state, it may have the possibility of having a limited interaction with the user or not (for example, to ask the user if the edited file is to be saved). Anyway, the state is saved, it tells the session manager by sending an appropriate message).

When the session is started again, the following takes place:

  1. the session manager restarts the client 4324 by executing what is stored in the property RestartCommand associated with the client 4324
  2. the application is therefore started as xyz -sid 4324; this way, the application knows its identifier
  3. the application retrieves the state information from the file .temp-4324
  4. the application connects to the session manager specifying the identifier 4324, so that the session manager knows that this is not a new client but an old one restarting

Client-managing sessions

According to the XSMP protocol, a session manager is an arbitrary program (server) that runs and controls the state of other applications. As a result, a client can itself be a session manager of other clients. For example, a mail client can start a text editor for the sake of writing an email, and behave as a session manager with respect to the editor. This way, if the mail client is closed and then restarted again, it can restore the state of the text editor.[ citation needed ]

Implementations

The X Window System includes a default session manager called xsm. Other session managers have been developed for specific desktop environments.

KDE

ksmserver is a default session manager of KDE Plasma 5 Desktop environment. [2] [3]

Xfce

xfce4-session program is a default X Session Manager for Xfce based DEs. Xfce allows to create different sessions and choose them at startup. [4] [5]

Gnome

gnome-session is a default session manager for Gnome DE. Gnome has supported XSMP since v1.x. 2013 GNOME had intention to replace GNOME session manager XSMP with a D-Bus interface in version 2.24. [6] It was eventually decided to combine both interfaces and provide an adapter (client) for legacy applications. [7] At the time it wasn't feature-complete however, nor used by non GNOME applications. [8] As of 2021 the codebase still includes X session manager clients.

See also

Related Research Articles

X Window System Windowing system for bitmap displays on UNIX-like systems

The X Window System is a windowing system for bitmap displays, common on Unix-like operating systems.

In computing, a desktop environment (DE) is an implementation of the desktop metaphor made of a bundle of programs running on top of a computer operating system that share a common graphical user interface (GUI), sometimes described as a graphical shell. The desktop environment was seen mostly on personal computers until the rise of mobile computing. Desktop GUIs help the user to easily access and edit files, while they usually do not provide access to all of the features found in the underlying operating system. Instead, the traditional command-line interface (CLI) is still used when full control over the operating system is required.

X window manager Type of window manager

An X window manager is a window manager that runs on top of the X Window System, a windowing system mainly used on Unix-like systems.

Xfce Desktop environment

Xfce or XFCE is a free and open-source desktop environment for Linux and Unix-like operating systems.

ROX Desktop Desktop environment for X Window System

The ROX Desktop is a graphical desktop environment for the X Window System. It is based on the ROX-Filer which is a drag and drop spatial file manager. It is free software released under the GNU General Public License. The environment was inspired by the user interface of RISC OS. The name "ROX" comes from "RISC OS on X". Programs can be installed or removed easily using Zero Install.

freedesktop.org (fd.o) is a project to work on interoperability and shared base technology for free-software desktop environments for the X Window System (X11) and Wayland on Linux and other Unix-like operating systems. It was founded by Havoc Pennington a GNOME developer working for Red Hat in March 2000. The project's servers are hosted by Portland State University, sponsored by Hewlett-Packard, Intel, and Google.

In computer science and networking in particular, a session is a temporary and interactive information interchange between two or more communicating devices, or between a computer and user. A session is established at a certain point in time, and then ‘torn down’ - brought to an end - at some later point. An established communication session may involve more than one message in each direction. A session is typically stateful, meaning that at least one of the communicating parties needs to hold current state information and save information about the session history to be able to communicate, as opposed to stateless communication, where the communication consists of independent requests with responses.

In computing, the X Window System is a network-transparent windowing system for bitmap displays. This article details the protocols and technical structure of X11.

X display manager

In the X Window System, an X display manager is a graphical login manager which starts a login session on an X server from the same or another computer.

In computing, D-Bus is a message-oriented middleware mechanism that allows communication between multiple processes running concurrently on the same machine. D-Bus was developed as part of the freedesktop.org project, initiated by Havoc Pennington from Red Hat to standardize services provided by Linux desktop environments such as GNOME and KDE.

Music Player Daemon (MPD) is a free and open music player server. It plays audio files, organizes playlists and maintains a music database. In order to interact with it, a client program is needed. The MPD distribution includes mpc, a simple command line client.

GNOME Terminal Terminal emulator from GNOME

GNOME Terminal is a terminal emulator for the GNOME desktop environment written by Havoc Pennington and others. Terminal emulators allow users to access a UNIX shell while remaining on their graphical desktop.

Selections, cut buffers, and drag-and-drop are the mechanisms used in the X Window System to allow a user to transfer data from one window to another. Selections and cut buffer are typically used when a user selects text or some other data in a window and pastes in another one. Drag-and-drop is used when a user selects something in a window, then clicks on the selection and drags it into another window.

Dreamlinux

Dreamlinux was a Brazilian computer operating system based on Debian Linux. It can boot as a live CD, from USB flash drive, or can be installed on a hard drive. The distribution's GUI aims to have a centered animated toolbar. As of October 2012, The Dreamlinux Project has been discontinued.

A desktop environment is a collection of software designed to give functionality and a certain look and feel to an operating system.

Quick Assist

Quick Assist is a Microsoft Windows feature that allows a user to view or control a remote Windows computer over a network or the Internet to resolve issues without directly touching the unit. It is based on the Remote Desktop Protocol (RDP). It is complemented by Get Help, a feature introduced in Windows 10 that enables the user to contact Microsoft directly but does not allow for remote desktoping or screen sharing.

Remote Desktop Services (RDS), known as Terminal Services in Windows Server 2008 and earlier, is one of the components of Microsoft Windows that allow a user to take control of a remote computer or virtual machine over a network connection. RDS is Microsoft's implementation of thin client architecture, where Windows software, and the entire desktop of the computer running RDS, are made accessible to any remote client machine that supports Remote Desktop Protocol (RDP). User interfaces are displayed from the server onto the client system and input from the client system is transmitted to the server - where software execution takes place. This is in contrast to application streaming systems, like Microsoft App-V, in which computer programs are streamed to the client on-demand and executed on the client machine.

GNOME Desktop environment for Linux and Unix-like systems

GNOME is a free and open-source desktop environment for Unix-like operating systems. GNOME was originally an acronym for GNU Network Object Model Environment, but the acronym was dropped because it no longer reflected the vision of the GNOME project.

QVD is an open-source virtual desktop infrastructure (VDI) product built on Linux. Its main purpose is to provide remote desktops to users.

References

  1. "X Session Management Protocol". www.x.org. Retrieved 2020-12-02.
  2. "KDE Desktop User Guide - KSMServer". www.linuxtopia.org. Retrieved 2021-10-05.
  3. "ksmserver · master · Plasma / Plasma Workspace". GitLab. Retrieved 2021-10-05.
  4. "xfce:xfce4-session:start [Xfce Docs]". docs.xfce.org. Retrieved 2021-10-05.
  5. "xfce:xfce4-session:preferences [Xfce Docs]". docs.xfce.org. Retrieved 2021-10-05.
  6. "Projects/SessionManagement/GnomeSession - GNOME Wiki!". wiki.gnome.org.
  7. "Projects/SessionManagement/NewGnomeSession - GNOME Wiki!". wiki.gnome.org. Retrieved 2021-10-05.
  8. "Chapter 6 Session Management (GNOME 2.0 Desktop for the Solaris Operating Environment System Administration Guide)". docs.oracle.com. Retrieved 2021-10-05.