summaryrefslogtreecommitdiff
path: root/tests/src/test-script-hook.c
blob: 56c43ef64a1ecc2d6d0bbbf0753c82dffd8faaac (plain)
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
#include <stdlib.h>
#include <glib.h>
#include <glib-object.h>

#include "status.h"

static GKeyFile *config;

int
main (int argc, char **argv)
{
#if !defined(GLIB_VERSION_2_36)
    g_type_init ();
#endif

    status_connect (NULL, NULL);

    config = g_key_file_new ();
    g_key_file_load_from_file (config, g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), G_KEY_FILE_NONE, NULL);

    if (argc < 2)
    {
        g_printerr ("Usage: %s text [return-value]\n", argv[0]);
        return EXIT_FAILURE;
    }

    g_autoptr(GString) status_text = g_string_new ("SCRIPT-HOOK");
    g_string_append_printf (status_text, " %s", argv[1]);
    if (g_getenv ("XDG_SEAT"))
        g_string_append_printf (status_text, " XDG_SEAT=%s", g_getenv ("XDG_SEAT"));
    if (g_getenv ("USER"))
        g_string_append_printf (status_text, " USER=%s", g_getenv ("USER"));
    status_notify ("%s", status_text->str);

    if (argc > 2)
        return atoi (argv[2]);
    else
        return EXIT_SUCCESS;
}