--- addon-dell-backlight.cpp.orig 2008-03-01 23:56:50.148970029 +0100 +++ addon-dell-backlight.cpp 2008-03-01 23:57:04.877632038 +0100 @@ -184,10 +184,34 @@ } /* Mechanism to ensure that we always set the AC brightness when we are on AC-power etc. */ - AC = libhal_device_get_property_bool (halctx, + if (libhal_device_exists (halctx, "/org/freedesktop/Hal/devices/acpi_AC", NULL)) + { + AC = libhal_device_get_property_bool (halctx, "/org/freedesktop/Hal/devices/acpi_AC", "ac_adapter.present", &err); + } + else if (libhal_device_exists (halctx, "/org/freedesktop/Hal/devices/computer_power_supply", NULL)) + { + /* Found on Dell Inspiron 1501 */ + AC = libhal_device_get_property_bool (halctx, + "/org/freedesktop/Hal/devices/computer_power_supply", + "ac_adapter.present", + &err); + } + else + { + /* If we don't know, always use battery (arbitrary choice) */ + HAL_DEBUG (("Cannot determine AC status, ac_adapter.present not found")); + AC = FALSE; + } + + /* Free err if set before re-using */ + if (dbus_error_is_set (&err)) { + HAL_DEBUG (("Error determining AC status: %s", err.message)); + dbus_error_free (&err); + AC = FALSE; + } if (dbus_message_is_method_call (message, "org.freedesktop.Hal.Device.LaptopPanel",