NetworkManager, ASUS led



Following up on this thread
http://lists.kde.org/?l=kde-devel&m=120099366404038&w=2

KDE's kwifimanager was explicitly patched to toggle the Wireless LED on/off on Asus notebooks. It seems that the function really belongs in NetworkManager instead. I patched my copy of NetworkManager 0.6.5 to add the function, the patch is attached. It's probably not the cleanest approach, but it works for me.

--
  -- Howard Chu
  Chief Architect, Symas Corp.  http://www.symas.com
  Director, Highland Sun        http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP     http://www.openldap.org/project/
diff -wur NetworkManager-0.6.5/src/nm-dbus-nm.c NetworkManager-0.6.5.N/src/nm-dbus-nm.c
--- NetworkManager-0.6.5/src/nm-dbus-nm.c	2007-04-18 11:13:06.000000000 -0700
+++ NetworkManager-0.6.5.N/src/nm-dbus-nm.c	2008-01-21 05:45:40.000000000 -0800
@@ -483,6 +483,9 @@
 	return (reply);
 }
 
+static gboolean asus_led_test = TRUE;
+static gboolean asus_led_state = FALSE;
+
 static DBusMessage *nm_dbus_nm_set_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
 {
 	gboolean	enabled = FALSE;
@@ -498,6 +501,20 @@
 	app_data = data->data;
 	app_data->wireless_enabled = enabled;
 
+	if (asus_led_test)
+	{
+		int fd = open("/proc/acpi/asus/wled", O_WRONLY);
+		if (fd < 0) {
+			asus_led_test = FALSE;
+		} else {
+			char c;
+			asus_led_state = enabled;
+			c = asus_led_state ? '1' : '0';
+			write(fd, &c, 1);
+			close(fd);
+		}
+	}
+
 	if (!enabled)
 	{
 		GSList	*elt;
@@ -527,6 +544,20 @@
 
 	g_return_val_if_fail (data && data->data && connection && message, NULL);
 
+	if (asus_led_test && asus_led_state != data->data->wireless_enabled)
+	{
+		int fd = open("/proc/acpi/asus/wled", O_WRONLY);
+		if (fd < 0) {
+			asus_led_test = FALSE;
+		} else {
+			char c;
+			asus_led_state = data->data->wireless_enabled;
+			c = asus_led_state ? '1' : '0';
+			write(fd, &c, 1);
+			close(fd);
+		}
+	}
+
 	if ((reply = dbus_message_new_method_return (message)))
 		dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &data->data->wireless_enabled, DBUS_TYPE_INVALID);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]