LightDMGreeter

LightDMGreeter — Make a connection to the LightDM daemon and authenticate users

Functions

GQuark lightdm_greeter_error_quark ()
LightDMGreeter * lightdm_greeter_new ()
void lightdm_greeter_set_resettable ()
void lightdm_greeter_connect_to_daemon ()
gboolean lightdm_greeter_connect_to_daemon_finish ()
gboolean lightdm_greeter_connect_to_daemon_sync ()
const gchar * lightdm_greeter_get_hint ()
const gchar * lightdm_greeter_get_default_session_hint ()
gboolean lightdm_greeter_get_hide_users_hint ()
gboolean lightdm_greeter_get_show_manual_login_hint ()
gboolean lightdm_greeter_get_show_remote_login_hint ()
gboolean lightdm_greeter_get_lock_hint ()
gboolean lightdm_greeter_get_has_guest_account_hint ()
const gchar * lightdm_greeter_get_select_user_hint ()
gboolean lightdm_greeter_get_select_guest_hint ()
const gchar * lightdm_greeter_get_autologin_user_hint ()
gboolean lightdm_greeter_get_autologin_guest_hint ()
gint lightdm_greeter_get_autologin_timeout_hint ()
void lightdm_greeter_cancel_autologin ()
gboolean lightdm_greeter_authenticate ()
gboolean lightdm_greeter_authenticate_as_guest ()
gboolean lightdm_greeter_authenticate_autologin ()
gboolean lightdm_greeter_authenticate_remote ()
gboolean lightdm_greeter_respond ()
gboolean lightdm_greeter_cancel_authentication ()
gboolean lightdm_greeter_get_in_authentication ()
gboolean lightdm_greeter_get_is_authenticated ()
const gchar * lightdm_greeter_get_authentication_user ()
gboolean lightdm_greeter_set_language ()
void lightdm_greeter_start_session ()
gboolean lightdm_greeter_start_session_finish ()
gboolean lightdm_greeter_start_session_sync ()
void lightdm_greeter_ensure_shared_data_dir ()
gchar * lightdm_greeter_ensure_shared_data_dir_finish ()
gchar * lightdm_greeter_ensure_shared_data_dir_sync ()
gboolean lightdm_greeter_connect_sync ()

Properties

Signals

Types and Values

Object Hierarchy

    GEnum
    ├── LightDMGreeterError
    ├── LightDMMessageType
    ╰── LightDMPromptType
    GObject
    ╰── LightDMGreeter

Includes

#include <lightdm.h>

Description

LightDMGreeter is an object that manages the connection to the LightDM server and provides common greeter functionality.

An example of a simple greeter:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
int main ()
{
    GMainLoop *main_loop;
    LightDMGreeter *greeter

    main_loop = g_main_loop_new ();

    greeter = lightdm_greeter_new ();
    g_object_connect (greeter, "show-prompt", G_CALLBACK (show_prompt_cb), NULL);
    g_object_connect (greeter, "authentication-complete", G_CALLBACK (authentication_complete_cb), NULL);

    // Connect to LightDM daemon
    if (!lightdm_greeter_connect_to_daemon_sync (greeter, NULL))
        return EXIT_FAILURE;

    // Start authentication
    lightdm_greeter_authenticate (greeter, NULL);

    g_main_loop_run (main_loop);

    return EXIT_SUCCESS;
}

static void show_prompt_cb (LightDMGreeter *greeter, const char *text, LightDMPromptType type)
{
    // Show the user the message and prompt for some response
    gchar *secret = prompt_user (text, type);

    // Give the result to the user
    lightdm_greeter_respond (greeter, response);
}

static void authentication_complete_cb (LightDMGreeter *greeter)
{
    // Start the session
    if (!lightdm_greeter_get_is_authenticated (greeter) ||
        !lightdm_greeter_start_session_sync (greeter, NULL))
    {
        // Failed authentication, try again
        lightdm_greeter_authenticate (greeter, NULL);
    }
}

Functions

lightdm_greeter_error_quark ()

GQuark
lightdm_greeter_error_quark (void);

lightdm_greeter_new ()

LightDMGreeter *
lightdm_greeter_new (void);

Create a new greeter.

Returns

the new LightDMGreeter


lightdm_greeter_set_resettable ()

void
lightdm_greeter_set_resettable (LightDMGreeter *greeter,
                                gboolean resettable);

Set whether the greeter will be reset instead of killed after the user logs in. This must be called before lightdm_greeter_connect is called.

Parameters

greeter

A LightDMGreeter

 

resettable

Whether the greeter wants to be reset instead of killed after the user logs in

 

