- Update to 0.5.8
This commit is contained in:
parent
fa52a7eb30
commit
5325dbfef1
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=281465
10 changed files with 29 additions and 1318 deletions
|
@ -6,8 +6,7 @@
|
|||
#
|
||||
|
||||
PORTNAME= lxpanel
|
||||
PORTVERSION= 0.5.6
|
||||
PORTREVISION= 3
|
||||
PORTVERSION= 0.5.8
|
||||
CATEGORIES= x11
|
||||
MASTER_SITES= SF/lxde/LXPanel%20%28desktop%20panel%29/LXPanel%20${PORTVERSION}
|
||||
|
||||
|
@ -15,7 +14,7 @@ MAINTAINER= kmoore@FreeBSD.org
|
|||
COMMENT= LXPanel is a lightweight X11 desktop panel
|
||||
|
||||
LIB_DEPENDS= menu-cache.1:${PORTSDIR}/x11/menu-cache
|
||||
BUILD_DEPENDS= ${LOCALBASE}/share/desktop-directories/lxde-audio-video.directory:${PORTSDIR}/x11/lxmenu-data
|
||||
RUN_DEPENDS= ${LOCALBASE}/share/desktop-directories/lxde-audio-video.directory:${PORTSDIR}/x11/lxmenu-data
|
||||
|
||||
OPTIONS= ALSA "enable ALSA audio architecture support" Off \
|
||||
NLS "NLS support" On
|
||||
|
@ -25,6 +24,7 @@ USE_GNOME= gnomehack gtk20 pkgconfig
|
|||
GNU_CONFIGURE= yes
|
||||
USE_AUTOTOOLS= automake:env
|
||||
CONFIGURE_ARGS= --prefix=${PREFIX} \
|
||||
--with-plugins=volume,deskno,kbled,xkb\
|
||||
CPPFLAGS="-I${LOCALBASE}/include" \
|
||||
LDFLAGS="-L${LOCALBASE}/lib"
|
||||
CFLAGS+= -I${WRKSRC}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
SHA256 (lxpanel-0.5.6.tar.gz) = 9c04839e2d23feec8b107a1d76899aca645416862b4b6ca01f8db743944348e1
|
||||
SIZE (lxpanel-0.5.6.tar.gz) = 1074786
|
||||
SHA256 (lxpanel-0.5.8.tar.gz) = 6a3579d6f384c03a33a03e4d32016428c84eb0f2bc421704f724fe2cc015cddd
|
||||
SIZE (lxpanel-0.5.8.tar.gz) = 1166241
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
--- src/plugins/cpu/cpu.c.orig 2010-02-08 01:37:52.000000000 -0500
|
||||
+++ src/plugins/cpu/cpu.c 2010-09-24 12:30:27.856886131 -0400
|
||||
@@ -19,12 +19,24 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
-/*A little bug fixed by Mykola <mykola@2ka.mipt.ru>:) */
|
||||
+
|
||||
+/*
|
||||
+ * A little bug fixed by Mykola <mykola@2ka.mipt.ru> :)
|
||||
+ * FreeBSD support added by Andreas Wiese <aw@instandbesetzt.net>
|
||||
+ */
|
||||
+
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
-#include <sys/sysinfo.h>
|
||||
+#ifdef __FreeBSD__
|
||||
+# include <sys/types.h>
|
||||
+# include <sys/resource.h>
|
||||
+# include <sys/sysctl.h>
|
||||
+# include <stdio.h>
|
||||
+#else
|
||||
+# include <sys/sysinfo.h>
|
||||
+#endif
|
||||
#include <stdlib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
@@ -65,6 +77,39 @@
|
||||
static int cpu_constructor(Plugin * p, char ** fp);
|
||||
static void cpu_destructor(Plugin * p);
|
||||
|
||||
+#ifdef __FreeBSD__
|
||||
+static void
|
||||
+get_procstat(unsigned long *u, unsigned long *n, unsigned long *s,
|
||||
+ unsigned long *i)
|
||||
+{
|
||||
+ static int mib[2] = { -1, -1 }, init = 0, j, realhz;
|
||||
+ long ct[CPUSTATES];
|
||||
+
|
||||
+
|
||||
+ if(init == 0) {
|
||||
+ struct clockinfo ci;
|
||||
+ j = sizeof(ci);
|
||||
+ sysctlbyname("kern.clockrate", &ci, &j, NULL, 0);
|
||||
+ realhz = ci.stathz ? ci.stathz : ci.hz;
|
||||
+
|
||||
+ j = 2;
|
||||
+ sysctlnametomib("kern.cp_time", mib, &j);
|
||||
+
|
||||
+ init = 1;
|
||||
+ j = sizeof(ct);
|
||||
+ }
|
||||
+
|
||||
+ sysctl(mib, 2, ct, &j, NULL, 0);
|
||||
+ *u = ct[CP_USER] / realhz;
|
||||
+ *n = ct[CP_NICE] / realhz;
|
||||
+ *s = ct[CP_SYS] / realhz;
|
||||
+ *i = ct[CP_IDLE] / realhz;
|
||||
+
|
||||
+ return;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
/* Redraw after timer callback or resize. */
|
||||
static void redraw_pixmap(CPUPlugin * c)
|
||||
{
|
||||
@@ -99,11 +144,18 @@
|
||||
{
|
||||
/* Open statistics file and scan out CPU usage. */
|
||||
struct cpu_stat cpu;
|
||||
- FILE * stat = fopen("/proc/stat", "r");
|
||||
- if (stat == NULL)
|
||||
- return TRUE;
|
||||
- int fscanf_result = fscanf(stat, "cpu %lu %lu %lu %lu", &cpu.u, &cpu.n, &cpu.s, &cpu.i);
|
||||
- fclose(stat);
|
||||
+ FILE * stat;
|
||||
+
|
||||
+ #ifdef __FreeBSD__
|
||||
+ get_procstat(&cpu.u, &cpu.n, &cpu.s, &cpu.i);
|
||||
+ int fscanf_result = 4;
|
||||
+ #else
|
||||
+ stat = fopen("/proc/stat", "r");
|
||||
+ if (stat == NULL)
|
||||
+ return TRUE;
|
||||
+ int fscanf_result = fscanf(stat, "cpu %lu %lu %lu %lu", &cpu.u, &cpu.n, &cpu.s, &cpu.i);
|
||||
+ fclose(stat);
|
||||
+ #endif
|
||||
|
||||
/* Ensure that fscanf succeeded. */
|
||||
if (fscanf_result == 4)
|
|
@ -1,222 +0,0 @@
|
|||
--- ./src/plugins/netstatus/netstatus-sysdeps.c.orig 2010-02-08 07:37:52.000000000 +0100
|
||||
+++ ./src/plugins/netstatus/netstatus-sysdeps.c 2010-10-13 20:13:03.722545000 +0200
|
||||
@@ -37,13 +37,26 @@
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/types.h>
|
||||
+#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
+#include <ifaddrs.h>
|
||||
#include <net/if.h>
|
||||
+#include <net/if_media.h>
|
||||
#include <net/if_var.h>
|
||||
+#if __FreeBSD_version < 700046
|
||||
#include <dev/an/if_aironet_ieee.h>
|
||||
#include <dev/wi/if_wavelan_ieee.h>
|
||||
#endif
|
||||
+#if __FreeBSD_version >= 602000
|
||||
+#include <net80211/ieee80211.h>
|
||||
+#include <net80211/ieee80211_ioctl.h>
|
||||
+#endif
|
||||
+#include <stdlib.h>
|
||||
+#ifndef IEEE80211_ADDR_COPY
|
||||
+#define IEEE80211_ADDR_COPY(dst, src) memcpy(dst, src, IEEE80211_ADDR_LEN)
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
static inline gboolean
|
||||
parse_stats (char *buf,
|
||||
@@ -426,15 +439,16 @@
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+#if __FreeBSD_version < 700046
|
||||
static inline char *
|
||||
get_an_data (const char *iface,
|
||||
int *signal_strength)
|
||||
{
|
||||
+ struct an_ltv_status *sts;
|
||||
+ struct an_req areq;
|
||||
#ifdef AN_RID_RSSI_MAP
|
||||
struct an_ltv_rssi_map an_rssimap;
|
||||
#endif
|
||||
- struct an_req areq;
|
||||
- struct an_ltv_status *sts;
|
||||
int level;
|
||||
char *error = NULL;
|
||||
gboolean rssimap_valid = FALSE;
|
||||
@@ -486,11 +500,11 @@
|
||||
level = (int) wreq.wi_val[1];
|
||||
|
||||
#ifdef WI_RID_READ_APS
|
||||
- if (signal_strength <= 0)
|
||||
+ if (level <= 0)
|
||||
{
|
||||
/* we fail to get signal strength by usual means, try another way */
|
||||
static time_t last_scan;
|
||||
- static long int cached;
|
||||
+ static int cached;
|
||||
time_t now;
|
||||
|
||||
now = time (NULL);
|
||||
@@ -510,15 +524,15 @@
|
||||
if (nstations > 0)
|
||||
{
|
||||
w = (struct wi_apinfo *)(((char *) &wreq.wi_val) + sizeof (int));
|
||||
- signal_strength = (long int) w->signal;
|
||||
+ level = w->signal;
|
||||
}
|
||||
|
||||
- cached = signal_strength;
|
||||
+ cached = level;
|
||||
last_scan = now;
|
||||
}
|
||||
else
|
||||
{
|
||||
- signal_strength = cached;
|
||||
+ level = cached;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -527,6 +541,77 @@
|
||||
|
||||
return error;
|
||||
}
|
||||
+#endif /* __FreeBSD_version < 700046 */
|
||||
+
|
||||
+#if __FreeBSD_version >= 602000
|
||||
+static inline char *
|
||||
+get_net80211_data (const char *iface,
|
||||
+ int *signal_strength)
|
||||
+{
|
||||
+ struct ieee80211req_sta_info *si;
|
||||
+ struct ieee80211req ireq;
|
||||
+ int level;
|
||||
+ int s;
|
||||
+ uint8_t mac[IEEE80211_ADDR_LEN];
|
||||
+ int8_t noise;
|
||||
+ char *error = NULL;
|
||||
+ union {
|
||||
+ struct ieee80211req_sta_req info;
|
||||
+ char buf[1024];
|
||||
+ } u_info;
|
||||
+
|
||||
+ memset (&u_info, 0, sizeof (u_info));
|
||||
+ memset (&ireq, 0, sizeof (ireq));
|
||||
+
|
||||
+ strlcpy (ireq.i_name, iface, sizeof (ireq.i_name));
|
||||
+ ireq.i_type = IEEE80211_IOC_BSSID;
|
||||
+ ireq.i_data = mac;
|
||||
+ ireq.i_len = IEEE80211_ADDR_LEN;
|
||||
+
|
||||
+ s = socket (AF_INET, SOCK_DGRAM, 0);
|
||||
+ if (s == -1)
|
||||
+ {
|
||||
+ error = g_strdup_printf (_("Could not connect to interface, '%s'"), iface);
|
||||
+ return error;
|
||||
+ }
|
||||
+
|
||||
+ if (ioctl (s, SIOCG80211, &ireq) == -1)
|
||||
+ {
|
||||
+ error = g_strdup_printf (_("Could not get MAC for interface, '%s'"), iface);
|
||||
+ close (s);
|
||||
+ return error;
|
||||
+ }
|
||||
+
|
||||
+ IEEE80211_ADDR_COPY (u_info.info.is_u.macaddr, mac);
|
||||
+ ireq.i_type = IEEE80211_IOC_STA_INFO;
|
||||
+ ireq.i_data = (caddr_t) &u_info;
|
||||
+ ireq.i_len = sizeof (u_info);
|
||||
+
|
||||
+ if (ioctl (s, SIOCG80211, &ireq) == -1)
|
||||
+ {
|
||||
+ error = g_strdup_printf (_("Could not send ioctl to interface, '%s'"), iface);
|
||||
+ close (s);
|
||||
+ return error;
|
||||
+ }
|
||||
+
|
||||
+ close (s);
|
||||
+
|
||||
+ si = &u_info.info.info[0];
|
||||
+ noise = si->isi_noise;
|
||||
+ if (si->isi_rssi == 0)
|
||||
+ level = 0;
|
||||
+ else
|
||||
+ {
|
||||
+ if (noise == 0)
|
||||
+ noise = -95;
|
||||
+ level = (int) abs (rint ((si->isi_rssi / (si->isi_rssi/2. + noise)) * 100.0));
|
||||
+ level = CLAMP (level, 0, 100);
|
||||
+ }
|
||||
+
|
||||
+ memcpy (signal_strength, &level, sizeof (signal_strength));
|
||||
+ return error;
|
||||
+}
|
||||
+#endif /* __FreeBSD_version >= 602000 */
|
||||
|
||||
char *
|
||||
netstatus_sysdeps_read_iface_wireless_details (const char *iface,
|
||||
@@ -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_ascii_strncasecmp (iface, "an", 2) == 0)
|
||||
{
|
||||
error_message = get_an_data (iface, signal_strength);
|
||||
*is_wireless = TRUE;
|
||||
}
|
||||
+#endif
|
||||
+#if __FreeBSD_version >= 602000
|
||||
+#if __FreeBSD_version < 700046
|
||||
+ else if (g_ascii_strncasecmp (iface, "wi", 2) == 0)
|
||||
+ {
|
||||
+ error_message = get_wi_data (iface, signal_strength);
|
||||
+ *is_wireless = TRUE;
|
||||
+ }
|
||||
+ else
|
||||
+#endif
|
||||
+ {
|
||||
+ error_message = get_net80211_data (iface, signal_strength);
|
||||
+ *is_wireless = TRUE;
|
||||
+ }
|
||||
+#else
|
||||
+#if __FreeBSD_version < 700046
|
||||
else
|
||||
{
|
||||
error_message = get_wi_data (iface, signal_strength);
|
||||
*is_wireless = TRUE;
|
||||
}
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
return error_message;
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
--- src/plugins/batt/batt.c.orig 2010-02-08 06:37:52.000000000 +0000
|
||||
+++ src/plugins/batt/batt.c 2010-11-26 14:33:21.000000000 +0000
|
||||
@@ -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,
|
||||
@@ -95,7 +95,7 @@
|
||||
typedef struct {
|
||||
char *command;
|
||||
sem_t *lock;
|
||||
-} alarm;
|
||||
+} lx_alarm;
|
||||
|
||||
static void destructor(Plugin *p);
|
||||
static void update_display(lx_battery *lx_b, gboolean repaint);
|
||||
@@ -103,7 +103,7 @@
|
||||
/* alarmProcess takes the address of a dynamically allocated alarm struct (which
|
||||
it must free). It ensures that alarm commands do not run concurrently. */
|
||||
static void * alarmProcess(void *arg) {
|
||||
- alarm *a = (alarm *) arg;
|
||||
+ lx_alarm *a = (lx_alarm *) arg;
|
||||
|
||||
sem_wait(a->lock);
|
||||
system(a->command);
|
||||
@@ -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
|
||||
@@ -157,7 +154,7 @@
|
||||
/* Run the alarm command if it isn't already running */
|
||||
if (alarmCanRun) {
|
||||
|
||||
- alarm *a = (alarm *) malloc(sizeof(alarm));
|
||||
+ lx_alarm *a = (lx_alarm *) malloc(sizeof(lx_alarm));
|
||||
a->command = lx_b->alarmCommand;
|
||||
a->lock = &(lx_b->alarmProcessLock);
|
||||
|
||||
@@ -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);
|
|
@ -1,270 +0,0 @@
|
|||
--- 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;
|
||||
-}
|
||||
-
|
||||
-
|
|
@ -1,26 +0,0 @@
|
|||
--- ./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
|
|
@ -1,412 +0,0 @@
|
|||
--- 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
|
||||
};
|
|
@ -1,142 +0,0 @@
|
|||
--- ./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
|
|
@ -1,12 +1,7 @@
|
|||
bin/lxpanel
|
||||
bin/lxpanelctl
|
||||
lib/lxpanel/plugins/batt.so
|
||||
lib/lxpanel/plugins/cpu.so
|
||||
lib/lxpanel/plugins/cpufreq.so
|
||||
lib/lxpanel/plugins/deskno.so
|
||||
lib/lxpanel/plugins/kbled.so
|
||||
lib/lxpanel/plugins/netstatus.so
|
||||
lib/lxpanel/plugins/thermal.so
|
||||
lib/lxpanel/plugins/volume.so
|
||||
lib/lxpanel/plugins/xkb.so
|
||||
libdata/pkgconfig/lxpanel.pc
|
||||
|
@ -125,19 +120,23 @@ include/lxpanel/plugin.h
|
|||
%%DATADIR%%/profile/default/panels/panel
|
||||
%%NLS%%share/locale/af/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ar/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/be/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/bg/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/bn/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/bn_IN/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ca/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/cs/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/da/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/de/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/el/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/en_GB/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/es/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/es_VE/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/et/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/eu/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/fa/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/fi/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/fo/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/fr/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/frp/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/gl/LC_MESSAGES/lxpanel.mo
|
||||
|
@ -148,22 +147,30 @@ include/lxpanel/plugin.h
|
|||
%%NLS%%share/locale/it/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ja/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ko/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/km/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/lt/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/lg/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ml/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ms/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/nb/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/nl/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/nn/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/pa/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/pl/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ps/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/pt/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/pt_BR/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ro/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ru/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/sk/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/sl/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/sr/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/sr@latin/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/sv/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/te/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/th/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/tr/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/tt_RU/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/uk/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ur/LC_MESSAGES/lxpanel.mo
|
||||
%%NLS%%share/locale/ur_PK/LC_MESSAGES/lxpanel.mo
|
||||
|
@ -180,10 +187,22 @@ include/lxpanel/plugin.h
|
|||
@dirrm include/lxpanel
|
||||
@dirrmtry share/locale/es_VE/LC_MESSAGES
|
||||
@dirrmtry share/locale/es_VE
|
||||
@dirrmtry share/locale/fo/LC_MESSAGES
|
||||
@dirrmtry share/locale/fo
|
||||
@dirrmtry share/locale/frp/LC_MESSAGES
|
||||
@dirrmtry share/locale/frp
|
||||
@dirrmtry share/locale/km/LC_MESSAGES
|
||||
@dirrmtry share/locale/km
|
||||
@dirrmtry share/locale/lg/LC_MESSAGES
|
||||
@dirrmtry share/locale/lg
|
||||
@dirrmtry share/locale/nn/LC_MESSAGES
|
||||
@dirrmtry share/locale/nn
|
||||
@dirrmtry share/locale/sr@latin/LC_MESSAGES
|
||||
@dirrmtry share/locale/sr@latin
|
||||
@dirrmtry share/locale/te/LC_MESSAGES
|
||||
@dirrmtry share/locale/te
|
||||
@dirrmtry share/locale/tt_RU/LC_MESSAGES
|
||||
@dirrmtry share/locale/tt_RU
|
||||
@dirrmtry share/locale/ur_PK/LC_MESSAGES
|
||||
@dirrmtry share/locale/ur_PK
|
||||
@dirrmtry lib/lxpanel/plugins
|
||||
|
|
Loading…
Reference in a new issue