Patch that allows remote control global backlight

[email protected]
Newsgroups gmane.comp.sysutils.lcdproc
Message-ID <2915063.EjQBpvbtGX@penguin>
Hello everyone!

I created a patch that allows to control the global server backlight option 
using the client protocol: 

server_backlight {on|off|open|toggle}

When reading throught the archives, I found that a remote control interface 
for lcdproc settings was discussed a few years ago. 

In my opinion it would be realy cool to have it :-)
I use lcdproc on my media server that is always running. 
With that patch i'm able to switch the lcd backlight on when switching on the 
tv.

The patch is not perfect as the options menu is not updated. 
(I didn't find a way without making the option menu globally available. Any 
tipps?)

It would also be cool to add other commands like 
- screen_goto 
- screen_next
- screen_prev

What do you think. Any chances that it'll make it to the trunk? Maybe with an
compiler option or flag in the server config to enable / disable it.

Thanks,
Christian

_______________________________________________
LCDproc mailing list
[email protected]
http://lists.omnipotent.net/mailman/listinfo/lcdproc
0001-patch-backlight.patch (text/x-patch, 2.6 KB)
? patch.txt
Index: server/commands/command_list.c
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/commands/command_list.c,v
retrieving revision 1.10
diff -u -r1.10 command_list.c
--- server/commands/command_list.c	5 Jan 2011 23:34:37 -0000	1.10
+++ server/commands/command_list.c	12 Sep 2011 19:33:40 -0000
@@ -50,6 +50,8 @@
 	{ "info",           info_func           },
 	{ "sleep",          sleep_func          },
 	{ "bye",            bye_func            },
+	/* Remote control commands*/
+	{ "server_backlight", server_backlight_func},
 	{ NULL,             NULL},
 };
 
Index: server/commands/server_commands.c
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/commands/server_commands.c,v
retrieving revision 1.9
diff -u -r1.9 server_commands.c
--- server/commands/server_commands.c	5 Jan 2011 23:34:37 -0000	1.9
+++ server/commands/server_commands.c	12 Sep 2011 19:33:40 -0000
@@ -180,3 +180,42 @@
 	sock_send_string(c->sock, "noop complete\n");
 	return 0;
 }
+
+/**
+ * Controls the servers master backlight settings.
+ * 
+ * This allows a client to control the server's master backlight setting.
+ * This is usefull to remote control the backlight e.g. in scripts.
+ *
+ *\verbatim
+ * Usage: server_backlight {on|off|open|toggle}
+ *\endverbatim
+ */
+int 
+server_backlight_func(Client *c, int argc, char **argv)
+{
+    if (argc != 2) {
+        sock_send_error(c->sock, "Usage: server_backlight {on|off|open|toggle}\n");
+        return 0;
+    }
+
+    if (strcmp ("on", argv[1]) == 0) {
+        backlight = BACKLIGHT_ON;
+    }   
+    else if (strcmp ("off", argv[1]) == 0) {
+        backlight = BACKLIGHT_OFF;
+    }
+	else if (strcmp ("open", argv[1]) == 0) {
+		backlight = BACKLIGHT_OPEN;
+	}
+    else if (strcmp ("toggle", argv[1]) == 0) {
+        if (backlight == BACKLIGHT_ON)
+            backlight = BACKLIGHT_OFF;
+        else if (backlight == BACKLIGHT_OFF)
+            backlight = BACKLIGHT_ON;
+    }
+
+	sock_send_string(c->sock, "success\n");
+	return 0;
+}
+
Index: server/commands/server_commands.h
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/commands/server_commands.h,v
retrieving revision 1.5
diff -u -r1.5 server_commands.h
--- server/commands/server_commands.h	5 Jan 2011 23:34:37 -0000	1.5
+++ server/commands/server_commands.h	12 Sep 2011 19:33:40 -0000
@@ -18,4 +18,6 @@
 int info_func(Client *c, int argc, char **argv);
 int sleep_func(Client *c, int argc, char **argv);
 
+int server_backlight_func(Client *c, int argc, char **argv);
+
 #endif
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.