2 * Copyright (C) 2010-2011 Robert Ancell.
3 * Author: Robert Ancell <robert.ancell@canonical.com>
5 * This program is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option) any later
8 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
15 #include <glib/gstdio.h>
18 #include <sys/ioctl.h>
24 #include "configuration.h"
26 static GList *used_vts = NULL;
33 fd = g_open ("/dev/console", O_RDONLY | O_NOCTTY);
35 g_warning ("Error opening /dev/console: %s", strerror (errno));
46 /* Pretend always active */
50 console_fd = open_console ();
53 struct vt_stat console_state = { 0 };
54 if (ioctl (console_fd, VT_GETSTATE, &console_state) < 0)
55 g_warning ("Error using VT_GETSTATE on /dev/console: %s", strerror (errno));
57 active = console_state.v_active;
68 vt_set_active (gint number)
73 g_debug ("Activating VT %d", number);
75 /* Pretend always active */
79 console_fd = open_console ();
83 if (ioctl (console_fd, VT_ACTIVATE, n) < 0)
84 g_warning ("Error using VT_ACTIVATE %d on /dev/console: %s", n, strerror (errno));
91 vt_is_used (gint number)
95 for (link = used_vts; link; link = link->next)
97 int n = GPOINTER_TO_INT (link->data);
110 number = config_get_integer (config_get_instance (), "LightDM", "minimum-vt");
125 number = vt_get_min ();
126 while (vt_is_used (number))
129 used_vts = g_list_append (used_vts, GINT_TO_POINTER (number));
135 vt_release (gint number)
137 used_vts = g_list_remove (used_vts, GINT_TO_POINTER (link));