lightdm_greeter_connect_to_daemon ()

void
lightdm_greeter_connect_to_daemon (LightDMGreeter *greeter,
                                   GCancellable *cancellable,
                                   GAsyncReadyCallback callback,
                                   gpointer user_data);

Asynchronously connects the greeter to the display manager.

When the operation is finished, callback will be invoked. You can then call lightdm_greeter_connect_to_daemon_finish() to get the result of the operation.

See lightdm_greeter_connect_to_daemon_sync() for the synchronous version.

Parameters

greeter

The greeter to connect

 

cancellable

A GCancellable or NULL.

[allow-none]

callback

A GAsyncReadyCallback to call when completed or NULL.

[allow-none]

user_data

data to pass to the callback or NULL.

[allow-none]

lightdm_greeter_connect_to_daemon_finish ()

gboolean
lightdm_greeter_connect_to_daemon_finish
                               (LightDMGreeter *greeter,
                                GAsyncResult *result,
                                GError **error);

Finishes an operation started with lightdm_greeter_connect_to_daemon().

Parameters

greeter

The greeter the the request was done with

 

result

A GAsyncResult.

 

error

return location for a GError, or NULL

 

Returns

TRUE if successfully connected


lightdm_greeter_connect_to_daemon_sync ()

gboolean
lightdm_greeter_connect_to_daemon_sync
                               (LightDMGreeter *greeter,
                                GError **error);

Connects the greeter to the display manager. Will block until connected.

Parameters

greeter

The greeter to connect

 

error

return location for a GError, or NULL

 

Returns

TRUE if successfully connected


lightdm_greeter_get_hint ()

const gchar *
lightdm_greeter_get_hint (LightDMGreeter *greeter,
                          const gchar *name);

Get a hint.

Parameters

greeter

A LightDMGreeter

 

name

The hint name to query.

 

Returns

The value for this hint or NULL if not set.

[nullable]


lightdm_greeter_get_default_session_hint ()

const gchar *
lightdm_greeter_get_default_session_hint
                               (LightDMGreeter *greeter);

Get the default session to use.

Parameters

greeter

A LightDMGreeter

 

Returns

The session name


lightdm_greeter_get_hide_users_hint ()

gboolean
lightdm_greeter_get_hide_users_hint (LightDMGreeter *greeter);

Check if user accounts should be shown. If this is TRUE then the list of accounts should be taken from LightDMUserList and displayed in the greeter for the user to choose from. Note that this list can be empty and it is recommended you show a method for the user to enter a username manually.

If this option is shown the greeter should only allow these users to be chosen for login unless the manual login hint is set.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if the available users should not be shown.


lightdm_greeter_get_show_manual_login_hint ()

gboolean
lightdm_greeter_get_show_manual_login_hint
                               (LightDMGreeter *greeter);

Check if a manual login option should be shown. If set the GUI should provide a way for a username to be entered manually. Without this hint a greeter which is showing a user list can limit logins to only those users.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if a manual login option should be shown.


lightdm_greeter_get_show_remote_login_hint ()

gboolean
lightdm_greeter_get_show_remote_login_hint
                               (LightDMGreeter *greeter);

Check if a remote login option should be shown. If set the GUI should provide a way for a user to log into a remote desktop server.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if a remote login option should be shown.


lightdm_greeter_get_lock_hint ()

gboolean
lightdm_greeter_get_lock_hint (LightDMGreeter *greeter);

Check if the greeter is acting as a lock screen.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if the greeter was triggered by locking the seat.


lightdm_greeter_get_has_guest_account_hint ()

gboolean
lightdm_greeter_get_has_guest_account_hint
                               (LightDMGreeter *greeter);

Check if guest sessions are supported.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if guest sessions are supported.


lightdm_greeter_get_select_user_hint ()

const gchar *
lightdm_greeter_get_select_user_hint (LightDMGreeter *greeter);

Get the user to select by default.

Parameters

greeter

A LightDMGreeter

 

Returns

A username or NULL if no particular user should be selected.

[nullable]


lightdm_greeter_get_select_guest_hint ()

gboolean
lightdm_greeter_get_select_guest_hint (LightDMGreeter *greeter);

Check if the guest account should be selected by default.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if the guest account should be selected by default.


lightdm_greeter_get_autologin_user_hint ()

const gchar *
lightdm_greeter_get_autologin_user_hint
                               (LightDMGreeter *greeter);

Get the user account to automatically log into when the timer expires.

Parameters

greeter

A LightDMGreeter

 

Returns

The user account to automatically log into or NULL if none configured.

[nullable]


