2009-11-02 05:38:10 +00:00
|
|
|
#
|
|
|
|
# Description: Get default keyboard layout from hal
|
|
|
|
# Ubuntu: https://bugs.launchpad.net/bugs/395103
|
|
|
|
# Fedora: http://cvs.fedoraproject.org/viewvc//devel/gdm/gdm-system-keyboard.patch?view=markup
|
|
|
|
#
|
|
|
|
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/configure.ac gdm-2.28.0.new/configure.ac
|
|
|
|
--- gdm-2.28.0/configure.ac 2009-09-21 22:06:40.000000000 +0200
|
|
|
|
+++ gdm-2.28.0.new/configure.ac 2009-10-01 12:35:50.345762314 +0200
|
|
|
|
@@ -70,6 +70,7 @@
|
2009-02-21 04:17:16 +00:00
|
|
|
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
|
|
|
|
gobject-2.0 >= $GLIB_REQUIRED_VERSION
|
2009-11-02 05:38:10 +00:00
|
|
|
gio-2.0 >= $GLIB_REQUIRED_VERSION
|
|
|
|
+ hal
|
2009-02-21 04:17:16 +00:00
|
|
|
)
|
|
|
|
AC_SUBST(DAEMON_CFLAGS)
|
|
|
|
AC_SUBST(DAEMON_LIBS)
|
2009-11-02 05:38:10 +00:00
|
|
|
diff -Nur -x '*.orig' -x '*~' gdm-2.28.0/daemon/gdm-session-direct.c gdm-2.28.0.new/daemon/gdm-session-direct.c
|
|
|
|
--- gdm-2.28.0/daemon/gdm-session-direct.c 2009-09-21 22:05:27.000000000 +0200
|
|
|
|
+++ gdm-2.28.0.new/daemon/gdm-session-direct.c 2009-10-01 12:34:43.000000000 +0200
|
2009-02-21 04:17:16 +00:00
|
|
|
@@ -45,6 +45,8 @@
|
|
|
|
#include <dbus/dbus-glib.h>
|
|
|
|
#include <dbus/dbus-glib-lowlevel.h>
|
|
|
|
|
|
|
|
+#include <libhal.h>
|
|
|
|
+
|
|
|
|
#include "gdm-session-direct.h"
|
|
|
|
#include "gdm-session.h"
|
|
|
|
#include "gdm-session-private.h"
|
2009-11-02 05:38:10 +00:00
|
|
|
@@ -598,14 +600,87 @@
|
2008-10-20 16:16:24 +00:00
|
|
|
return setlocale (LC_MESSAGES, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static char *
|
2009-02-21 04:17:16 +00:00
|
|
|
+get_system_default_layout (GdmSessionDirect *session)
|
2008-10-20 16:16:24 +00:00
|
|
|
+{
|
2009-02-21 04:17:16 +00:00
|
|
|
+ DBusConnection *connection;
|
|
|
|
+ LibHalContext *ctx;
|
|
|
|
+ char **devices;
|
|
|
|
+ int n_devices;
|
|
|
|
+ char *layout;
|
2009-11-02 05:38:10 +00:00
|
|
|
+ char *variant;
|
2008-10-20 16:16:24 +00:00
|
|
|
+ char *result;
|
|
|
|
+
|
|
|
|
+ result = NULL;
|
2009-02-21 04:17:16 +00:00
|
|
|
+
|
|
|
|
+ connection = dbus_g_connection_get_connection (session->priv->connection);
|
|
|
|
+ ctx = libhal_ctx_new ();
|
|
|
|
+ libhal_ctx_set_dbus_connection (ctx, connection);
|
|
|
|
+
|
|
|
|
+ if (!libhal_ctx_init (ctx, NULL)) {
|
|
|
|
+ goto out;
|
2008-10-20 16:16:24 +00:00
|
|
|
+ }
|
|
|
|
+
|
2009-02-21 04:17:16 +00:00
|
|
|
+ devices = libhal_find_device_by_capability (ctx,
|
|
|
|
+ "input.keyboard",
|
|
|
|
+ &n_devices,
|
|
|
|
+ NULL);
|
|
|
|
+ if (n_devices > 0) {
|
|
|
|
+ layout = libhal_device_get_property_string (ctx,
|
|
|
|
+ devices[0],
|
2009-02-25 03:56:44 +00:00
|
|
|
+ "input.x11_options.XkbLayout",
|
2009-02-21 04:17:16 +00:00
|
|
|
+ NULL);
|
2009-02-25 03:56:44 +00:00
|
|
|
+ if (!layout) {
|
|
|
|
+ layout = libhal_device_get_property_string (ctx,
|
|
|
|
+ devices[0],
|
|
|
|
+ "input.xkb.layout",
|
|
|
|
+ NULL);
|
|
|
|
+ }
|
2009-11-02 05:38:10 +00:00
|
|
|
+ if (!layout)
|
|
|
|
+ goto out;
|
|
|
|
+
|
|
|
|
+ variant = libhal_device_get_property_string (ctx,
|
|
|
|
+ devices[0],
|
|
|
|
+ "input.x11_options.XkbVariant",
|
|
|
|
+ NULL);
|
|
|
|
+ if (!variant) {
|
|
|
|
+ variant = libhal_device_get_property_string (ctx,
|
|
|
|
+ devices[0],
|
|
|
|
+ "input.xkb.variant",
|
|
|
|
+ NULL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (variant != NULL && variant[0] != '\0') {
|
|
|
|
+ result = g_strdup_printf("%s\t%s", layout, variant);
|
|
|
|
+ libhal_free_string (variant);
|
|
|
|
+ } else {
|
|
|
|
+ result = g_strdup (layout);
|
|
|
|
+ }
|
|
|
|
+ libhal_free_string (layout);
|
2009-02-21 04:17:16 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ libhal_free_string_array (devices);
|
|
|
|
+
|
|
|
|
+ libhal_ctx_shutdown (ctx, NULL);
|
|
|
|
+ libhal_ctx_free (ctx);
|
|
|
|
+
|
|
|
|
+out:
|
2008-10-20 16:16:24 +00:00
|
|
|
+ if (!result) {
|
|
|
|
+ result = g_strdup ("us");
|
|
|
|
+ }
|
|
|
|
+
|
2009-11-02 05:38:10 +00:00
|
|
|
+ g_debug ("GdmSessionDirect: System default keyboard layout: '%s'", result);
|
2008-10-20 16:16:24 +00:00
|
|
|
+ return result;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static const char *
|
|
|
|
get_default_layout_name (GdmSessionDirect *session)
|
|
|
|
{
|
|
|
|
- if (session->priv->saved_layout != NULL) {
|
|
|
|
- return session->priv->saved_layout;
|
2009-11-02 05:38:10 +00:00
|
|
|
+ if (!session->priv->saved_layout) {
|
2009-02-21 04:17:16 +00:00
|
|
|
+ session->priv->saved_layout = get_system_default_layout (session);
|
2008-10-20 16:16:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- return "us";
|
|
|
|
+ return session->priv->saved_layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|