X Keyboard Layout setting from ldm
Warren Togami <[email protected]>
| Newsgroups | gmane.linux.terminal-server.devel |
|---|---|
| Message-ID | <[email protected]> |
Attached is a preliminary implementation of X keyboard layout setting within ldm gtkgreet. The XKB* environment variables are already present in the greeter process, and it must be done here synchronously in order to guarantee that the keyboard layout is properly set before the user can type anything. Any comments on this patch or suggestions of how it can be improved? Otherwise I would like to commit this in ldm-trunk soon. Warren Togami [email protected] ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _____________________________________________________________________ Ltsp-developer mailing list. To un-subscribe, or change prefs, goto: https://lists.sourceforge.net/lists/listinfo/ltsp-developer For additional LTSP help, try #ltsp channel on irc.freenode.net
ldm-x-keyboard-layout.patch
(text/x-patch, 2.1 KB)
=== modified file 'gtkgreet/greeter.c'
--- gtkgreet/greeter.c 2008-04-01 15:21:56 +0000
+++ gtkgreet/greeter.c 2008-07-01 20:23:23 +0000
@@ -260,6 +260,74 @@
return;
}
+/*
+ * scopy()
+ *
+ * Copy a string. Used to move data in and out of our ldminfo structure.
+ * Note: if the source string is null, or points to a valid string of '\0',
+ * both result in a dest string length of 0.
+ */
+
+char *
+scopy(char *dest, char *source)
+{
+ if (!source)
+ *dest = '\0';
+ else {
+ strncpy(dest, source, MAXSTRSZ - 1);
+ *(dest + MAXSTRSZ - 1) = '\0'; /* ensure null termination */
+ }
+
+ return dest;
+}
+
+void
+setup_keyboard_layout()
+{
+ char *argv[32];
+ char layout[MAXSTRSZ];
+ char model[MAXSTRSZ];
+ char rules[MAXSTRSZ];
+ char options[MAXSTRSZ];
+ char variant[MAXSTRSZ];
+ int i = 0;
+ int pid;
+
+ argv[i++] = "/usr/bin/setxkbmap";
+ scopy(layout, getenv("XKBLAYOUT"));
+ if (! layout[0] == '\0') {
+ argv[i++] = "-layout";
+ argv[i++] = layout;
+ }
+ scopy(model, getenv("XKBMODEL"));
+ if (! model[0] == '\0') {
+ argv[i++] = "-model";
+ argv[i++] = model;
+ }
+ scopy(rules, getenv("XKBRULES"));
+ if (! rules[0] == '\0') {
+ argv[i++] = "-rules";
+ argv[i++] = rules;
+ }
+ scopy(options, getenv("XKBOPTIONS"));
+ if (! options[0] == '\0') {
+ argv[i++] = "-option";
+ argv[i++] = options;
+ }
+ scopy(variant, getenv("XKBVARIANT"));
+ if (! variant[0] == '\0') {
+ argv[i++] = "-variant";
+ argv[i++] = variant;
+ }
+ argv[i++] = NULL;
+
+ // Skip setxkbmap if no parameters were specified
+ if (i > 2) {
+ g_spawn_sync(NULL,argv,NULL,G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+ }
+ return;
+}
+
int
main(int argc, char *argv[])
{
@@ -447,6 +515,7 @@
g_stdout = g_io_channel_unix_new(STDOUT_FILENO);
g_io_add_watch(g_stdin, G_IO_IN, (GIOFunc) handle_command, g_stdin);
+ setup_keyboard_layout();
gtk_main();
return 0;