lightdm_greeter_get_autologin_guest_hint ()

gboolean
lightdm_greeter_get_autologin_guest_hint
                               (LightDMGreeter *greeter);

Check if the guest account should be automatically logged into when the timer expires.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if the guest account should be automatically logged into.


lightdm_greeter_get_autologin_timeout_hint ()

gint
lightdm_greeter_get_autologin_timeout_hint
                               (LightDMGreeter *greeter);

Get the number of seconds to wait before automaitcally logging in.

Parameters

greeter

A LightDMGreeter

 

Returns

The number of seconds to wait before automatically logging in or 0 for no timeout.


lightdm_greeter_cancel_autologin ()

void
lightdm_greeter_cancel_autologin (LightDMGreeter *greeter);

Cancel the automatic login.

Parameters

greeter

A LightDMGreeter

 

lightdm_greeter_authenticate ()

gboolean
lightdm_greeter_authenticate (LightDMGreeter *greeter,
                              const gchar *username,
                              GError **error);

Starts the authentication procedure for a user.

Parameters

greeter

A LightDMGreeter

 

username

A username or NULL to prompt for a username.

[allow-none]

error

return location for a GError, or NULL

 

Returns

TRUE if authentication request sent.


lightdm_greeter_authenticate_as_guest ()

gboolean
lightdm_greeter_authenticate_as_guest (LightDMGreeter *greeter,
                                       GError **error);

Starts the authentication procedure for the guest user.

Parameters

greeter

A LightDMGreeter

 

error

return location for a GError, or NULL

 

Returns

TRUE if authentication request sent.


lightdm_greeter_authenticate_autologin ()

gboolean
lightdm_greeter_authenticate_autologin
                               (LightDMGreeter *greeter,
                                GError **error);

Starts the authentication procedure for the automatic login user.

Parameters

greeter

A LightDMGreeter

 

error

return location for a GError, or NULL

 

Returns

TRUE if authentication request sent.


lightdm_greeter_authenticate_remote ()

gboolean
lightdm_greeter_authenticate_remote (LightDMGreeter *greeter,
                                     const gchar *session,
                                     const gchar *username,
                                     GError **error);

Start authentication for a remote session type.

Parameters

greeter

A LightDMGreeter

 

session

The name of a remote session

 

username

A username of NULL to prompt for a username.

[allow-none]

error

return location for a GError, or NULL

 

Returns

TRUE if authentication request sent.


lightdm_greeter_respond ()

gboolean
lightdm_greeter_respond (LightDMGreeter *greeter,
                         const gchar *response,
                         GError **error);

Provide response to a prompt. May be one in a series.

Parameters

greeter

A LightDMGreeter

 

response

Response to a prompt

 

error

return location for a GError, or NULL

 

Returns

TRUE if response sent.


lightdm_greeter_cancel_authentication ()

gboolean
lightdm_greeter_cancel_authentication (LightDMGreeter *greeter,
                                       GError **error);

Cancel the current user authentication.

Parameters

greeter

A LightDMGreeter

 

error

return location for a GError, or NULL

 

Returns

TRUE if cancel request sent.


lightdm_greeter_get_in_authentication ()

gboolean
lightdm_greeter_get_in_authentication (LightDMGreeter *greeter);

Checks if the greeter is in the process of authenticating.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if the greeter is authenticating a user.


lightdm_greeter_get_is_authenticated ()

gboolean
lightdm_greeter_get_is_authenticated (LightDMGreeter *greeter);

Checks if the greeter has successfully authenticated.

Parameters

greeter

A LightDMGreeter

 

Returns

TRUE if the greeter is authenticated for login.


lightdm_greeter_get_authentication_user ()

const gchar *
lightdm_greeter_get_authentication_user
                               (LightDMGreeter *greeter);

Get the user that is being authenticated.

Parameters

greeter

A LightDMGreeter

 

Returns

The username of the authentication user being authenticated or NULL if no authentication in progress.

[nullable]


lightdm_greeter_set_language ()

gboolean
lightdm_greeter_set_language (LightDMGreeter *greeter,
                              const gchar *language,
                              GError **error);

Set the language for the currently authenticated user.

Parameters

greeter

A LightDMGreeter

 

language

The language to use for this user in the form of a locale specification (e.g. "de_DE.UTF-8").

 

error

return location for a GError, or NULL

 

Returns

TRUE if set language request sent.


lightdm_greeter_start_session ()

void
lightdm_greeter_start_session (LightDMGreeter *greeter,
                               const gchar *session,
                               GCancellable *cancellable,
                               GAsyncReadyCallback callback,
                               gpointer user_data);

