aboutsummaryrefslogtreecommitdiff
path: root/x11/lxpanel
diff options
context:
space:
mode:
authorLars Engels <lme@FreeBSD.org>2010-10-18 18:54:27 +0000
committerLars Engels <lme@FreeBSD.org>2010-10-18 18:54:27 +0000
commit3939fa4ec2de84d17836c3d0b17957ee1edb93d7 (patch)
treed67b8153472db2013ba3ca9c5c7354af66f00a50 /x11/lxpanel
parent0550254cdc46be77d0dc245bb2da357964bd0261 (diff)
downloadports-3939fa4ec2de84d17836c3d0b17957ee1edb93d7.tar.gz
ports-3939fa4ec2de84d17836c3d0b17957ee1edb93d7.zip
Notes
Diffstat (limited to 'x11/lxpanel')
-rw-r--r--x11/lxpanel/Makefile2
-rw-r--r--x11/lxpanel/files/patch-src-plugins-netstatus-netstatus-sysdeps.c50
-rw-r--r--x11/lxpanel/files/patch-src__plugins__batt__batt.c116
-rw-r--r--x11/lxpanel/files/patch-src__plugins__batt__batt_sys.c270
-rw-r--r--x11/lxpanel/files/patch-src__plugins__batt__batt_sys.h26
-rw-r--r--x11/lxpanel/files/patch-src__plugins__cpufreq__cpufreq.c412
-rw-r--r--x11/lxpanel/files/patch-src__plugins__thermal__thermal.c142
7 files changed, 1001 insertions, 17 deletions
diff --git a/x11/lxpanel/Makefile b/x11/lxpanel/Makefile
index daa32d95f290..73561c7f932e 100644
--- a/x11/lxpanel/Makefile
+++ b/x11/lxpanel/Makefile
@@ -7,7 +7,7 @@
PORTNAME= lxpanel
PORTVERSION= 0.5.6
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= x11
MASTER_SITES= SF/lxde/LXPanel%20%28desktop%20panel%29/LXPanel%20${PORTVERSION}
diff --git a/x11/lxpanel/files/patch-src-plugins-netstatus-netstatus-sysdeps.c b/x11/lxpanel/files/patch-src-plugins-netstatus-netstatus-sysdeps.c
index 30c766ff8d3c..29a52ea19d24 100644
--- a/x11/lxpanel/files/patch-src-plugins-netstatus-netstatus-sysdeps.c
+++ b/x11/lxpanel/files/patch-src-plugins-netstatus-netstatus-sysdeps.c
@@ -1,5 +1,5 @@
--- ./src/plugins/netstatus/netstatus-sysdeps.c.orig 2010-02-08 07:37:52.000000000 +0100
-+++ ./src/plugins/netstatus/netstatus-sysdeps.c 2010-10-08 17:10:02.591239839 +0200
++++ ./src/plugins/netstatus/netstatus-sysdeps.c 2010-10-13 20:13:03.722545000 +0200
@@ -37,13 +37,26 @@
#ifdef __FreeBSD__
@@ -83,7 +83,7 @@
return error;
}
-+#endif
++#endif /* __FreeBSD_version < 700046 */
+
+#if __FreeBSD_version >= 602000
+static inline char *
@@ -153,25 +153,43 @@
+ memcpy (signal_strength, &level, sizeof (signal_strength));
+ return error;
+}
-+#endif
++#endif /* __FreeBSD_version >= 602000 */
char *
netstatus_sysdeps_read_iface_wireless_details (const char *iface,
-@@ -548,21 +633,44 @@
- g_strncasecmp (iface, "wi", 2) &&
- g_strncasecmp (iface, "ath", 3) &&
- g_strncasecmp (iface, "ndis", 4) &&
-+ g_strncasecmp (iface, "ural", 4) &&
-+ g_strncasecmp (iface, "ral", 3) &&
- g_strncasecmp (iface, "ipw", 3) &&
- g_strncasecmp (iface, "iwi", 3) &&
-+ g_strncasecmp (iface, "rum", 3) &&
-+ g_strncasecmp (iface, "wlan", 4) &&
- g_strncasecmp (iface, "acx", 3))
+@@ -544,25 +629,54 @@
+ if (signal_strength)
+ *signal_strength = 0;
+
+- if (g_strncasecmp (iface, "an", 2) &&
+- g_strncasecmp (iface, "wi", 2) &&
+- g_strncasecmp (iface, "ath", 3) &&
+- g_strncasecmp (iface, "ndis", 4) &&
+- g_strncasecmp (iface, "ipw", 3) &&
+- g_strncasecmp (iface, "iwi", 3) &&
+- g_strncasecmp (iface, "acx", 3))
++#if __FreeBSD_version >= 800036
++ if (g_ascii_strncasecmp (iface, "wlan", 4))
return error_message;
++#else
++ if (g_ascii_strncasecmp (iface, "acx", 3) &&
++ g_ascii_strncasecmp (iface, "an", 2) &&
++ g_ascii_strncasecmp (iface, "ath", 3) &&
++ g_ascii_strncasecmp (iface, "ipw", 3) &&
++ g_ascii_strncasecmp (iface, "iwi", 3) &&
++ g_ascii_strncasecmp (iface, "malo", 4) &&
++ g_ascii_strncasecmp (iface, "ndis", 4) &&
++ g_ascii_strncasecmp (iface, "ral", 3) &&
++ g_ascii_strncasecmp (iface, "rum", 3) &&
++ g_ascii_strncasecmp (iface, "ural", 4) &&
++ g_ascii_strncasecmp (iface, "wi", 2) &&
++ g_ascii_strncasecmp (iface, "zyd", 3))
++ return error_message;
++#endif
+- if (g_strncasecmp (iface, "an", 2) == 0)
+#if __FreeBSD_version < 700046
- if (g_strncasecmp (iface, "an", 2) == 0)
++ if (g_ascii_strncasecmp (iface, "an", 2) == 0)
{
error_message = get_an_data (iface, signal_strength);
*is_wireless = TRUE;
@@ -179,7 +197,7 @@
+#endif
+#if __FreeBSD_version >= 602000
+#if __FreeBSD_version < 700046
-+ else if (g_strncasecmp (iface, "wi", 2) == 0)
++ else if (g_ascii_strncasecmp (iface, "wi", 2) == 0)
+ {
+ error_message = get_wi_data (iface, signal_strength);
+ *is_wireless = TRUE;
diff --git a/x11/lxpanel/files/patch-src__plugins__batt__batt.c b/x11/lxpanel/files/patch-src__plugins__batt__batt.c
new file mode 100644
index 000000000000..95b2bc8df9d4
--- /dev/null
+++ b/x11/lxpanel/files/patch-src__plugins__batt__batt.c
@@ -0,0 +1,116 @@
+--- src/plugins/batt/batt.c.orig 2010-02-08 07:37:52.000000000 +0100
++++ src/plugins/batt/batt.c 2010-10-16 19:33:35.871250014 +0200
+@@ -30,7 +30,7 @@
+ */
+
+ /* FIXME:
+- * Here are somethings need to be improvec:
++ * Here are somethings need to be improved:
+ * 1. Replace pthread stuff with gthread counterparts for portability.
+ * 3. Add an option to hide the plugin when AC power is used or there is no battery.
+ * 4. Handle failure gracefully under systems other than Linux.
+@@ -71,7 +71,7 @@
+ GdkPixmap *pixmap;
+ GtkWidget *drawingArea;
+ int orientation;
+- unsigned int alarmTime,
++ unsigned int alarmPercentage,
+ border,
+ height,
+ length,
+@@ -120,21 +120,18 @@
+ char tooltip[ 256 ];
+ battery *b = lx_b->b;
+ /* unit: mW */
+- int rate = lx_b->b->present_rate;
+
+ if (! lx_b->pixmap )
+ return;
+
+ /* no battery is found */
+- if( b == NULL )
++ if( b == NULL || b->percentage < 0)
+ {
+ gtk_widget_set_tooltip_text( lx_b->drawingArea, _("No batteries found") );
++ gdk_draw_rectangle(lx_b->pixmap, lx_b->bg, TRUE, 0, 0, lx_b->width, lx_b->height);
+ return;
+ }
+
+-
+-
+-
+ gboolean isCharging;
+
+ /* draw background */
+@@ -145,8 +142,8 @@
+ isCharging = battery_is_charging ( b );
+
+ /* Consider running the alarm command */
+- if (! isCharging && rate &&
+- ( ( battery_get_remaining( b ) / 60 ) < lx_b->alarmTime ) )
++ if (! isCharging &&
++ ( ( b->percentage ) < lx_b->alarmPercentage ) )
+ {
+ /* Shrug this should be done using glibs process functions */
+ /* Alarms should not run concurrently; determine whether an alarm is
+@@ -176,7 +173,7 @@
+ int left_seconds = b->seconds -= 3600 * hours;
+ int minutes = left_seconds / 60;
+ snprintf(tooltip, 256,
+- _("Battery: %d%% charged, %d:%02d until full"),
++ _("Battery: %d%% charged"),
+ lx_b->b->percentage,
+ hours,
+ minutes );
+@@ -187,10 +184,10 @@
+ int left_seconds = b->seconds -= 3600 * hours;
+ int minutes = left_seconds / 60;
+ snprintf(tooltip, 256,
+- _("Battery: %d%% charged, %d:%02d left"),
++ _("Battery: %d%% charged, %d:%02dh left"),
+ lx_b->b->percentage,
+- hours,
+- minutes );
++ lx_b->b->minutes / 60,
++ lx_b->b->minutes % 60 );
+ } else {
+ snprintf(tooltip, 256,
+ _("Battery: %d%% charged"),
+@@ -374,7 +371,7 @@
+ = lx_b->dischargingColor1 = lx_b->dischargingColor2 = NULL;
+
+ /* Set default values for integers */
+- lx_b->alarmTime = 5;
++ lx_b->alarmPercentage = 10;
+ lx_b->requestedBorder = 1;
+
+ line s;
+@@ -403,8 +400,8 @@
+ lx_b->dischargingColor1 = g_strdup(s.t[1]);
+ else if (!g_ascii_strcasecmp(s.t[0], "DischargingColor2"))
+ lx_b->dischargingColor2 = g_strdup(s.t[1]);
+- else if (!g_ascii_strcasecmp(s.t[0], "AlarmTime"))
+- lx_b->alarmTime = atoi(s.t[1]);
++ else if (!g_ascii_strcasecmp(s.t[0], "AlarmPercentage"))
++ lx_b->alarmPercentage = atoi(s.t[1]);
+ else if (!g_ascii_strcasecmp(s.t[0], "BorderWidth"))
+ lx_b->requestedBorder = atoi(s.t[1]);
+ else if (!g_ascii_strcasecmp(s.t[0], "Size")) {
+@@ -580,7 +577,7 @@
+ _("Hide if there is no battery"), &b->hide_if_no_battery, CONF_TYPE_BOOL,
+ #endif
+ _("Alarm command"), &b->alarmCommand, CONF_TYPE_STR,
+- _("Alarm time (minutes left)"), &b->alarmTime, CONF_TYPE_INT,
++ _("Alarm percentage (Percentage left)"), &b->alarmPercentage, CONF_TYPE_INT,
+ _("Background color"), &b->backgroundColor, CONF_TYPE_STR,
+ _("Charging color 1"), &b->chargingColor1, CONF_TYPE_STR,
+ _("Charging color 2"), &b->chargingColor2, CONF_TYPE_STR,
+@@ -600,7 +597,7 @@
+
+ lxpanel_put_bool(fp, "HideIfNoBattery",lx_b->hide_if_no_battery);
+ lxpanel_put_str(fp, "AlarmCommand", lx_b->alarmCommand);
+- lxpanel_put_int(fp, "AlarmTime", lx_b->alarmTime);
++ lxpanel_put_int(fp, "AlarmPercentage", lx_b->alarmPercentage);
+ lxpanel_put_str(fp, "BackgroundColor", lx_b->backgroundColor);
+ lxpanel_put_int(fp, "BorderWidth", lx_b->requestedBorder);
+ lxpanel_put_str(fp, "ChargingColor1", lx_b->chargingColor1);
diff --git a/x11/lxpanel/files/patch-src__plugins__batt__batt_sys.c b/x11/lxpanel/files/patch-src__plugins__batt__batt_sys.c
new file mode 100644
index 000000000000..4d38a4c51a8f
--- /dev/null
+++ b/x11/lxpanel/files/patch-src__plugins__batt__batt_sys.c
@@ -0,0 +1,270 @@
+--- src/plugins/batt/batt_sys.c.orig 2010-02-08 07:37:52.000000000 +0100
++++ src/plugins/batt/batt_sys.c 2010-10-16 19:34:55.616250250 +0200
+@@ -39,15 +39,6 @@
+ static int battery_num = 1;
+ battery * b = g_new0 ( battery, 1 );
+ b->type_battery = TRUE;
+- b->capacity_unit = "mAh";
+- b->last_capacity_unit = -1;
+- b->last_capacity = -1;
+- b->voltage = -1;
+- b->design_capacity_unit = -1;
+- b->design_capacity = -1;
+- b->remaining_energy = -1;
+- b->remaining_capacity = -1;
+- b->present_rate = -1;
+ b->state = NULL;
+ b->battery_num = battery_num;
+ battery_num++;
+@@ -76,7 +67,7 @@
+ return n;
+ }
+
+-void battery_print(battery *b, int show_capacity)
++void battery_print(battery *b)
+ {
+ if ( b->type_battery )
+ {
+@@ -90,193 +81,61 @@
+ b->seconds -= 3600 * b->hours;
+ b->minutes = b->seconds / 60;
+ b->seconds -= 60 * b->minutes;
+- printf(", %02d:%02d:%02d%s", b->hours, b->minutes, b->seconds, b->poststr);
++ printf(", %02d:%02d:%02d", b->hours, b->minutes, b->seconds);
+ } else if (b->poststr != NULL) {
+ printf(", %s", b->poststr);
+ }
+
+-
+ printf("\n");
+-
+- if (show_capacity && b->design_capacity > 0) {
+- if (b->last_capacity <= 100) {
+- /* some broken systems just give a percentage here */
+- b->percentage = b->last_capacity;
+- b->last_capacity = b->percentage * b->design_capacity / 100;
+- } else {
+- b->percentage = b->last_capacity * 100 / b->design_capacity;
+- }
+- if (b->percentage > 100)
+- b->percentage = 100;
+-
+- printf ("%s %d: design capacity %d %s, last full capacity %d %s = %d%%\n",
+- BATTERY_DESC, b->battery_num - 1, b->design_capacity, b->capacity_unit, b->last_capacity, b->capacity_unit, b->percentage);
+- }
+ }
+ }
+ }
+
+
+ void battery_update( battery *b ) {
+- int i = 0;
+- const gchar *sys_list[] = {
+- "current_now",
+- "charge_now",
+- "energy_now",
+- "voltage_now",
+- "voltage_min_design",
+- "charge_full",
+- "energy_full",
+- "charge_full_design",
+- "energy_full_design",
+- "online",
+- "status",
+- "type",
+- NULL
+- };
+- const gchar *sys_file;
++ char sstmp[ 100 ];
++ int c, state;
++ size_t intlen = sizeof c;
++
++ snprintf(sstmp, sizeof(sstmp), "hw.acpi.battery.life");
++ sysctlbyname(sstmp, &c, &intlen, NULL, 0);
++ b->percentage = c;
+
+- while ( (sys_file = sys_list[i]) != NULL ) {
++ snprintf(sstmp, sizeof(sstmp), "hw.acpi.battery.state");
++ sysctlbyname(sstmp, &state, &intlen, NULL, 0);
+
+- gchar *file_content;
+- GString *filename = g_string_new( ACPI_PATH_SYS_POWER_SUPPY );
+- g_string_append_printf ( filename, "/%s/%s", b->path,
+- sys_file );
+- if ((file_content = parse_info_file(filename->str)) != NULL) {
+-
+- if ( strcmp("charge_now", sys_file ) == 0 ) {
+- b->remaining_capacity = get_unit_value((gchar*) file_content) / 1000;
+- if (!b->state)
+- b->state = "available";
+- }
+- else if ( strcmp("energy_now", sys_file ) == 0 ) {
+- b->remaining_capacity = get_unit_value((gchar*) file_content) / 1000;
+- if (!b->state)
+- b->state = "available";
+- }
+- else if ( strcmp("current_now", sys_file ) == 0 ) {
+- b->present_rate = get_unit_value((gchar*) file_content) / 1000;
+- }
+- else if ( strcmp("charge_full", sys_file ) == 0 ) {
+- b->last_capacity = get_unit_value((gchar*) file_content) / 1000;
+- if (!b->state)
+- b->state = ("available");
+- }
+- else if ( strcmp("energy_full", sys_file ) == 0 ) {
+- b->last_capacity_unit = get_unit_value((gchar*) file_content) / 1000;
+- if (!b->state)
+- b->state = ("available");
+- }
+- else if ( strcmp("charge_full_design", sys_file ) == 0 ) {
+- b->design_capacity = get_unit_value((gchar*) file_content) / 1000;
+- }
+- else if ( strcmp("energy_full_design", sys_file ) == 0 ) {
+- b->design_capacity_unit = get_unit_value((gchar*) file_content) / 1000;
+- }
+- else if ( strcmp("type", sys_file ) == 0 ) {
+- b->type_battery = (strcasecmp(file_content, "battery") == 0 );
+- }
+- else if ( ( strcmp("status", sys_file ) == 0 ) || strcmp("state", sys_file ) == 0 )
+- b->state = file_content;
+- else if ( strcmp("voltage_now", sys_file ) == 0 ) {
+- b->voltage = get_unit_value((gchar*) file_content) / 1000;
+- }
+-
+- g_string_free( filename, TRUE );
+- }
+- i++;
+- }
+-
+- /* convert energy values (in mWh) to charge values (in mAh) if needed and possible */
+- if (b->last_capacity_unit != -1 && b->last_capacity == -1) {
+- if (b->voltage != -1) {
+- b->last_capacity = b->last_capacity_unit * 1000 / b->voltage;
+- } else {
+- b->last_capacity = b->last_capacity_unit;
+- b->capacity_unit = "mWh";
+- }
+- }
+- if (b->design_capacity_unit != -1 && b->design_capacity == -1) {
+- if (b->voltage != -1) {
+- b->design_capacity = b->design_capacity_unit * 1000 / b->voltage;
+- } else {
+- b->design_capacity = b->design_capacity_unit;
+- b->capacity_unit = "mWh";
+- }
+- }
+- if (b->remaining_energy != -1 && b->remaining_capacity == -1) {
+- if (b->voltage != -1) {
+- b->remaining_capacity = b->remaining_energy * 1000 / b->voltage;
+- b->present_rate = b->present_rate * 1000 / b->voltage;
+- } else {
+- b->remaining_capacity = b->remaining_energy;
+- }
+- }
+- if (b->last_capacity < MIN_CAPACITY)
+- b->percentage = 0;
+- else
+- b->percentage = b->remaining_capacity * 100 / b->last_capacity;
+-
+- if (b->percentage > 100)
+- b->percentage = 100;
+-
+-
+-
+- if (b->present_rate == -1) {
+- b->poststr = "rate information unavailable";
+- b->seconds = -1;
+- } else if (!strcasecmp(b->state, "charging")) {
+- if (b->present_rate > MIN_PRESENT_RATE) {
+- b->seconds = 3600 * (b->last_capacity - b->remaining_capacity) / b->present_rate;
+- b->poststr = " until charged";
+- } else {
+- b->poststr = "charging at zero rate - will never fully charge.";
+- b->seconds = -1;
+- }
+- } else if (!strcasecmp(b->state, "discharging")) {
+- if (b->present_rate > MIN_PRESENT_RATE) {
+- b->seconds = 3600 * b->remaining_capacity / b->present_rate;
+- b->poststr = " remaining";
+- } else {
+- b->poststr = "discharging at zero rate - will never fully discharge.";
+- b->seconds = -1;
+- }
+- } else {
+- b->poststr = NULL;
+- b->seconds = -1;
+- }
+-
+-}
+-
+-static battery* acpi_sys_get_battery_from_dir (const gchar *device_name ) {
+- battery *b = battery_new();
+- b->path = g_strdup( device_name );
+- return b;
++ switch(state) {
++ case BATT_FULL:
++ b->state = "Full";
++ break;
++ case BATT_DISCHARGING:
++ b->state = "Discharging";
++ break;
++ case BATT_CHARGING:
++ b->state = "Charging";
++ break;
++ case BATT_CRITICAL:
++ b->state = "Critical";
++ break;
++ case BATT_NONE:
++ b->state = "Unavailable";
++ break;
++ default:
++ b->state = "Unknown";
++ break;
++
++ }
++
++ snprintf(sstmp, sizeof(sstmp), "hw.acpi.battery.time");
++ sysctlbyname(sstmp, &c, &intlen, NULL, 0);
++ b->minutes = c;
++ b->seconds = c * 60;
+ }
+
+ battery *battery_get() {
+- GError * error = NULL;
+- const gchar *entry;
+- GDir * dir = g_dir_open( ACPI_PATH_SYS_POWER_SUPPY, 0, &error );
+ battery *b = NULL;
+- if ( dir == NULL )
+- {
+- g_warning( "NO ACPI/sysfs support in kernel: %s", error->message );
+- return NULL;
+- }
+- while ( ( entry = g_dir_read_name (dir) ) != NULL )
+- {
+- b = acpi_sys_get_battery_from_dir(entry);
+- battery_update ( b );
+- if ( b->type_battery == TRUE )
+- break;
+- /* ignore non-batteries */
+- else {
+- g_free(b);
+- b = NULL;
+- }
+- }
+- g_dir_close( dir );
++ b = battery_new();
++ battery_update(b);
+ return b;
+ }
+
+@@ -286,10 +145,3 @@
+ strcasecmp( b->state, "Full" ) == 0
+ || strcasecmp( b->state, "Charging" ) == 0 );
+ }
+-
+-gint battery_get_remaining( battery *b )
+-{
+- return b->seconds;
+-}
+-
+-
diff --git a/x11/lxpanel/files/patch-src__plugins__batt__batt_sys.h b/x11/lxpanel/files/patch-src__plugins__batt__batt_sys.h
new file mode 100644
index 000000000000..ff2223873790
--- /dev/null
+++ b/x11/lxpanel/files/patch-src__plugins__batt__batt_sys.h
@@ -0,0 +1,26 @@
+--- ./src/plugins/batt/batt_sys.h.orig 2010-10-16 15:13:33.221247000 +0200
++++ ./src/plugins/batt/batt_sys.h 2010-10-16 13:58:18.377264000 +0200
+@@ -30,6 +30,13 @@
+ #define MIN_PRESENT_RATE 0.01
+ #define BATTERY_DESC "Battery"
+
++/* The states a battery can have */
++#define BATT_FULL 0
++#define BATT_DISCHARGING 1
++#define BATT_CHARGING 2
++#define BATT_CRITICAL 5
++#define BATT_NONE 7
++
+ #include <glib.h>
+
+ typedef struct battery {
+@@ -53,8 +60,7 @@
+
+ battery *battery_get();
+ void battery_update( battery *b );
+-void battery_print(battery *b, int show_capacity);
++void battery_print(battery *b);
+ gboolean battery_is_charging( battery *b );
+-gint battery_get_remaining( battery *b );
+
+ #endif
diff --git a/x11/lxpanel/files/patch-src__plugins__cpufreq__cpufreq.c b/x11/lxpanel/files/patch-src__plugins__cpufreq__cpufreq.c
new file mode 100644
index 000000000000..9be132572d03
--- /dev/null
+++ b/x11/lxpanel/files/patch-src__plugins__cpufreq__cpufreq.c
@@ -0,0 +1,412 @@
+--- src/plugins/cpufreq/cpufreq.c.orig 2010-10-16 19:40:17.038248942 +0200
++++ src/plugins/cpufreq/cpufreq.c 2010-10-16 20:29:05.387248781 +0200
+@@ -33,28 +33,13 @@
+
+ #include "dbg.h"
+
+-#define PROC_ICON PACKAGE_DATA_DIR "/lxpanel/images/cpufreq-icon.png"
+-#define SYSFS_CPU_DIRECTORY "/sys/devices/system/cpu"
+-#define SCALING_GOV "scaling_governor"
+-#define SCALING_AGOV "scaling_available_governors"
+-#define SCALING_AFREQ "scaling_available_frequencies"
+-#define SCALING_CUR_FREQ "scaling_cur_freq"
+-#define SCALING_SETFREQ "scaling_setspeed"
+-#define SCALING_MAX "scaling_max_freq"
+-#define SCALING_MIN "scaling_min_freq"
+-
+-
+ typedef struct {
+ GtkWidget *main;
+ GtkWidget *namew;
+ GtkTooltips *tip;
+- GList *governors;
+ GList *cpus;
+- int has_cpufreq;
+- char* cur_governor;
+ int cur_freq;
+ unsigned int timer;
+- gboolean remember;
+ } cpufreq;
+
+ typedef struct {
+@@ -63,243 +48,33 @@
+ } Param;
+
+ static void
+-get_cur_governor(cpufreq *cf){
+- FILE *fp;
+- char buf[ 100 ], sstmp [ 256 ];
+-
+- sprintf(sstmp,"%s/%s",cf->cpus->data, SCALING_GOV);
+- if ((fp = fopen( sstmp, "r")) != NULL) {
+- fgets(buf, 100, fp);
+- buf[strlen(buf)-1] = '\0';
+- if(cf->cur_governor)
+- {
+- g_free(cf->cur_governor);
+- cf->cur_governor = NULL;
+- }
+- cf->cur_governor = strdup(buf);
+- fclose(fp);
+- }
+-}
+-
+-static void
+ get_cur_freq(cpufreq *cf){
+- FILE *fp;
+- char buf[ 100 ], sstmp [ 256 ];
+-
+- sprintf(sstmp,"%s/%s",cf->cpus->data, SCALING_CUR_FREQ);
+- if ((fp = fopen( sstmp, "r")) != NULL) {
+- fgets(buf, 100, fp);
+- buf[strlen(buf)-1] = '\0';
+- cf->cur_freq = atoi(buf);
+- fclose(fp);
+- }
++ char sstmp [ 256 ];
++ int c;
++ size_t clen = sizeof c;
++
++ snprintf(sstmp, sizeof(sstmp), "dev.cpu.0.freq");
++ if (sysctlbyname(sstmp, &c, &clen, NULL, 0) != 0 || clen != sizeof c)
++ return;
++ printf("freq: %d\n", c);
++ cf->cur_freq = c;
+ }
+
+-static void
+-get_governors(cpufreq *cf){
+- FILE *fp;
+- GList *l;
+- char buf[ 100 ], sstmp [ 256 ], c, bufl = 0;
+-
+- g_list_free(cf->governors);
+- cf->governors = NULL;
+-
+- get_cur_governor(cf);
+-
+- if(cf->cpus == NULL){
+- cf->governors = NULL;
+- return;
+- }
+- sprintf(sstmp,"%s/%s",cf->cpus->data, SCALING_AGOV);
+-
+- if (!(fp = fopen( sstmp, "r"))) {
+- printf("cpufreq: cannot open %s\n",sstmp);
+- return;
+- }
+-
+- while((c = fgetc(fp)) != EOF){
+- if(c == ' '){
+- if(bufl > 1){
+- buf[bufl] = '\0';
+- cf->governors = g_list_append(cf->governors, strdup(buf));
+- }
+- bufl = 0;
+- buf[0] = '\0';
+- }else{
+- buf[bufl++] = c;
+- }
+- }
+-
+- fclose(fp);
+-}
+-
+-static void
+-cpufreq_set_freq(GtkWidget *widget, Param* p){
+- FILE *fp;
+- char buf[ 100 ], sstmp [ 256 ];
+-
+- if(strcmp(p->cf->cur_governor, "userspace")) return;
+-
+- sprintf(sstmp,"%s/%s",p->cf->cpus->data, SCALING_SETFREQ);
+- if ((fp = fopen( sstmp, "w")) != NULL) {
+- fprintf(fp,"%s",p->data);
+- fclose(fp);
+- }
+-}
+-
+-static GtkWidget *
+-frequency_menu(cpufreq *cf){
+- FILE *fp;
+- Param* param;
+- char buf[ 100 ], sstmp [ 256 ], c, bufl = 0;
+-
+- sprintf(sstmp,"%s/%s",cf->cpus->data, SCALING_AFREQ);
+-
+- if (!(fp = fopen( sstmp, "r"))) {
+- printf("cpufreq: cannot open %s\n",sstmp);
+- return;
+- }
+-
+- GtkMenu* menu = GTK_MENU(gtk_menu_new());
+- GtkWidget* menuitem;
+-
+- while((c = fgetc(fp)) != EOF){
+- if(c == ' '){
+- if(bufl > 1){
+- buf[bufl] = '\0';
+- menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(strdup(buf)));
+- gtk_menu_append (GTK_MENU_SHELL (menu), menuitem);
+- gtk_widget_show (menuitem);
+- param = g_new0(Param, 1);
+- param->data = strdup(buf);
+- param->cf = cf;
+- g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(cpufreq_set_freq), param);
+- g_object_weak_ref(menuitem, g_free, param);
+- }
+- bufl = 0;
+- buf[0] = '\0';
+- }else{
+- buf[bufl++] = c;
+- }
+- }
+-
+- fclose(fp);
+- return menu;
+-}
+
+ static void
+ get_cpus(cpufreq *cf)
+ {
+-
+ const char *cpu;
+- char cpu_path[100];
+-
+- GDir * cpuDirectory = g_dir_open(SYSFS_CPU_DIRECTORY, 0, NULL);
+- if (cpuDirectory == NULL)
+- {
+- cf->cpus = NULL;
+- printf("cpufreq: no cpu found\n");
+- return;
+- }
+
+- while ((cpu = g_dir_read_name(cpuDirectory)))
+- {
+- /* Look for directories of the form "cpu<n>", where "<n>" is a decimal integer. */
+- if ((strncmp(cpu, "cpu", 3) == 0) && (cpu[3] >= '0') && (cpu[3] <= '9'))
+- {
+- sprintf(cpu_path, "%s/%s/cpufreq", SYSFS_CPU_DIRECTORY, cpu);
+-
+- GDir * cpufreqDir = g_dir_open(SYSFS_CPU_DIRECTORY, 0, NULL);
+- if (cpufreqDir == NULL)
+- {
+- cf->cpus = NULL;
+- cf->has_cpufreq = 0;
+- break;
+- }
+-
+- cf->has_cpufreq = 1;
+- cf->cpus = g_list_append(cf->cpus, strdup(cpu_path));
+- }
+- }
+- g_dir_close(cpuDirectory);
+-}
+-
+-static void
+-cpufreq_set_governor(GtkWidget *widget, Param* p){
+- FILE *fp;
+- char buf[ 100 ], sstmp [ 256 ];
+-
+- sprintf(sstmp, "%s/%s", p->cf->cpus->data, SCALING_GOV);
+- if ((fp = fopen( sstmp, "w")) != NULL) {
+- fprintf(fp,"%s",p->data);
+- fclose(fp);
+- }
+-}
+-
+-static GtkWidget *
+-cpufreq_menu(cpufreq *cf){
+- GList *l;
+- GSList *group;
+- char buff[100];
+- GtkMenuItem* menuitem;
+- Param* param;
+-
+- GtkMenu* menu = GTK_MENU(gtk_menu_new());
+- g_signal_connect(menu, "selection-done", gtk_widget_destroy, NULL);
+-
+- get_governors(cf);
+- group = NULL;
+-
+- if((cf->governors == NULL) || (!cf->has_cpufreq) || (cf->cur_governor == NULL)){
+- menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label("CPUFreq not supported"));
+- gtk_menu_append (GTK_MENU_SHELL (menu), menuitem);
+- gtk_widget_show (menuitem);
+- return menu;
+- }
+-
+- if(strcmp(cf->cur_governor, "userspace") == 0){
+- menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(" Frequency"));
+- gtk_menu_append (GTK_MENU_SHELL (menu), menuitem);
+- gtk_widget_show (menuitem);
+- gtk_menu_item_set_submenu(menuitem, frequency_menu(cf));
+- menuitem = GTK_MENU_ITEM(gtk_separator_menu_item_new());
+- gtk_menu_append (GTK_MENU_SHELL (menu), menuitem);
+- gtk_widget_show (GTK_WIDGET(menuitem));
+- }
+-
+- for( l = cf->governors; l; l = l->next )
+- {
+- if(strcmp((char*)l->data, cf->cur_governor) == 0){
+- sprintf(buff,"> %s", l->data);
+- menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(strdup(buff)));
+- }else{
+- sprintf(buff," %s", l->data);
+- menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(strdup(buff)));
+- }
+-
+- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+- gtk_widget_show (menuitem);
+- param = g_new0(Param, 1);
+- param->data = l->data;
+- param->cf = cf;
+- g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(cpufreq_set_governor), param);
+- g_object_weak_ref(menuitem, g_free, param);
+- }
+-
+- return menu;
++ cf->cpus = g_list_append(cf->cpus, strdup("dev.cpu.0.freq"));
+ }
+
+-
+-
+ static gboolean
+ clicked( GtkWidget *widget, GdkEventButton* evt, Plugin* plugin)
+ {
+ ENTER2;
+ if( evt->button == 1 )
+ {
+-// Setting governor can't work without root privilege
+-// gtk_menu_popup( cpufreq_menu((cpufreq*)plugin->priv), NULL, NULL, NULL, NULL,
+-// evt->button, evt->time );
+ return TRUE;
+ }else if ( evt->button == 3 )
+ {
+@@ -316,15 +91,16 @@
+ update_tooltip(cpufreq *cf)
+ {
+ char *tooltip;
++ char buffer [60];
+
+ get_cur_freq(cf);
+- get_cur_governor(cf);
+
+ ENTER;
+
+- tooltip = g_strdup_printf("Frequency: %d MHz\nGovernor: %s",
+- cf->cur_freq / 1000, cf->cur_governor);
++ tooltip = g_strdup_printf("Frequency: %d MHz", cf->cur_freq );
+ gtk_tooltips_set_tip(cf->tip, cf->main, tooltip, NULL);
++ sprintf(buffer, "<span color=\"#ffffff\"><b>%d MHz</b></span>", cf->cur_freq);
++ gtk_label_set_markup (GTK_LABEL(cf->namew), buffer);
+ g_free(tooltip);
+ RET(TRUE);
+ }
+@@ -337,7 +113,6 @@
+
+ ENTER;
+ cf = g_new0(cpufreq, 1);
+- cf->governors = NULL;
+ cf->cpus = NULL;
+ g_return_val_if_fail(cf != NULL, 0);
+ p->priv = cf;
+@@ -346,7 +121,7 @@
+ GTK_WIDGET_SET_FLAGS( p->pwid, GTK_NO_WINDOW );
+ gtk_container_set_border_width( GTK_CONTAINER(p->pwid), 2 );
+
+- cf->namew = gtk_image_new_from_file(PROC_ICON);
++ cf->namew = gtk_label_new("xxx");
+ gtk_container_add(GTK_CONTAINER(p->pwid), cf->namew);
+
+ cf->main = p->pwid;
+@@ -361,34 +136,8 @@
+
+ g_signal_connect (G_OBJECT (p->pwid), "button_press_event", G_CALLBACK (clicked), (gpointer) p);
+
+- cf->has_cpufreq = 0;
+-
+ get_cpus(cf);
+
+-/* line s;
+- s.len = 256;
+-
+- if (fp) {
+- while (lxpanel_get_line(fp, &s) != LINE_BLOCK_END) {
+- if (s.type == LINE_NONE) {
+- ERR( "cpufreq: illegal token %s\n", s.str);
+- goto error;
+- }
+- if (s.type == LINE_VAR) {
+- if (!g_ascii_strcasecmp(s.t[0], "DefaultGovernor")){
+- //cf->str_cl_normal = g_strdup(s.t[1]);
+- }else {
+- ERR( "cpufreq: unknown var %s\n", s.t[0]);
+- continue;
+- }
+- }
+- else {
+- ERR( "cpufreq: illegal in cfis context %s\n", s.str);
+- goto error;
+- }
+- }
+-
+- }*/
+ update_tooltip(cf);
+ cf->timer = g_timeout_add(2000, (GSourceFunc)update_tooltip, (gpointer)cf);
+
+@@ -400,53 +149,24 @@
+ RET(FALSE);*/
+ }
+
+-static void applyConfig(Plugin* p) { }
+-
+-static void config(Plugin *p, GtkWindow* parent) {
+- ENTER;
+-
+- GtkWidget *dialog;
+- cpufreq *cf = (cpufreq *) p->priv;
+- dialog = create_generic_config_dlg(_(p->class->name),
+- GTK_WIDGET(parent),
+- (GSourceFunc) applyConfig, (gpointer) p,
+- _("Remember governor and frequency"), &cf->remember, CONF_TYPE_BOOL,
+- NULL);
+- gtk_window_present(GTK_WINDOW(dialog));
+-
+- RET();
+-}
+-
+ static void
+ cpufreq_destructor(Plugin *p)
+ {
+ cpufreq *cf = (cpufreq *)p->priv;
+ g_list_free ( cf->cpus );
+- g_list_free ( cf->governors );
+ g_source_remove(cf->timer);
+ g_free(cf);
+ }
+
+-static void save_config( Plugin* p, FILE* fp )
+-{
+- cpufreq *cf = (cpufreq *)p->priv;
+-
+- lxpanel_put_bool( fp, "Remember", cf->remember);
+- lxpanel_put_str( fp, "Governor", cf->cur_governor );
+- lxpanel_put_int( fp, "Frequency", cf->cur_freq );
+-}
+-
+ PluginClass cpufreq_plugin_class = {
+ PLUGINCLASS_VERSIONING,
+
+ type : "cpufreq",
+ name : N_("CPUFreq frontend"),
+ version: "0.1",
+- description : N_("Display CPU frequency and allow to change governors and frequency"),
++ description : N_("Display CPU frequency"),
+
+ constructor : cpufreq_constructor,
+ destructor : cpufreq_destructor,
+- config : config,
+- save : NULL,
+ panel_configuration_changed : NULL
+ };
diff --git a/x11/lxpanel/files/patch-src__plugins__thermal__thermal.c b/x11/lxpanel/files/patch-src__plugins__thermal__thermal.c
new file mode 100644
index 000000000000..e2544c2e2de2
--- /dev/null
+++ b/x11/lxpanel/files/patch-src__plugins__thermal__thermal.c
@@ -0,0 +1,142 @@
+--- ./src/plugins/thermal/thermal.c.orig 2010-10-09 15:45:51.496346000 +0200
++++ ./src/plugins/thermal/thermal.c 2010-10-09 16:51:40.227196000 +0200
+@@ -32,10 +32,7 @@
+
+ #include "dbg.h"
+
+-#define THERMAL_DIRECTORY "/proc/acpi/thermal_zone/" /* must be slash-terminated */
+-#define THERMAL_TEMPF "temperature"
+-#define THERMAL_TRIP "trip_points"
+-#define TRIP_CRITICAL "critical (S5):"
++#include <sys/sysctl.h>
+
+ typedef struct {
+ Plugin * plugin;
+@@ -57,68 +54,33 @@
+ } thermal;
+
+ static gint
+-get_critical(thermal *th){
+- FILE *state;
+- char buf[ 256 ], sstmp [ 100 ];
+- char* pstr;
+-
+- if(th->sensor == NULL) return -1;
+-
+- sprintf(sstmp,"%s%s",th->sensor,THERMAL_TRIP);
+-
+- if (!(state = fopen( sstmp, "r"))) {
+- //printf("cannot open %s\n",sstmp);
+- return -1;
+- }
++get_temperature_value(thermal *th, const char *which)
++{
++ char sstmp[ 100 ];
++ int t;
++ size_t tlen = sizeof t;
+
+- while( fgets(buf, 256, state) &&
+- ! ( pstr = strstr(buf, TRIP_CRITICAL) ) );
+- if( pstr )
+- {
+- pstr += strlen(TRIP_CRITICAL);
+- while( *pstr && *pstr == ' ' )
+- ++pstr;
++ if(th->sensor == NULL) return -1;
+
+- pstr[strlen(pstr)-3] = '\0';
+- printf("Critical: [%s]\n",pstr);
+- fclose(state);
+- return atoi(pstr);
+- }
++ snprintf(sstmp, sizeof(sstmp), "hw.acpi.thermal.%s.%s", th->sensor, which);
++ if (sysctlbyname(sstmp, &t, &tlen, NULL, 0) != 0 || tlen != sizeof t)
++ return -1;
+
+- fclose(state);
+- return -1;
++ return (t - 2732) / 10;
+ }
+
+ static gint
+-get_temperature(thermal *th){
+- FILE *state;
+- char buf[ 256 ], sstmp [ 100 ];
+- char* pstr;
+-
+- if(th->sensor == NULL) return -1;
+-
+- sprintf(sstmp,"%s%s",th->sensor,THERMAL_TEMPF);
+-
+- if (!(state = fopen( sstmp, "r"))) {
+- //printf("cannot open %s\n",sstmp);
+- return -1;
+- }
++get_critical(thermal *th)
++{
+
+- while( fgets(buf, 256, state) &&
+- ! ( pstr = strstr(buf, "temperature:") ) );
+- if( pstr )
+- {
+- pstr += 12;
+- while( *pstr && *pstr == ' ' )
+- ++pstr;
++ return (get_temperature_value(th, "_CRT"));
++}
+
+- pstr[strlen(pstr)-3] = '\0';
+- fclose(state);
+- return atoi(pstr);
+- }
++static gint
++get_temperature(thermal *th)
++{
+
+- fclose(state);
+- return -1;
++ return (get_temperature_value(th, "temperature"));
+ }
+
+ static gint
+@@ -141,7 +103,7 @@
+ panel_draw_label_text(th->plugin->panel, th->namew, "NA", TRUE, TRUE);
+ else
+ {
+- n = sprintf(buffer, "<span color=\"#%06x\"><b>%02d</b></span>", gcolor2rgb24(&color), temp);
++ n = sprintf(buffer, "<span color=\"#%06x\"><b>%02d C</b></span>", gcolor2rgb24(&color), temp);
+ gtk_label_set_markup (GTK_LABEL(th->namew), buffer) ;
+ }
+
+@@ -151,30 +113,8 @@
+ static void
+ check_sensors( thermal* th )
+ {
+- GDir *sensorsDirectory;
+- const char *sensor_name;
+- char sensor_path[100];
+
+- if (! (sensorsDirectory = g_dir_open(THERMAL_DIRECTORY, 0, NULL)))
+- {
+- th->sensor = NULL;
+- return;
+- }
+-
+- /* Scan the thermal_zone directory for available sensors */
+- while ((sensor_name = g_dir_read_name(sensorsDirectory))) {
+- if (sensor_name[0] != '.') {
+- sprintf(sensor_path,"%s%s/",THERMAL_DIRECTORY, sensor_name);
+- if(th->sensor) {
+- g_free(th->sensor);
+- th->sensor = NULL;
+- }
+- th->sensor = strdup(sensor_path);
+- //printf("sensor: %s\n", b->sensor);
+- break;
+- }
+- }
+- g_dir_close(sensorsDirectory);
++ th->sensor = strdup("tz0");
+ }
+
+ static int