summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in9
-rw-r--r--fdi/policy/10osvendor/10-laptop-buttons.fdi20
-rw-r--r--fdi/policy/10osvendor/10-toshiba-buttons.fdi15
-rw-r--r--fdi/policy/10osvendor/Makefile.am2
-rw-r--r--hald/linux/addons/addon-acpi.c100
5 files changed, 129 insertions, 17 deletions
diff --git a/configure.in b/configure.in
index 009624e6..58dfec01 100644
--- a/configure.in
+++ b/configure.in
@@ -168,6 +168,14 @@ fi
AC_SUBST(ACPI_PROC)
AM_CONDITIONAL(ACPI_PROC, test x$acpi_proc = xyes)
+AC_ARG_ENABLE([acpi-ibm], AC_HELP_STRING([--enable-acpi-ibm], [catch IBM ACPI events]), [acpi_ibm=$enableval], [acpi_ibm=no])
+if test "x$acpi_proc" = "xyes" ; then
+ AC_DEFINE(ACPI_IBM_EVENTS,1,[catch and forward IBM ACPI hotkey and button events])
+fi
+AC_SUBST(ACPI_IBM_EVENTS)
+AM_CONDITIONAL(ACPI_IBM_EVENTS, test x$acpi_ibm = xyes)
+
+
dnl libparted
AC_ARG_ENABLE([parted], AC_HELP_STRING([--enable-parted], [Use libparted]), [use_parted=$enableval], [use_parted=no])
@@ -927,6 +935,7 @@ echo "
Macbook Pro utils: ${BUILD_MACBOOKPRO} (Linux only, x86 only, requires libpci)
OMAP utils: ${BUILD_OMAP} (Linux only, arm only)
CPU frequency scaling: ${BUILD_CPUFREQ} (Linux only)
+ catch IBM acpi events: ${acpi_ibm} (Linux only)
USB wireless mouse power: ${BUILD_USBCSR} (Linux only, requires libusb)
Dell Backlight: ${BUILD_DELL} (Linux only, requires libsmbios >= 0.13.4)
diff --git a/fdi/policy/10osvendor/10-laptop-buttons.fdi b/fdi/policy/10osvendor/10-laptop-buttons.fdi
new file mode 100644
index 00000000..ee7cd0bf
--- /dev/null
+++ b/fdi/policy/10osvendor/10-laptop-buttons.fdi
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deviceinfo version="0.2">
+
+ <device>
+ <match key="system.formfactor" string="laptop">
+ <!-- Only launch the addon for Toshiba laptops. -->
+ <match key="system.hardware.vendor" string="TOSHIBA">
+ <append key="info.addons" type="strlist">hald-addon-acpi-buttons-toshiba</append>
+ <append key="info.capabilities" type="strlist">button</append>
+ </match>
+
+ <!-- button capability for IBM laptops -->
+ <match key="system.hardware.vendor" string="IBM">
+ <append key="info.capabilities" type="strlist">button</append>
+ </match>
+ </match>
+ </device>
+
+</deviceinfo>
diff --git a/fdi/policy/10osvendor/10-toshiba-buttons.fdi b/fdi/policy/10osvendor/10-toshiba-buttons.fdi
deleted file mode 100644
index d60bee2a..00000000
--- a/fdi/policy/10osvendor/10-toshiba-buttons.fdi
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<deviceinfo version="0.2">
-
- <!-- Only launch the addon for Toshiba laptops. -->
- <device>
- <match key="system.hardware.vendor" string="TOSHIBA">
- <match key="system.formfactor" string="laptop">
- <append key="info.addons" type="strlist">hald-addon-acpi-buttons-toshiba</append>
- <append key="info.capabilities" type="strlist">button</append>
- </match>
- </match>
- </device>
-
-</deviceinfo>
diff --git a/fdi/policy/10osvendor/Makefile.am b/fdi/policy/10osvendor/Makefile.am
index 98bbe927..d60d5b3b 100644
--- a/fdi/policy/10osvendor/Makefile.am
+++ b/fdi/policy/10osvendor/Makefile.am
@@ -4,7 +4,7 @@ fdidir = $(datadir)/hal/fdi/policy/10osvendor
dist_fdi_DATA = \
10-keyboard-policy.fdi \
10-power-mgmt-policy.fdi \
- 10-toshiba-buttons.fdi \
+ 10-laptop-buttons.fdi \
10-rfkill-switch.fdi \
10-laptop-panel-mgmt-policy.fdi \
15-storage-luks.fdi \
diff --git a/hald/linux/addons/addon-acpi.c b/hald/linux/addons/addon-acpi.c
index f0561caf..dd27e9c6 100644
--- a/hald/linux/addons/addon-acpi.c
+++ b/hald/linux/addons/addon-acpi.c
@@ -89,6 +89,99 @@ acpi_get_event_fp_acpid (void)
}
#endif
+#ifdef ACPI_IBM_EVENTS
+static void
+handle_ibm_acpi_events (LibHalContext *ctx, int type, int event)
+{
+ DBusError error;
+ char udi[256];
+ char *button;
+ char **devices;
+ int num_devices;
+
+ dbus_error_init (&error);
+ button = NULL;
+ snprintf (udi, sizeof (udi), "/org/freedesktop/Hal/devices/computer");
+
+ if (type == 128) {
+ switch (event) {
+ case 4097: /* Fn+F1 */
+ button = "Fn+F1";
+ break;
+ case 4098:
+ button = "Fn+F2";
+ break;
+ case 4099: /* dpms off */
+ button = "display_off";
+ break;
+ case 4100: /* sleep button */
+ button = "sleep";
+ devices = libhal_manager_find_device_string_match (ctx, "button.type",
+ "sleep", &num_devices,
+ &error);
+ if (devices != NULL && num_devices > 0) {
+ snprintf (udi, sizeof (udi), devices[0]);
+ libhal_free_string_array (devices);
+ }
+ if (dbus_error_is_set (&error))
+ dbus_error_free (&error);
+ break;
+ case 4101: /* wireless */
+ button = "wifi-power";
+ break;
+ case 4102:
+ button = "Fn+F6";
+ break;
+ case 4103: /* switch display */
+ button = "display_switch";
+ break;
+ case 4104:
+ button = "Fn+F8";
+ break;
+ case 4105: /* undock */
+ button = "undock";
+ break;
+ case 4106:
+ button = "Fn+F10";
+ break;
+ case 4107:
+ button = "Fn+F11";
+ break;
+ case 4108: /* Fn+F12 , hibernate/s2disk */
+ button = "hibernate";
+ break;
+ case 4109: /* Fn+Backspace*/
+ button = "Fn+Backspace";
+ break;
+ case 4110: /* Fn+Insert*/
+ button = "Fn=Insert";
+ break;
+ case 4111: /* Fn+Delete*/
+ button = "Fn+Delete";
+ break;
+ case 4112: /* Fn+Home*/
+ button = "brightness-up";
+ break;
+ case 20489: /* Tablet rotated */
+ button = "tabletpc_rotate_180";
+ break;
+ case 20490: /* Tablet rotated back*/
+ button = "tabletpc_rotate_normal";
+ break;
+ default:
+ break;
+
+ }
+
+ if (button) {
+ libhal_device_emit_condition (ctx, udi, "ButtonPressed",
+ button, &error);
+ if (dbus_error_is_set (&error))
+ dbus_error_free (&error);
+ }
+ }
+}
+#endif
static void
main_loop (LibHalContext *ctx, FILE *eventfp)
@@ -137,7 +230,12 @@ main_loop (LibHalContext *ctx, FILE *eventfp)
HAL_DEBUG (("battery event"));
dbus_error_init (&error);
libhal_device_rescan (ctx, udi, &error);
- }
+#ifdef ACPI_IBM_EVENTS
+ } else if (strncmp (acpi_path, "ibm/hotkey", sizeof ("ibm/hotkey") -1) == 0) {
+ /* handle ibm ACPI hotkey events*/
+ handle_ibm_acpi_events(ctx, acpi_num1, acpi_num2);
+#endif
+ }
} else {
HAL_DEBUG (("cannot parse event"));