Asynchronously start a session for the authenticated user.

When the operation is finished, callback will be invoked. You can then call lightdm_greeter_start_session_finish() to get the result of the operation.

See lightdm_greeter_start_session_sync() for the synchronous version.

Parameters

greeter

A LightDMGreeter

 

session

The session to log into or NULL to use the default.

[allow-none]

cancellable

A GCancellable or NULL.

[allow-none]

callback

A GAsyncReadyCallback to call when completed or NULL.

[allow-none]

user_data

data to pass to the callback or NULL.

[allow-none]

lightdm_greeter_start_session_finish ()

gboolean
lightdm_greeter_start_session_finish (LightDMGreeter *greeter,
                                      GAsyncResult *result,
                                      GError **error);

Start a session for the authenticated user.

Parameters

greeter

A LightDMGreeter

 

result

A GAsyncResult.

 

error

return location for a GError, or NULL

 

Returns

TRUE if the session was started.


lightdm_greeter_start_session_sync ()

gboolean
lightdm_greeter_start_session_sync (LightDMGreeter *greeter,
                                    const gchar *session,
                                    GError **error);

Start a session for the authenticated user.

Parameters

greeter

A LightDMGreeter

 

session

The session to log into or NULL to use the default.

[allow-none]

error

return location for a GError, or NULL

 

Returns

TRUE if the session was started.


lightdm_greeter_ensure_shared_data_dir ()

void
lightdm_greeter_ensure_shared_data_dir
                               (LightDMGreeter *greeter,
                                const gchar *username,
                                GCancellable *cancellable,
                                GAsyncReadyCallback callback,
                                gpointer user_data);

Ensure that a shared data dir for the given user is available. Both the greeter user and username will have write access to that folder. The intention is that larger pieces of shared data would be stored there (files that the greeter creates but wants to give to a user -- like camera photos -- or files that the user creates but wants the greeter to see -- like contact avatars).

LightDM will automatically create these if the user actually logs in, so greeters only need to call this method if they want to store something in the directory themselves.

Parameters

greeter

A LightDMGreeter

 

username

A username

 

cancellable

A GCancellable or NULL.

[allow-none]

callback

A GAsyncReadyCallback to call when completed or NULL.

[allow-none]

user_data

data to pass to the callback or NULL.

[allow-none]

lightdm_greeter_ensure_shared_data_dir_finish ()

gchar *
lightdm_greeter_ensure_shared_data_dir_finish
                               (LightDMGreeter *greeter,
                                GAsyncResult *result,
                                GError **error);

Function to call from lightdm_greeter_ensure_shared_data_dir callback.

Parameters

result

A GAsyncResult.

 

greeter

A LightDMGreeter

 

error

return location for a GError, or NULL

 

Returns

The path to the shared directory, free with g_free.


lightdm_greeter_ensure_shared_data_dir_sync ()

gchar *
lightdm_greeter_ensure_shared_data_dir_sync
                               (LightDMGreeter *greeter,
                                const gchar *username,
                                GError **error);

Ensure that a shared data dir for the given user is available. Both the greeter user and username will have write access to that folder. The intention is that larger pieces of shared data would be stored there (files that the greeter creates but wants to give to a user -- like camera photos -- or files that the user creates but wants the greeter to see -- like contact avatars).

LightDM will automatically create these if the user actually logs in, so greeters only need to call this method if they want to store something in the directory themselves.

Parameters

greeter

A LightDMGreeter

 

username

A username

 

error

return location for a GError, or NULL

 

Returns

The path to the shared directory, free with g_free.


lightdm_greeter_connect_sync ()

gboolean
lightdm_greeter_connect_sync (LightDMGreeter *greeter,
                              GError **error);

lightdm_greeter_connect_sync has been deprecated since version 1.11.1 and should not be used in newly-written code.

Use lightdm_greeter_connect_to_daemon_sync() instead

Connects the greeter to the display manager. Will block until connected.

Parameters

greeter

The greeter to connect

 

error

return location for a GError, or NULL

 

Returns

TRUE if successfully connected

Types and Values

enum LightDMPromptType

Prompt types the client is required to display.

Members

LIGHTDM_PROMPT_TYPE_QUESTION

prompt is a question. The information can be shown as it is entered.

 

LIGHTDM_PROMPT_TYPE_SECRET

prompt is for secret information. The entered information should be obscured so it can't be publically visible.

 

enum LightDMMessageType

Members

LIGHTDM_MESSAGE_TYPE_INFO

Informational message.

 

LIGHTDM_MESSAGE_TYPE_ERROR

Error message.

 

