|
From: <mla...@us...> - 2006-12-17 08:50:27
|
Revision: 206
http://svn.sourceforge.net/g15daemon/?rev=206&view=rev
Author: mlampard
Date: 2006-12-17 00:50:27 -0800 (Sun, 17 Dec 2006)
Log Message:
-----------
add option to turn off keyboard backlight on exit, hopefully this will help users who have power on the usb bus when the pc is shutdown. Using uppercase -K or -KILL on the cmdline will activate. requires libg15 1.2 or svn.
Modified Paths:
--------------
trunk/g15daemon-wip/g15daemon/main.c
Modified: trunk/g15daemon-wip/g15daemon/main.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/main.c 2006-12-16 14:39:28 UTC (rev 205)
+++ trunk/g15daemon-wip/g15daemon/main.c 2006-12-17 08:50:27 UTC (rev 206)
@@ -49,6 +49,7 @@
/* all threads will exit if leaving >0 */
int leaving = 0;
+int keyboard_backlight_off_onexit = 0;
unsigned int g15daemon_debug = 0;
unsigned int cycle_key;
unsigned int client_handles_keys = 0;
@@ -238,6 +239,8 @@
void g15daemon_sighandler(int sig) {
switch(sig){
+ case SIGUSR1:
+ keyboard_backlight_off_onexit = 1;
case SIGINT:
case SIGQUIT:
leaving = 1;
@@ -274,6 +277,14 @@
printf("G15Daemon not running\n");
exit(0);
}
+ if (!strncmp(daemonargs, "-K",2) || !strncmp(daemonargs, "--KILL",6)) {
+ daemonpid = uf_return_running();
+ if(daemonpid>0) {
+ kill(daemonpid,SIGUSR1);
+ } else
+ printf("G15Daemon not running\n");
+ exit(0);
+ }
if (!strncmp(daemonargs, "-v",2) || !strncmp(daemonargs, "--version",9)) {
float lg15ver = LIBG15_VERSION;
printf("G15Daemon version %s - %s\n",VERSION,uf_return_running() >= 0 ?"Loaded & Running":"Not Running");
@@ -283,7 +294,13 @@
if (!strncmp(daemonargs, "-h",2) || !strncmp(daemonargs, "--help",6)) {
printf("G15Daemon version %s - %s\n",VERSION,uf_return_running() >= 0 ?"Loaded & Running":"Not Running");
- printf("%s -h (--help) or -k (--kill) or -s (--switch) or -d (--debug) or -v (--version)\n\n -k will kill a previous incarnation,\n -h shows this help\n -s changes the screen-switch key from MR to L1\n -d debug mode - stay in foreground and output all debug messages to STDERR\n -v show version\n",argv[0]);
+ printf("%s -h (--help) or -k (--kill) or -s (--switch) or -d (--debug) or -v (--version)\n\n -k will kill a previous incarnation",argv[0]);
+ #ifdef LIBG15_VERSION
+ #if LIBG15_VERSION >= 1200
+ printf(", if uppercase -K or -KILL turn off the keyboard backlight on the way out.");
+ #endif
+ #endif
+ printf("\n -h shows this help\n -s changes the screen-switch key from MR to L1\n -d debug mode - stay in foreground and output all debug messages to STDERR\n -v show version\n");
exit(0);
}
@@ -319,11 +336,11 @@
libg15Debug(g15daemon_debug);
/* init stuff here.. */
- if((retval=initLibG15())==G15_ERROR_OPENING_USB_DEVICE){
+ if((retval=initLibG15())!=G15_NO_ERROR){
g15daemon_log(LOG_ERR,"Unable to attach to the G15 Keyboard... exiting");
exit(1);
}
-
+
if(!g15daemon_debug)
daemon(0,0);
@@ -350,7 +367,12 @@
setLCDContrast(1);
setLEDs(0);
setLCDBrightness(1);
-
+
+#ifdef LIBG15_VERSION
+#if LIBG15_VERSION >= 1200
+ setKBBrightness(1);
+#endif
+#endif
/* initialise the linked list */
lcdlist = ll_lcdlist_init();
lcdlist->nobody = nobody;
@@ -407,6 +429,7 @@
new_action.sa_flags = 0;
sigaction(SIGINT, &new_action, NULL);
sigaction(SIGQUIT, &new_action, NULL);
+ sigaction(SIGUSR1, &new_action, NULL);
do {
sleep(1);
@@ -420,6 +443,14 @@
/* switch off the lcd backlight */
setLCDBrightness(0);
#ifdef LIBG15_VERSION
+#if LIBG15_VERSION >= 1200
+ /* if SIGUSR1 was sent to kill us, switch off the keyboard backlight as well */
+ if(keyboard_backlight_off_onexit==1)
+ setKBBrightness(0);
+#endif
+#endif
+
+#ifdef LIBG15_VERSION
#if LIBG15_VERSION >= 1100
exitLibG15();
#endif
@@ -427,8 +458,8 @@
ll_lcdlist_destroy(&lcdlist);
exitnow:
- /* return to root privilages for the final countdown */
- seteuid(0);
+ /* return to root privilages for the final countdown */
+ seteuid(0);
setegid(0);
closelog();
uf_conf_write(lcdlist,"/etc/g15daemon.conf");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|