[ltp] Re: Fn-Keys R40
Mika Fischer
linux-thinkpad@linux-thinkpad.org
Mon, 26 Apr 2004 12:27:15 +0200
--nextPart6613340.9yauZnLUsd
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8Bit
Reinhard Tartler wrote:
> Fn+5 is not working correctly even when booting windows xp. ;)
It does here...
Attached is also a patch to tpb that enables use of the button under linux.
You can then write a little script that does ifup/ifdown or whatever you
deem apropriate :)
This will also be in the next official release of tpb.
To Tobias: The button is supposed to switch the wireless interface on/off.
Cheers,
Mika
--nextPart6613340.9yauZnLUsd
Content-Type: text/x-diff; name="tpb-0.6.1-wireless-button.patch"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="tpb-0.6.1-wireless-button.patch"
diff -ruN tpb-0.6.1/doc/nvram.txt tpb-0.6.1-wireless/doc/nvram.txt
--- tpb-0.6.1/doc/nvram.txt 2003-08-10 23:00:11.000000000 +0200
+++ tpb-0.6.1-wireless/doc/nvram.txt 2004-03-25 22:22:16.000000000 +0100
@@ -35,11 +35,11 @@
byte 0x3f-0x44 RTC appointment (date/time/...)
byte 0x56: xxxx xxxx
- |||
- ||+--> toggle if home button pressed
- |+---> toggle if search button pressed
- +----> toggle if mail button pressed
-
+ | |||
+ | ||+--> toggle if home button pressed
+ | |+---> toggle if search button pressed
+ | +----> toggle if mail button pressed
+ +--------> toggle if wireless button pressed
byte 0x57: xxxx xxxx
|||| ||||
|||| |||+--> toggle if battery is inserted and charge changes
diff -ruN tpb-0.6.1/man/tpb.1 tpb-0.6.1-wireless/man/tpb.1
--- tpb-0.6.1/man/tpb.1 2004-01-19 10:51:20.000000000 +0100
+++ tpb-0.6.1-wireless/man/tpb.1 2004-03-25 22:29:35.000000000 +0100
@@ -68,6 +68,10 @@
String with command and options that should be executed when Mail button is
pressed. By default no command is executed.
.TP 8
+.B \-W, \-\-wireless=CMD
+String with command and options that should be executed when Wireless button is
+pressed. By default no command is executed.
+.TP 8
.B \-C, \-\-callback=CMD
String with command and options that should be executed each button press and state change.
tpb passes an identifier as first argument and the new state as second argument to the callback.
diff -ruN tpb-0.6.1/src/cfg.c tpb-0.6.1-wireless/src/cfg.c
--- tpb-0.6.1/src/cfg.c 2003-12-26 21:00:35.000000000 +0100
+++ tpb-0.6.1-wireless/src/cfg.c 2004-03-25 22:28:47.000000000 +0100
@@ -193,15 +193,16 @@
{"home", 1, NULL, 'H'},
{"search", 1, NULL, 'S'},
{"mail", 1, NULL, 'M'},
+ {"wireless", 1, NULL, 'W'},
{"xevents", 1, NULL, 'x'},
{"verbose", 0, NULL, 'v'},
{NULL, 0, NULL, 0}
};
#ifdef HAVE_LIBXOSD
- next_option = getopt_long (argc, argv, "hdA:P:c:C:m:o:p:t:H:S:M:x:v", long_options, &option_index);
+ next_option = getopt_long (argc, argv, "hdA:P:c:C:m:o:p:t:H:S:M:W:x:v", long_options, &option_index);
#else /* HAVE_LIBXOSD */
- next_option = getopt_long (argc, argv, "hdA:P:c:C:m:p:t:H:S:M:x:v", long_options, &option_index);
+ next_option = getopt_long (argc, argv, "hdA:P:c:C:m:p:t:H:S:M:W:x:v", long_options, &option_index);
#endif /* HAVE_LIBXOSD */
if (next_option == -1) {
@@ -267,6 +268,10 @@
set_value(CFG_MAIL, optarg, &cmd_cfg);
break;
+ case 'W':
+ set_value(CFG_WIRELESS, optarg, &cmd_cfg);
+ break;
+
case 'x':
set_value(CFG_XEVENTS, optarg, &cmd_cfg);
break;
@@ -341,6 +346,12 @@
}
cfg->mail_cmd = NULL;
+ /* cfg->wireless_cmd */
+ if(cfg->wireless_cmd != NULL) {
+ free(cfg->wireless_cmd);
+ }
+ cfg->wireless_cmd = NULL;
+
/* cfg->favorites_cmd */
if(cfg->favorites_cmd != NULL) {
free(cfg->favorites_cmd);
@@ -490,6 +501,9 @@
/* cfg->mail_cmd */
cfg->mail_cmd = NULL;
+ /* cfg->wireless_cmd */
+ cfg->wireless_cmd = NULL;
+
/* cfg->favorites_cmd */
cfg->favorites_cmd = NULL;
@@ -595,6 +609,11 @@
free(cfg->mail_cmd);
}
+ /* cfg->wireless_cmd */
+ if(cfg->wireless_cmd != NULL) {
+ free(cfg->wireless_cmd);
+ }
+
/* cfg->favorites_cmd */
if(cfg->favorites_cmd != NULL) {
free(cfg->favorites_cmd);
@@ -719,6 +738,14 @@
slave->mail_cmd = strdup(master->mail_cmd);
}
+ /* cfg->wireless_cmd */
+ if(master->wireless_cmd != NULL) {
+ if(slave->wireless_cmd != NULL) {
+ free(slave->wireless_cmd);
+ }
+ slave->wireless_cmd = strdup(master->wireless_cmd);
+ }
+
/* cfg->favorites_cmd */
if(master->favorites_cmd != NULL) {
if(slave->favorites_cmd != NULL) {
@@ -1000,6 +1027,16 @@
}
} /* }}} */
+ else if (strcmp(CFG_WIRELESS, key) == 0) { /* {{{ */
+ if(cfg->wireless_cmd != NULL) {
+ free(cfg->wireless_cmd);
+ }
+ if((cfg->wireless_cmd = strdup(arg)) == NULL) {
+ fputs(_("Not enough memory"), stderr);
+ _exit(1);
+ }
+ } /* }}} */
+
else if (strcmp(CFG_FAVORITES, key) == 0) { /* {{{ */
if(cfg->favorites_cmd != NULL) {
free(cfg->favorites_cmd);
@@ -1328,6 +1365,7 @@
printf(_(" -H, --home=CMD command and options for Home button [none]\n"));
printf(_(" -S, --search=CMD command and options for Search button [none]\n"));
printf(_(" -M, --mail=CMD command and options for Mail button [none]\n"));
+ printf(_(" -W, --wireless=CMD command and options for Wireless button [none]\n"));
printf(_(" -C, --callback=CMD string with command that should be executed for each\n"));
printf(_(" pressed button. It is called with pressed button as\n"));
printf(_(" first argument and new state as second [none]\n"));
diff -ruN tpb-0.6.1/src/cfg.h tpb-0.6.1-wireless/src/cfg.h
--- tpb-0.6.1/src/cfg.h 2003-12-26 21:00:35.000000000 +0100
+++ tpb-0.6.1-wireless/src/cfg.h 2004-03-25 22:26:43.000000000 +0100
@@ -84,6 +84,7 @@
#define CFG_HOME "home"
#define CFG_SEARCH "search"
#define CFG_MAIL "mail"
+#define CFG_WIRELESS "wireless"
#define CFG_FAVORITES "favorites"
#define CFG_RELOAD "reload"
#define CFG_ABORT "abort"
@@ -135,6 +136,7 @@
char *home_cmd;
char *search_cmd;
char *mail_cmd;
+ char *wireless_cmd;
char *favorites_cmd;
char *reload_cmd;
char *abort_cmd;
diff -ruN tpb-0.6.1/src/tpb.c tpb-0.6.1-wireless/src/tpb.c
--- tpb-0.6.1/src/tpb.c 2003-12-26 21:00:35.000000000 +0100
+++ tpb-0.6.1-wireless/src/tpb.c 2004-03-25 22:26:11.000000000 +0100
@@ -274,6 +274,25 @@
}
} /* }}} */
+ /* determine the state of the wireless button {{{ */
+ if(thinkpad_state.wireless_toggle != last_thinkpad_state.wireless_toggle &&
+ thinkpad_state.hibernate_toggle == last_thinkpad_state.hibernate_toggle) {
+ if(cfg.verbose == STATE_ON) {
+ puts(_("Wireless button pressed"));
+ }
+ if(cfg.wireless_cmd != NULL) {
+ if(fork_app(cfg.wireless_cmd) != 0) {
+ _exit(0);
+ }
+ }
+ if(cfg.callback != NULL) {
+ snprintf(callback_cmd, sizeof(callback_cmd), "%s wireless pressed", cfg.callback);
+ if(fork_app(callback_cmd) != 0) {
+ _exit(0);
+ }
+ }
+ } /* }}} */
+
/* determine the state of the favorites button {{{ */
if(thinkpad_state.favorites_toggle != last_thinkpad_state.favorites_toggle) {
if(cfg.verbose == STATE_ON) {
@@ -954,6 +973,7 @@
thinkpad_state->home_toggle = (thinkpad_state->home_toggle & ~0x01) | (( buffer[0x56] & 0x01) );
thinkpad_state->search_toggle = (thinkpad_state->search_toggle & ~0x01) | (( buffer[0x56] & 0x02) >> 1);
thinkpad_state->mail_toggle = (thinkpad_state->mail_toggle & ~0x01) | (( buffer[0x56] & 0x04) >> 2);
+ thinkpad_state->wireless_toggle = (thinkpad_state->wireless_toggle & ~0x01) | (( buffer[0x56] & 0x20) >> 5);
thinkpad_state->thinklight_toggle = (thinkpad_state->thinklight_toggle & ~0x01) | (( buffer[0x58] & 0x10) >> 4);
thinkpad_state->hibernate_toggle = (thinkpad_state->hibernate_toggle & ~0x01) | (( buffer[0x58] & 0x01) );
thinkpad_state->display_state = (( buffer[0x59] & 0x03) );
diff -ruN tpb-0.6.1/src/tpb.h tpb-0.6.1-wireless/src/tpb.h
--- tpb-0.6.1/src/tpb.h 2003-12-25 23:46:36.000000000 +0100
+++ tpb-0.6.1-wireless/src/tpb.h 2004-03-25 22:25:45.000000000 +0100
@@ -50,6 +50,7 @@
unsigned int home_toggle; /* Home button */
unsigned int search_toggle; /* Search button */
unsigned int mail_toggle; /* Mail button */
+ unsigned int wireless_toggle; /* Wireless Button */
unsigned int favorites_toggle; /* Favorites button */
unsigned int reload_toggle; /* Reload button */
unsigned int abort_toggle; /* Abort button */
--nextPart6613340.9yauZnLUsd--