Enable numlock in ldm greeter

"Leo Eraly" <[email protected]>
Newsgroups gmane.linux.terminal-server.devel
Message-ID <[email protected]>
 Hi,

I noticed that numlock is not enabled (or turned off) when LDM starts.

Yesterday I discussed this behavior on IRC and some people agreed that it
would be ok to include a setting which makes
this configurable via lts.conf

Attached is a patch to greeter.c to allow this.
It will check lts.conf for a NUM_LOCK settings (which is a boolean), if it
is set to true numlockx on will be started.

Since I'm not an experienced (C) programmer It's possible that it still
contains some undocumented features/bugs ;-)


Feedback is appreciated.



Leo

-------------------------------------------------------------------------
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
greeter.c.patch (text/x-patch, 861 B)
=== modified file 'gtkgreet/greeter.c'
--- gtkgreet/greeter.c	2008-07-01 21:53:04 +0000
+++ gtkgreet/greeter.c	2008-07-09 10:42:23 +0000
@@ -328,6 +328,35 @@
     return;
 }
 
+void
+enable_numlock()
+{
+	char *argv[32];
+	int i=0;
+	int numlock;
+
+	numlock=ldm_getenv_bool("NUM_LOCK");
+
+	if(access("/usr/bin/numlockx" , X_OK)) {	
+		argv[i++] = "/usr/bin/numlockx";
+	
+		if(numlock) 
+			argv[i++] = "on";
+		else
+			argv[i++] = "off";
+
+		argv[i++] = NULL;
+
+		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[])
 {
@@ -516,6 +545,7 @@
     g_io_add_watch(g_stdin, G_IO_IN, (GIOFunc) handle_command, g_stdin);
 
     setup_keyboard_layout();
+	enable_numlock();
     gtk_main();
 
     return 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.