enum LightDMGreeterError

Error codes returned by greeter operations.

Members

LIGHTDM_GREETER_ERROR_COMMUNICATION_ERROR

error communicating with daemon.

 

LIGHTDM_GREETER_ERROR_CONNECTION_FAILED

failed to connect to the daemon.

 

LIGHTDM_GREETER_ERROR_SESSION_FAILED

requested session failed to start.

 

LIGHTDM_GREETER_ERROR_NO_AUTOLOGIN

autologin not configured.

 

LIGHTDM_GREETER_ERROR_INVALID_USER

autologin not configured.

 

Property Details

The “authentication-user” property

  “authentication-user”      gchar *

The user being authenticated.

Flags: Read

Default value: NULL


The “autologin-guest-hint” property

  “autologin-guest-hint”     gboolean

Autologin guest account hint.

Flags: Read

Default value: FALSE


The “autologin-timeout-hint” property

  “autologin-timeout-hint”   gint

Autologin timeout hint.

Flags: Read

Allowed values: >= 0

Default value: 0


The “autologin-user-hint” property

  “autologin-user-hint”      gchar *

Autologin user hint.

Flags: Read

Default value: NULL


The “default-session-hint” property

  “default-session-hint”     gchar *

Default session hint.

Flags: Read

Default value: NULL


The “has-guest-account-hint” property

  “has-guest-account-hint”   gboolean

Has guest account hint.

Flags: Read

Default value: FALSE


The “hide-users-hint” property

  “hide-users-hint”          gboolean

Hide users hint.

Flags: Read

Default value: FALSE


The “in-authentication” property

  “in-authentication”        gboolean

TRUE if a user is being authenticated.

Flags: Read

Default value: FALSE


The “is-authenticated” property

  “is-authenticated”         gboolean

TRUE if the selected user is authenticated.

Flags: Read

Default value: FALSE


The “lock-hint” property

  “lock-hint”                gboolean

Lock hint.

Flags: Read

Default value: FALSE


The “select-guest-hint” property

  “select-guest-hint”        gboolean

Select guest account hint.

Flags: Read

Default value: FALSE


The “select-user-hint” property

  “select-user-hint”         gchar *

Select user hint.

Flags: Read

Default value: NULL


The “show-manual-login-hint” property

  “show-manual-login-hint”   gboolean

Show manual login hint.

Flags: Read

Default value: FALSE


The “show-remote-login-hint” property

  “show-remote-login-hint”   gboolean

Show remote login hint.

Flags: Read

Default value: FALSE

Signal Details

The “authentication-complete” signal

void
user_function (LightDMGreeter *greeter,
               gpointer        user_data)

The ::authentication-complete signal gets emitted when the greeter has completed authentication.

Call lightdm_greeter_get_is_authenticated() to check if the authentication was successful.

Parameters

greeter

A LightDMGreeter

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “autologin-timer-expired” signal

void
user_function (LightDMGreeter *greeter,
               gpointer        user_data)

The ::timed-login signal gets emitted when the automatic login timer has expired. The application should then call lightdm_greeter_authenticate_autologin().

Parameters

greeter

A LightDMGreeter

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “idle” signal

void
user_function (LightDMGreeter *greeter,
               gpointer        user_data)

The ::idle signal gets emitted when the user has logged in and the greeter is no longer needed.

This signal only matters if the greeter has marked itself as resettable using lightdm_greeter_set_resettable().

Parameters

greeter

A LightDMGreeter

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “reset” signal

void
user_function (LightDMGreeter *greeter,
               gpointer        user_data)

The ::reset signal gets emitted when the user is returning to a greeter that was previously marked idle.

This signal only matters if the greeter has marked itself as resettable using lightdm_greeter_set_resettable().

Parameters

greeter

A LightDMGreeter

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “show-message” signal

void
user_function (LightDMGreeter    *greeter,
               gchar             *text,
               LightDMMessageType type,
               gpointer           user_data)

The ::show-message signal gets emitted when the greeter should show a message to the user.

Parameters

greeter

A LightDMGreeter

 

text

Message text

 

type

Message type

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “show-prompt” signal

void
user_function (LightDMGreeter   *greeter,
               gchar            *text,
               LightDMPromptType type,
               gpointer          user_data)

The ::show-prompt signal gets emitted when the greeter should show a prompt to the user. The given text should be displayed and an input field for the user to provide a response.

Call lightdm_greeter_respond() with the resultant input or lightdm_greeter_cancel_authentication() to abort the authentication.

Parameters

greeter

A LightDMGreeter

 

text

Prompt text

 

type

Prompt type

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last