1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-20 00:21:35 +00:00

- Update to 0.9.3

- Adjust dependencies
- Add WEATHER (set by default), and ALSA (unset) options
- Rewrite patches plugins in order to use sysctl calls instead the Linux
proc and sys file system
This commit is contained in:
Olivier Duchateau 2017-01-24 21:37:57 +00:00
parent e147c6761a
commit bd76ecd8df
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=432391
15 changed files with 677 additions and 2487 deletions

View File

@ -2,10 +2,9 @@
# $FreeBSD$
PORTNAME= lxpanel
PORTVERSION= 0.6.2
PORTREVISION= 1
PORTVERSION= 0.9.3
CATEGORIES= x11
MASTER_SITES= SF/lxde/LXPanel%20%28desktop%20panel%29/LXPanel%20${PORTVERSION}/
MASTER_SITES= SF/lxde/LXPanel%20%28desktop%20panel%29/LXPanel%20${PORTVERSION:R}.x/
MAINTAINER= ports@FreeBSD.org
COMMENT= Lightweight X11 desktop panel
@ -14,99 +13,44 @@ LICENSE= GPLv2 MIT
LICENSE_COMB= dual
LIB_DEPENDS= libmenu-cache.so:x11/menu-cache \
libsysinfo.so:devel/libsysinfo
RUN_DEPENDS= ${LOCALBASE}/share/desktop-directories/lxde-audio-video.directory:x11/lxmenu-data \
xmessage:x11/xmessage
libkeybinder.so:x11/keybinder \
libfm-gtk.so:x11/libfm \
libfontconfig.so:x11-fonts/fontconfig \
libfreetype.so:print/freetype2
RUN_DEPENDS= ${LOCALBASE}/etc/xdg/menus/lxde-applications.menu:x11/lxmenu-data
USE_AUTOTOOLS= automake:env
USE_CSTD= gnu89
USE_GNOME= gtk20 libwnck intltool
USE_XORG= x11 xmu
USES= gmake pathfix pkgconfig
USE_GNOME= glib20 gtk20 cairo gdkpixbuf2 libwnck intltool
USE_XORG= x11
USES= gmake libtool localbase pathfix pkgconfig tar:xz
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --prefix="${PREFIX}" \
--with-plugins=netstatus,volume,volumealsa,deskno,batt,kbled,xkb,thermal,cpu,cpufreq,monitors,wnckpager \
--with-x \
CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib"
CFLAGS+= -I${WRKSRC}
INSTALL_TARGET= install-strip
SUB_FILES= pkg-message
PORTDOCS= AUTHORS README
# Panel plugins
LXPANEL_PLUGINS= "-netstat,-netstatus,deskno,-batt,kbled,xkb,-thermal,cpu,cpufreq,monitors,-indicator"
OPTIONS_DEFINE= ALSA DOCS NLS
OPTIONS_SINGLE= SOUND
OPTIONS_SINGLE_SOUND= ALSA OSS
OPTIONS_DEFINE= NLS WEATHER
OPTIONS_DEFAULT= OSS WEATHER
OPTIONS_SUB= yes
ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib
ALSA_CONFIGURE_ENABLE= alsa
ALSA_VARS= lxpanel_plugins+=",-volume,volumealsa"
OSS_VARS= lxpanel_plugins+=",volume,-volumealsa"
NLS_CONFIGURE_ENABLE= nls
NLS_USES= gettext
NLS_USES_OFF= gettext-tools
WEATHER_USE= gnome=libxml2
WEATHER_VARS= lxpanel_plugins+=",weather"
WEATHER_VARS_OFF= lxpanel_plugins+=",-weather"
WEATHER_DESC= Weather plugin
post-patch:
@${REINPLACE_CMD} -e '/g_thread_create/ \
s|.*| g_thread_new("tf", (GThreadFunc)thread_func,\
thread_data);|' \
${WRKSRC}/src/gtk-run.c
@${REINPLACE_CMD} -e '/g_thread_init/d' \
${WRKSRC}/src/panel.c
@${REINPLACE_CMD} -e 's|structure_size :|.structure_size =|; \
s|structure_version :|.structure_version =|' \
${WRKSRC}/src/plugin.h
@${REINPLACE_CMD} -e 's| type *:| .type =|; \
s| name *:| .name =|; \
s| version *:| .version =|; \
s| description *:| .description =|; \
s| constructor *:| .constructor =|; \
s| destructor *:| .destructor =|; \
s| config *:| .config =|; \
s| save *:| .save =|; \
s| panel_configuration_changed *:| \
.panel_configuration_changed =|; \
s| fname:| .fname =|; \
s| count:| .count =|; \
s| expand_available :| .expand_available =|; \
s| expand_default :| .expand_default =|; \
s| one_per_system :| .one_per_system =|; \
s| not_unloadable :| .not_unloadable =|' \
${WRKSRC}/src/plugins/batt/batt.c \
${WRKSRC}/src/plugins/cpu*/cpu*.c \
${WRKSRC}/src/plugins/deskno/deskno.c \
${WRKSRC}/src/plugins/kbled/kbled.c \
${WRKSRC}/src/plugins/monitors/monitors.c \
${WRKSRC}/src/plugins/netstatus/netstatus.c \
${WRKSRC}/src/plugins/thermal/thermal.c \
${WRKSRC}/src/plugins/wnckpager/wnckpager.c \
${WRKSRC}/src/plugins/xkb/xkb-plugin.c \
${WRKSRC}/src/plugins/volume*/volume*.c \
${WRKSRC}/src/plugins/*.c
@${REINPLACE_CMD} -e '/gdk_color_parse(b/ s|;||; \
/gdk_color_parse(b/{p;s/.*/ ;/;}' \
${WRKSRC}/src/plugins/batt/batt.c
@${REINPLACE_CMD} -e 's|/sys|/compat/linux&|' \
${WRKSRC}/src/plugins/batt/batt_sys.h
@${REINPLACE_CMD} -e 's|/proc|/compat/linux&|' \
${WRKSRC}/src/plugins/cpu/cpu.c \
${WRKSRC}/src/plugins/monitors/monitors.c \
${WRKSRC}/src/plugins/thermal/thermal.c
@${REINPLACE_CMD} -e 's|%lld|%lu|g; s|bytes >=|bytes >|' \
${WRKSRC}/src/plugins/netstatus/netstatus-dialog.c
@${REINPLACE_CMD} -e '/NETSTATUS_ERROR, code/ s|error_message|"%s", &|' \
${WRKSRC}/src/plugins/netstatus/netstatus-iface.c
@${REINPLACE_CMD} -e '611s/signal_strength)/*&/' \
${WRKSRC}/src/plugins/netstatus/netstatus-sysdeps.c
@${REINPLACE_CMD} -e 's|linux|sys|' \
${WRKSRC}/src/plugins/volume/volume-impl.c
CONFIGURE_ARGS+= --sysconfdir=${PREFIX}/etc \
--with-plugins="${LXPANEL_PLUGINS}"
post-patch-NLS-off:
@${REINPLACE_CMD} -e 's|po man|man|' \
${WRKSRC}/Makefile.in
post-install:
@${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/lxpanel/plugins/*.so
post-install-DOCS-on:
@${MKDIR} ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${PORTDOCS:S|^|${WRKSRC}/|} ${STAGEDIR}${DOCSDIR}
.include <bsd.port.mk>

View File

@ -1,2 +1,3 @@
SHA256 (lxpanel-0.6.2.tar.gz) = f9ba6d0b825f7b99de045c3371738792bf9f3604af66bef4d98d783461c60a48
SIZE (lxpanel-0.6.2.tar.gz) = 2086833
TIMESTAMP = 1485088803
SHA256 (lxpanel-0.9.3.tar.xz) = 342cfa205f255acf69c76ba0ca6c77c890f3955a879b755931c80ffae4d98fb1
SIZE (lxpanel-0.9.3.tar.xz) = 1515144

View File

@ -0,0 +1,120 @@
--- plugins/cpu/cpu.c.orig 2016-11-19 18:28:43 UTC
+++ plugins/cpu/cpu.c
@@ -35,8 +35,15 @@
#include <string.h>
#include <sys/time.h>
#include <time.h>
+#if defined(__linux__)
#include <sys/sysinfo.h>
+#endif
#include <stdlib.h>
+#if defined(__DragonFly__) || (__FreeBSD__)
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
#include <glib/gi18n.h>
#include "plugin.h"
@@ -46,12 +53,22 @@
/* #include "../../dbg.h" */
-typedef unsigned long long CPUTick; /* Value from /proc/stat */
typedef float CPUSample; /* Saved CPU utilization value as 0.0..1.0 */
+#if defined(__linux__)
+typedef unsigned long long CPUTick; /* Value from /proc/stat */
+
struct cpu_stat {
CPUTick u, n, s, i; /* User, nice, system, idle */
};
+#elif defined(__DragonFly__) || (__FreeBSD__)
+typedef glong CPUTick;
+
+struct cpu_stat {
+ CPUTick u, n, s, intr, i;
+};
+#endif
+
/* Private context for CPU plugin. */
typedef struct {
@@ -116,6 +133,20 @@ static void redraw_pixmap(CPUPlugin * c)
gtk_widget_queue_draw(c->da);
}
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+static gint cpu_nb(void)
+{
+ static gint mib[] = { CTL_HW, HW_NCPU };
+ gint res;
+ size_t len = sizeof(gint);
+
+ if (sysctl(mib, 2, &res, &len, NULL, 0) < 0)
+ return 0;
+ else
+ return res;
+}
+#endif
+
/* Periodic timer callback. */
static gboolean cpu_update(CPUPlugin * c)
{
@@ -123,6 +154,7 @@ static gboolean cpu_update(CPUPlugin * c
return FALSE;
if ((c->stats_cpu != NULL) && (c->pixmap != NULL))
{
+#if defined(__linux__)
/* Open statistics file and scan out CPU usage. */
struct cpu_stat cpu;
FILE * stat = fopen("/proc/stat", "r");
@@ -155,6 +187,48 @@ static gboolean cpu_update(CPUPlugin * c
/* Redraw with the new sample. */
redraw_pixmap(c);
}
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+ size_t cp_size = sizeof(glong) * CPUSTATES * cpu_nb();
+ glong *cp_times = malloc(cp_size);
+
+ if (sysctlbyname("kern.cp_times", cp_times, &cp_size, NULL, 0) < 0)
+ {
+ g_free(cp_times);
+ return FALSE;
+ }
+ else
+ {
+ struct cpu_stat cpu;
+ struct cpu_stat cpu_delta;
+
+ cpu.u = cp_times[CP_USER];
+ cpu.n = cp_times[CP_NICE];
+ cpu.s = cp_times[CP_SYS];
+ cpu.intr = cp_times[CP_INTR];
+ cpu.i = cp_times[CP_IDLE];
+
+ g_free(cp_times);
+
+ /* Compute delta from previous statistics. */
+ cpu_delta.u = cpu.u - c->previous_cpu_stat.u;
+ cpu_delta.n = cpu.n - c->previous_cpu_stat.n;
+ cpu_delta.s = cpu.s - c->previous_cpu_stat.s;
+ cpu_delta.intr = cpu.intr - c->previous_cpu_stat.intr;
+ cpu_delta.i = cpu.i - c->previous_cpu_stat.i;
+
+ memcpy(&c->previous_cpu_stat, &cpu, sizeof(struct cpu_stat));
+
+ float cpu_used = cpu_delta.u + cpu_delta.n;
+ float cpu_total = cpu_used + cpu_delta.s + cpu_delta.intr + cpu_delta.i;
+ c->stats_cpu[c->ring_cursor] = cpu_used / cpu_total;
+ c->ring_cursor += 1;
+ if (c->ring_cursor >= c->pixmap_width)
+ c->ring_cursor = 0;
+
+ /* Redraw with the new sample. */
+ redraw_pixmap(c);
+ }
+#endif
}
return TRUE;
}

View File

@ -0,0 +1,334 @@
--- plugins/cpufreq/cpufreq.c.orig 2015-05-06 19:44:51 UTC
+++ plugins/cpufreq/cpufreq.c
@@ -22,6 +22,9 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+#include <sys/sysctl.h>
+#endif
#include <glib.h>
#include <glib/gi18n.h>
@@ -33,6 +36,7 @@
#include "dbg.h"
#define PROC_ICON "cpufreq-icon"
+#if defined(__linux__)
#define SYSFS_CPU_DIRECTORY "/sys/devices/system/cpu"
#define SCALING_GOV "scaling_governor"
#define SCALING_AGOV "scaling_available_governors"
@@ -41,15 +45,19 @@
#define SCALING_SETFREQ "scaling_setspeed"
#define SCALING_MAX "scaling_max_freq"
#define SCALING_MIN "scaling_min_freq"
-
+#endif
typedef struct {
GtkWidget *main;
config_setting_t *settings;
+#if defined(__linux__)
GList *governors;
GList *cpus;
- int has_cpufreq;
char* cur_governor;
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+ int cpus;
+#endif
+ int has_cpufreq;
int cur_freq;
unsigned int timer;
//gboolean remember;
@@ -62,6 +70,7 @@ typedef struct {
static void cpufreq_destructor(gpointer user_data);
+#if defined(__linux__)
static void
get_cur_governor(cpufreq *cf){
FILE *fp;
@@ -99,98 +108,6 @@ get_cur_freq(cpufreq *cf){
}
}
-/*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 0;
- }
-
- 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_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(G_OBJECT(menuitem), (GWeakNotify)g_free, param);
- }
- bufl = 0;
- buf[0] = '\0';
- }else{
- buf[bufl++] = c;
- }
- }
-
- fclose(fp);
- return GTK_WIDGET(menu);
-}*/
-
static void
get_cpus(cpufreq *cf)
{
@@ -227,72 +144,49 @@ get_cpus(cpufreq *cf)
}
g_dir_close(cpuDirectory);
}
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+static void
+get_cur_freq(cpufreq *cf)
+{
+ int buf;
+ size_t length_buf = sizeof(int);
-/*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);
- }
+ if (sysctlbyname("dev.cpu.0.freq", &buf, &length_buf, NULL, 0) < 0)
+ cf->cur_freq = 0;
+ else
+ cf->cur_freq = buf;
}
-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", G_CALLBACK(gtk_widget_destroy), NULL);
-
- get_governors(cf);
- group = NULL;
+int
+detect_cpus_number(void)
+{
+ static int mib[] = {CTL_HW, HW_NCPU};
+ int buf;
+ size_t length_buf = sizeof(int);
- 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), GTK_WIDGET (menuitem));
- gtk_widget_show (GTK_WIDGET (menuitem));
- return GTK_WIDGET(menu);
- }
+ if (sysctl(mib, 2, &buf, &length_buf, NULL, 0) < 0)
+ return 0;
+ else
+ return buf;
+}
- 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), GTK_WIDGET (menuitem));
- gtk_widget_show (GTK_WIDGET (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), GTK_WIDGET (menuitem));
- gtk_widget_show (GTK_WIDGET(menuitem));
- }
+static void
+get_cpus(cpufreq *cf)
+{
+ int ncpus, buf;
+ size_t lenght_buf = sizeof(int);
- for( l = cf->governors; l; l = l->next )
+ ncpus = detect_cpus_number();
+ cf->cpus = ncpus;
+ if (cf->cpus > 0)
+ cf->has_cpufreq = 1;
+ else
{
- 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), GTK_WIDGET (menuitem));
- gtk_widget_show (GTK_WIDGET (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(G_OBJECT(menuitem), (GWeakNotify) g_free, param);
+ cf->has_cpufreq = 0;
+ printf("cpufreq: no cpu found\n");
}
-
- return GTK_WIDGET (menu);
-}*/
-
+}
+#endif
static gboolean
@@ -318,12 +212,18 @@ _update_tooltip(cpufreq *cf)
char *tooltip;
get_cur_freq(cf);
+#if defined(__linux__)
get_cur_governor(cf);
+#endif
ENTER;
+#if defined(__linux__)
tooltip = g_strdup_printf(_("Frequency: %d MHz\nGovernor: %s"),
cf->cur_freq / 1000, cf->cur_governor);
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+ tooltip = g_strdup_printf("Frequency: %d MHz", cf->cur_freq);
+#endif
gtk_widget_set_tooltip_text(cf->main, tooltip);
g_free(tooltip);
RET(TRUE);
@@ -344,8 +244,12 @@ static GtkWidget *cpufreq_constructor(LX
ENTER;
cf = g_new0(cpufreq, 1);
g_return_val_if_fail(cf != NULL, NULL);
+#if defined(__linux__)
cf->governors = NULL;
cf->cpus = NULL;
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+ cf->cpus = 0;
+#endif
cf->settings = settings;
cf->main = lxpanel_button_new_for_icon(panel, PROC_ICON, NULL, NULL);
@@ -365,30 +269,14 @@ static GtkWidget *cpufreq_constructor(LX
RET(cf->main);
}
-/*
-static gboolean applyConfig(gpointer user_data)
-{
- cpufreq *cf = lxpanel_plugin_get_data(user_data);
-
- config_group_set_int(cf->settings, "Remember", cf->remember);
- return FALSE;
-}
-
-static GtkWidget *config(LXPanel *panel, GtkWidget *p, GtkWindow *parent)
-{
- cpufreq *cf = lxpanel_plugin_get_data(p);
- return lxpanel_generic_config_dlg(_("CPUFreq frontend"), panel, applyConfig, p,
- _("Remember governor and frequency"), &cf->remember, CONF_TYPE_BOOL,
- NULL);
-}
-*/
-
static void
cpufreq_destructor(gpointer user_data)
{
cpufreq *cf = (cpufreq *)user_data;
+#if defined(__linux__)
g_list_free ( cf->cpus );
g_list_free ( cf->governors );
+#endif
g_source_remove(cf->timer);
g_free(cf);
}
@@ -399,7 +287,11 @@ FM_DEFINE_MODULE(lxpanel_gtk, cpufreq)
/* Plugin descriptor. */
LXPanelPluginInit fm_module_init_lxpanel_gtk = {
.name = N_("CPUFreq frontend"),
+#if defined(__linux__)
.description = N_("Display CPU frequency and allow to change governors and frequency"),
+#elif defined(__DragonFly__) || defined(__FreeBSD__)
+ .description = "Display CPU frequency",
+#endif
.new_instance = cpufreq_constructor,
//.config = config,

View File

@ -0,0 +1,169 @@
--- plugins/monitors/monitors.c.orig 2016-11-19 18:28:43 UTC
+++ plugins/monitors/monitors.c
@@ -72,6 +72,12 @@
*/
#include <stdlib.h>
+#if defined(__DragonFly__) || (__FreeBSD__)
+#include <unistd.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
#include <glib/gi18n.h>
#include <errno.h>
#include <libfm/fm-gtk.h>
@@ -221,20 +227,46 @@ monitor_set_foreground_color(MonitorsPlu
/******************************************************************************
* CPU monitor *
******************************************************************************/
-typedef unsigned long long CPUTick;/* Value from /proc/stat */
typedef float CPUSample; /* Saved CPU utilization value as 0.0..1.0 */
+#if defined(__linux__)
+typedef unsigned long long CPUTick;/* Value from /proc/stat */
+
struct cpu_stat {
CPUTick u, n, s, i; /* User, nice, system, idle */
};
+#elif defined(__DragonFly__) || (__FreeBSD__)
+typedef glong CPUTick;
+
+struct cpu_stat {
+ CPUTick u, n, s, intr, i;
+};
+
+static gint cpu_nb(void)
+{
+ static gint mib[] = { CTL_HW, HW_NCPU };
+ gint res;
+ size_t len = sizeof(gint);
+
+ if (sysctl(mib, 2, &res, &len, NULL, 0) < 0)
+ return 0;
+ else
+ return res;
+}
+#endif
static gboolean
cpu_update(Monitor * c)
{
+#if defined(__linux__)
static struct cpu_stat previous_cpu_stat = { 0, 0, 0, 0 };
+#elif defined(__DragonFly__) || (__FreeBSD__)
+ static struct cpu_stat previous_cpu_stat = { 0, 0, 0, 0, 0 };
+#endif
if ((c->stats != NULL) && (c->pixmap != NULL))
{
+#if defined(__linux__)
/* Open statistics file and scan out CPU usage. */
struct cpu_stat cpu;
FILE * stat = fopen("/proc/stat", "r");
@@ -269,6 +301,48 @@ cpu_update(Monitor * c)
/* Redraw with the new sample. */
redraw_pixmap(c);
}
+#elif defined(__DragonFly__) || (__FreeBSD__)
+ size_t cp_size = sizeof(glong) * CPUSTATES * cpu_nb();
+ glong *cp_times = malloc(cp_size);
+
+ if (sysctlbyname("kern.cp_times", cp_times, &cp_size, NULL, 0) < 0)
+ {
+ g_free(cp_times);
+ return FALSE;
+ }
+ else
+ {
+ struct cpu_stat cpu;
+ struct cpu_stat cpu_delta;
+
+ cpu.u = cp_times[CP_USER];
+ cpu.n = cp_times[CP_NICE];
+ cpu.s = cp_times[CP_SYS];
+ cpu.intr = cp_times[CP_INTR];
+ cpu.i = cp_times[CP_IDLE];
+
+ g_free(cp_times);
+
+ /* Compute delta from previous statistics. */
+ cpu_delta.u = cpu.u - previous_cpu_stat.u;
+ cpu_delta.n = cpu.n - previous_cpu_stat.n;
+ cpu_delta.s = cpu.s - previous_cpu_stat.s;
+ cpu_delta.intr = cpu.intr - previous_cpu_stat.intr;
+ cpu_delta.i = cpu.i - previous_cpu_stat.i;
+
+ memcpy(&previous_cpu_stat, &cpu, sizeof(struct cpu_stat));
+
+ float cpu_used = cpu_delta.u + cpu_delta.n;
+ float cpu_total = cpu_used + cpu_delta.s + cpu_delta.intr + cpu_delta.i;
+ c->stats[c->ring_cursor] = cpu_used / cpu_total;
+ c->ring_cursor += 1;
+ if (c->ring_cursor >= c->pixmap_width)
+ c->ring_cursor = 0;
+
+ /* Redraw with the new sample. */
+ redraw_pixmap(c);
+ }
+#endif
}
return TRUE;
}
@@ -294,11 +368,38 @@ cpu_tooltip_update (Monitor *m)
/******************************************************************************
* RAM Monitor *
******************************************************************************/
+#if defined(__DragonFly__) || (__FreeBSD__)
+static glong
+mem_get_by_bytes(const gchar *name)
+{
+ glong buf;
+ gsize len = sizeof(glong);
+
+ if (sysctlbyname(name, &buf, &len, NULL, 0) < 0)
+ return 0;
+ else
+ return buf;
+}
+
+static glong
+mem_get_by_pages(const gchar *name)
+{
+ glong res = 0;
+
+ res = mem_get_by_bytes(name);
+ if (res > 0)
+ res = res * getpagesize();
+
+ return res;
+}
+#endif
+
static gboolean
mem_update(Monitor * m)
{
ENTER;
+#if defined(__linux__)
FILE *meminfo;
char buf[80];
long int mem_total = 0;
@@ -343,6 +444,17 @@ mem_update(Monitor * m)
"readmask %x", readmask);
RET(FALSE);
}
+#elif defined(__DragonFly__) || (__FreeBSD__)
+ if (!m->stats || !m->pixmap)
+ RET(TRUE);
+
+ glong mem_total, mem_free, mem_buffers, mem_cached;
+
+ mem_total = mem_get_by_bytes("hw.physmem");
+ mem_free = mem_get_by_pages("vm.stats.vm.v_free_count");
+ mem_buffers = mem_get_by_bytes("vfs.bufspace");
+ mem_cached = mem_get_by_pages("vm.stats.vm.v_inactive_count");
+#endif
m->total = mem_total;

View File

@ -1,266 +0,0 @@
--- ./src/plugins/batt/Makefile.in.orig 2014-05-09 09:31:24.000000000 -0400
+++ ./src/plugins/batt/Makefile.in 2014-05-27 18:13:52.000000000 -0400
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.12.6 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2012 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -15,51 +15,23 @@
@SET_MAKE@
VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
-am__make_running_with_option = \
- case $${target_option-} in \
- ?) ;; \
- *) echo "am__make_running_with_option: internal error: invalid" \
- "target option '$${target_option-}' specified" >&2; \
- exit 1;; \
- esac; \
- has_opt=no; \
- sane_makeflags=$$MAKEFLAGS; \
- if $(am__is_gnu_make); then \
- sane_makeflags=$$MFLAGS; \
- else \
+am__make_dryrun = \
+ { \
+ am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
- bs=\\; \
- sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
- | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
- esac; \
- fi; \
- skip_next=no; \
- strip_trailopt () \
- { \
- flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
- }; \
- for flg in $$sane_makeflags; do \
- test $$skip_next = yes && { skip_next=no; continue; }; \
- case $$flg in \
- *=*|--*) continue;; \
- -*I) strip_trailopt 'I'; skip_next=yes;; \
- -*I?*) strip_trailopt 'I';; \
- -*O) strip_trailopt 'O'; skip_next=yes;; \
- -*O?*) strip_trailopt 'O';; \
- -*l) strip_trailopt 'l'; skip_next=yes;; \
- -*l?*) strip_trailopt 'l';; \
- -[dEDm]) skip_next=yes;; \
- -[JT]) skip_next=yes;; \
- esac; \
- case $$flg in \
- *$$target_option*) has_opt=yes; break;; \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
esac; \
- done; \
- test $$has_opt = yes
-am__make_dryrun = (target_option=n; $(am__make_running_with_option))
-am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+ test $$am__dry = yes; \
+ }
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -79,21 +51,14 @@
build_triplet = @build@
host_triplet = @host@
subdir = src/plugins/batt
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
- $(top_srcdir)/mkinstalldirs $(top_srcdir)/depcomp
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+ $(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
- $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intltool.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
- $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
- $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
- $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@@ -178,23 +143,6 @@
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
-am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
-# Read a list of newline-separated strings from the standard input,
-# and print each of them once, without duplicates. Input order is
-# *not* preserved.
-am__uniquify_input = $(AWK) '\
- BEGIN { nonempty = 0; } \
- { items[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in items) print i; }; } \
-'
-# Make sure the list of sources is unique. This is necessary because,
-# e.g., the same source file might be shared among _SOURCES variables
-# for different programs/libraries.
-am__define_uniq_tagged_files = \
- list='$(am__tagged_files)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -255,15 +203,11 @@
INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@
LD = @LD@
LDFLAGS = @LDFLAGS@
-LIBICONV = @LIBICONV@
-LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
-LTLIBICONV = @LTLIBICONV@
-LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
LXPANEL_MODULE = @LXPANEL_MODULE@
MAKEINFO = @MAKEINFO@
@@ -423,7 +367,6 @@
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
-
install-moduleLTLIBRARIES: $(module_LTLIBRARIES)
@$(NORMAL_INSTALL)
@list='$(module_LTLIBRARIES)'; test -n "$(moduledir)" || list=; \
@@ -458,7 +401,6 @@
echo rm -f $${locs}; \
rm -f $${locs}; \
}
-
batt.la: $(batt_la_OBJECTS) $(batt_la_DEPENDENCIES) $(EXTRA_batt_la_DEPENDENCIES)
$(AM_V_CCLD)$(batt_la_LINK) -rpath $(moduledir) $(batt_la_OBJECTS) $(batt_la_LIBADD) $(LIBS)
@@ -476,14 +418,14 @@
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -512,15 +454,26 @@
clean-libtool:
-rm -rf .libs _libs
-ID: $(am__tagged_files)
- $(am__define_uniq_tagged_files); mkid -fID $$unique
-tags: tags-am
-TAGS: tags
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
-tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
- $(am__define_uniq_tagged_files); \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
@@ -532,11 +485,15 @@
$$unique; \
fi; \
fi
-ctags: ctags-am
-
-CTAGS: ctags
-ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
- $(am__define_uniq_tagged_files); \
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
@@ -545,10 +502,9 @@
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
-cscopelist: cscopelist-am
-cscopelist-am: $(am__tagged_files)
- list='$(am__tagged_files)'; \
+cscopelist: $(HEADERS) $(SOURCES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
@@ -704,9 +660,9 @@
.MAKE: install-am install-strip
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-moduleLTLIBRARIES cscopelist-am ctags \
- ctags-am distclean distclean-compile distclean-generic \
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-moduleLTLIBRARIES cscopelist ctags \
+ distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
@@ -716,7 +672,7 @@
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
- pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-moduleLTLIBRARIES

View File

@ -1,171 +0,0 @@
--- ./src/plugins/batt/batt.c.orig 2014-05-09 09:15:04.000000000 -0400
+++ ./src/plugins/batt/batt.c 2014-05-27 18:13:59.000000000 -0400
@@ -68,7 +68,7 @@
cairo_surface_t *pixmap;
GtkWidget *drawingArea;
int orientation;
- unsigned int alarmTime,
+ unsigned int alarmPercentage,
border,
height,
length,
@@ -118,7 +118,6 @@
char tooltip[ 256 ];
battery *b = lx_b->b;
/* unit: mW */
- int rate;
gboolean isCharging;
if (! lx_b->pixmap )
@@ -127,26 +126,28 @@
cr = cairo_create(lx_b->pixmap);
cairo_set_line_width (cr, 1.0);
- /* draw background */
- gdk_cairo_set_source_color(cr, &lx_b->background);
- cairo_rectangle(cr, 0, 0, lx_b->width, lx_b->height);
- cairo_fill(cr);
-
/* no battery is found */
- if( b == NULL )
+ if( b == NULL || b->percentage < 0 )
{
gtk_widget_set_tooltip_text( lx_b->drawingArea, _("No batteries found") );
- goto update_done;
+ gdk_cairo_set_source_color(cr, &lx_b->background);
+ cairo_rectangle(cr, 0, 0, lx_b->width, lx_b->height);
+ cairo_fill(cr);
+ return;
}
+ /* draw background */
+ gdk_cairo_set_source_color(cr, &lx_b->background);
+ cairo_rectangle(cr, 0, 0, lx_b->width, lx_b->height);
+ cairo_fill(cr);
+
/* fixme: only one battery supported */
- rate = lx_b->b->current_now;
isCharging = battery_is_charging ( b );
/* Consider running the alarm command */
- if ( !isCharging && rate > 0 &&
- ( ( 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 +177,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 +188,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 );
+ hours,
+ minutes);
} else {
snprintf(tooltip, 256,
_("Battery: %d%% charged"),
@@ -236,8 +237,6 @@
cairo_fill(cr);
}
-
-update_done:
if( repaint )
gtk_widget_queue_draw( lx_b->drawingArea );
@@ -247,19 +246,12 @@
/* This callback is called every 3 seconds */
static int update_timout(lx_battery *lx_b) {
- battery *bat;
GDK_THREADS_ENTER();
lx_b->state_elapsed_time++;
lx_b->info_elapsed_time++;
- bat = battery_update( lx_b->b );
- if (bat == NULL)
- {
- battery_free(lx_b->b);
-
- /* maybe in the mean time a battery has been inserted. */
- lx_b->b = battery_get();
- }
+ /* check the batteries every 3 seconds */
+ battery_update( lx_b->b );
update_display( lx_b, TRUE );
@@ -346,6 +338,10 @@
/* get available battery */
lx_b->b = battery_get ();
+ /* no battery available */
+ if ( lx_b->b == NULL )
+ goto error;
+
p->pwid = gtk_event_box_new();
GTK_WIDGET_SET_FLAGS( p->pwid, GTK_NO_WINDOW );
gtk_container_set_border_width( GTK_CONTAINER(p->pwid), 1 );
@@ -380,7 +376,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;
@@ -409,8 +405,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")) {
@@ -477,9 +473,6 @@
lx_battery *b = (lx_battery *) p->priv;
- if (b->b != NULL)
- battery_free(b->b);
-
if (b->pixmap)
cairo_surface_destroy(b->pixmap);
@@ -562,7 +555,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,
@@ -582,7 +575,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);

View File

@ -1,304 +0,0 @@
--- ./src/plugins/batt/batt_sys.c.orig 2014-05-09 09:15:04.000000000 -0400
+++ ./src/plugins/batt/batt_sys.c 2014-05-27 18:14:06.000000000 -0400
@@ -39,26 +39,10 @@
static int battery_num = 1;
battery * b = g_new0 ( battery, 1 );
b->type_battery = TRUE;
- b->capacity_unit = "mAh";
- b->energy_full = -1;
- b->charge_full = -1;
- b->voltage_now = -1;
- b->energy_full_design = -1;
- b->charge_full_design = -1;
- b->energy_now = -1;
- b->charge_now = -1;
- b->current_now = -1;
- b->power_now = -1;
b->state = NULL;
- b->battery_num = battery_num;
- b->seconds = -1;
- b->percentage = -1;
- b->poststr = NULL;
- battery_num++;
return b;
}
-
static gchar* parse_info_file(battery *b, char *sys_file)
{
char *buf = NULL;
@@ -97,7 +81,7 @@
return parse_info_file(b, sys_file);
}
-void battery_print(battery *b, int show_capacity)
+void battery_print(battery *b)
{
if ( b->type_battery )
{
@@ -110,215 +94,65 @@
int seconds = b->seconds - 3600 * hours;
int minutes = seconds / 60;
seconds -= 60 * minutes;
- printf(", %02d:%02d:%02d%s", hours, minutes, seconds,
- b->poststr);
+ printf(", %02d:%02d:%02d", hours, minutes, seconds);
} else if (b->poststr != NULL) {
printf(", %s", b->poststr);
}
printf("\n");
- if (show_capacity && b->charge_full_design > 0) {
- int percentage = -1;
- int charge_full = -1;
- if (b->charge_full <= 100) {
- /* some broken systems just give a percentage here */
- percentage = b->charge_full;
- charge_full = percentage * b->charge_full_design / 100;
- } else {
- percentage = b->charge_full * 100 / b->charge_full_design;
- charge_full = b->charge_full;
- }
- if (percentage > 100)
- percentage = 100;
-
- printf ("%s %d: design capacity %d %s, "
- "last full capacity %d %s = %d%%\n",
- BATTERY_DESC, b->battery_num - 1, b->charge_full_design,
- b->capacity_unit, charge_full, b->capacity_unit,
- percentage);
- }
}
}
}
-static gboolean battery_inserted(gchar* path)
-{
- if (path == NULL)
- return FALSE;
-
- GString *dirname = g_string_new(ACPI_PATH_SYS_POWER_SUPPY);
- GDir *dir;
-
- g_string_append_printf (dirname, "/%s/", path);
- dir = g_dir_open(dirname->str, 0, NULL);
- if (dir)
- g_dir_close(dir);
- g_string_free(dirname, TRUE);
-
- return dir ? TRUE : FALSE;
-}
-
-
-battery* battery_update(battery *b)
+void battery_update(battery *b)
{
- gchar *gctmp;
-
- if (b == NULL)
- return NULL;
-
- if (!battery_inserted(b->path))
- return NULL;
-
- /* read from sysfs */
- b->charge_now = get_gint_from_infofile(b, "charge_now");
- b->energy_now = get_gint_from_infofile(b, "energy_now");
-
- b->current_now = get_gint_from_infofile(b, "current_now");
- b->power_now = get_gint_from_infofile(b, "power_now");
- /* FIXME: Some battery drivers report -1000 when the discharge rate is
- * unavailable. Others use negative values when discharging. Best we can do
- * is to treat -1 as an error, and take the absolute value otherwise.
- * Ideally the kernel would not export the sysfs file when the value is not
- * available. */
- if (b->current_now < -1)
- b->current_now = - b->current_now;
- if (b->power_now < -1)
- b->power_now = - b->power_now;
-
- b->charge_full = get_gint_from_infofile(b, "charge_full");
- b->energy_full = get_gint_from_infofile(b, "energy_full");
-
- b->charge_full_design = get_gint_from_infofile(b, "charge_full_design");
- b->energy_full_design = get_gint_from_infofile(b, "energy_full_design");
-
- b->voltage_now = get_gint_from_infofile(b, "voltage_now");
-
- gctmp = get_gchar_from_infofile(b, "type");
- b->type_battery = gctmp ? (strcasecmp(gctmp, "battery") == 0) : TRUE;
-
- b->state = get_gchar_from_infofile(b, "status");
- if (!b->state)
- b->state = get_gchar_from_infofile(b, "state");
- if (!b->state) {
- if (b->charge_now != -1 || b->energy_now != -1
- || b->charge_full != -1 || b->energy_full != -1)
- b->state = "available";
- else
- b->state = "unavailable";
- }
-
-
- /* convert energy values (in mWh) to charge values (in mAh) if needed and possible */
-
- if (b->energy_full != -1 && b->charge_full == -1) {
- if (b->voltage_now != -1 && b->voltage_now != 0) {
- b->charge_full = b->energy_full * 1000 / b->voltage_now;
- } else {
- b->charge_full = b->energy_full;
- b->capacity_unit = "mWh";
- }
- }
-
- if (b->energy_full_design != -1 && b->charge_full_design == -1) {
- if (b->voltage_now != -1 && b->voltage_now != 0) {
- b->charge_full_design = b->energy_full_design * 1000 / b->voltage_now;
- } else {
- b->charge_full_design = b->energy_full_design;
- b->capacity_unit = "mWh";
- }
- }
-
- if (b->energy_now != -1 && b->charge_now == -1) {
- if (b->voltage_now != -1 && b->voltage_now != 0) {
- b->charge_now = b->energy_now * 1000 / b->voltage_now;
- if (b->current_now != -1)
- b->current_now = b->current_now * 1000 / b->voltage_now;
- } else {
- b->charge_now = b->energy_now;
- }
- }
-
- if (b->power_now != -1 && b->current_now == -1) {
- if (b->voltage_now != -1 && b->voltage_now != 0)
- b->current_now = b->power_now * 1000 / b->voltage_now;
- }
-
-
- if (b->charge_full < MIN_CAPACITY)
- b->percentage = 0;
- else {
- int promille = (b->charge_now * 1000) / b->charge_full;
- b->percentage = (promille + 5) / 10; /* round properly */
- }
- if (b->percentage > 100)
- b->percentage = 100;
+ 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;
+
+ snprintf(sstmp, sizeof(sstmp), "hw.acpi.battery.state");
+ sysctlbyname(sstmp, &state, &intlen, NULL, 0);
- if (b->current_now == -1) {
- b->poststr = "rate information unavailable";
- b->seconds = -1;
- } else if (!strcasecmp(b->state, "charging")) {
- if (b->current_now > MIN_PRESENT_RATE) {
- b->seconds = 3600 * (b->charge_full - b->charge_now) / b->current_now;
- 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->current_now > MIN_PRESENT_RATE) {
- b->seconds = 3600 * b->charge_now / b->current_now;
- b->poststr = " remaining";
- } else {
- b->poststr = "discharging at zero rate - will never fully discharge.";
- b->seconds = -1;
- }
- } else {
- b->poststr = NULL;
- b->seconds = -1;
- }
+ 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->seconds = c * 60;
- return b;
}
-
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 = battery_new();
- b->path = g_strdup( entry );
- battery_update ( b );
- if ( b->type_battery == TRUE )
- break;
- /* ignore non-batteries */
- else {
- g_free(b);
- b = NULL;
- }
- }
- g_dir_close( dir );
+ battery *b = battery_new();
+ battery_update(b);
return b;
}
-void battery_free(battery* bat)
-{
- if (bat) {
- g_free(bat->path);
- g_free(bat);
- }
-}
-
gboolean battery_is_charging( battery *b )
{
if (!b->state)
@@ -327,11 +161,3 @@
strcasecmp( b->state, "Full" ) == 0
|| strcasecmp( b->state, "Charging" ) == 0 );
}
-
-gint battery_get_remaining( battery *b )
-{
- return b->seconds;
-}
-
-
-/* vim: set sw=4 et sts=4 : */

View File

@ -1,38 +0,0 @@
--- ./src/plugins/batt/batt_sys.h.orig 2014-05-09 09:15:04.000000000 -0400
+++ ./src/plugins/batt/batt_sys.h 2014-05-27 18:14:12.000000000 -0400
@@ -23,6 +23,12 @@
#ifndef BATT_SYS_H
#define BATT_SYS_H
+/* 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
#define BUF_SIZE 1024
#define ACPI_PATH_SYS_POWER_SUPPY "/sys/class/power_supply"
@@ -35,7 +41,7 @@
typedef struct battery {
int battery_num;
/* path to battery dir */
- gchar *path;
+ const gchar *path;
/* sysfs file contents */
int charge_now;
int energy_now;
@@ -55,10 +61,9 @@
} battery;
battery *battery_get();
-battery *battery_update( battery *b );
-void battery_print(battery *b, int show_capacity);
+void battery_update( battery *b );
+void battery_print(battery *b);
+void battery_reset(battery *b);
gboolean battery_is_charging( battery *b );
-gint battery_get_remaining( battery *b );
-void battery_free(battery* bat);
#endif

View File

@ -1,411 +0,0 @@
--- ./src/plugins/cpufreq/cpufreq.c.orig 2014-05-15 23:39:21.000000000 -0400
+++ ./src/plugins/cpufreq/cpufreq.c 2014-05-15 23:57:32.000000000 -0400
@@ -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,32 @@
} 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);
- }
-}
-
-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 0;
- }
-
- 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_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(G_OBJECT(menuitem), (GWeakNotify)g_free, param);
- }
- bufl = 0;
- buf[0] = '\0';
- }else{
- buf[bufl++] = c;
- }
- }
+ char sstmp [ 256 ];
+ int c;
+ size_t clen = sizeof c;
- fclose(fp);
- return GTK_WIDGET(menu);
+ 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_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", G_CALLBACK(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), GTK_WIDGET (menuitem));
- gtk_widget_show (GTK_WIDGET (menuitem));
- return GTK_WIDGET(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), GTK_WIDGET (menuitem));
- gtk_widget_show (GTK_WIDGET (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), GTK_WIDGET (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), GTK_WIDGET (menuitem));
- gtk_widget_show (GTK_WIDGET (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(G_OBJECT(menuitem), (GWeakNotify) g_free, param);
- }
-
- return GTK_WIDGET (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 +90,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 +112,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 +120,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 +135,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_seconds(2, (GSourceFunc)update_tooltip, (gpointer)cf);
@@ -400,53 +148,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
};

View File

@ -1,222 +0,0 @@
--- ./src/plugins/netstatus/netstatus-sysdeps.c.orig 2014-05-15 22:37:08.000000000 -0400
+++ ./src/plugins/netstatus/netstatus-sysdeps.c 2014-05-15 22:53:33.000000000 -0400
@@ -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;
}

View File

@ -1,462 +0,0 @@
--- ./src/plugins/thermal/Makefile.in.orig 2014-05-09 09:31:26.000000000 -0400
+++ ./src/plugins/thermal/Makefile.in 2014-05-20 09:47:15.000000000 -0400
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
-
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -15,51 +16,6 @@
@SET_MAKE@
VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
-am__make_running_with_option = \
- case $${target_option-} in \
- ?) ;; \
- *) echo "am__make_running_with_option: internal error: invalid" \
- "target option '$${target_option-}' specified" >&2; \
- exit 1;; \
- esac; \
- has_opt=no; \
- sane_makeflags=$$MAKEFLAGS; \
- if $(am__is_gnu_make); then \
- sane_makeflags=$$MFLAGS; \
- else \
- case $$MAKEFLAGS in \
- *\\[\ \ ]*) \
- bs=\\; \
- sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
- | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
- esac; \
- fi; \
- skip_next=no; \
- strip_trailopt () \
- { \
- flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
- }; \
- for flg in $$sane_makeflags; do \
- test $$skip_next = yes && { skip_next=no; continue; }; \
- case $$flg in \
- *=*|--*) continue;; \
- -*I) strip_trailopt 'I'; skip_next=yes;; \
- -*I?*) strip_trailopt 'I';; \
- -*O) strip_trailopt 'O'; skip_next=yes;; \
- -*O?*) strip_trailopt 'O';; \
- -*l) strip_trailopt 'l'; skip_next=yes;; \
- -*l?*) strip_trailopt 'l';; \
- -[dEDm]) skip_next=yes;; \
- -[JT]) skip_next=yes;; \
- esac; \
- case $$flg in \
- *$$target_option*) has_opt=yes; break;; \
- esac; \
- done; \
- test $$has_opt = yes
-am__make_dryrun = (target_option=n; $(am__make_running_with_option))
-am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -79,21 +35,13 @@
build_triplet = @build@
host_triplet = @host@
subdir = src/plugins/thermal
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
- $(top_srcdir)/mkinstalldirs $(top_srcdir)/depcomp
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
- $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intltool.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \
- $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
- $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
- $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@@ -118,37 +66,18 @@
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__uninstall_files_from_dir = { \
- test -z "$$files" \
- || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
- || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
- $(am__cd) "$$dir" && rm -f $$files; }; \
- }
am__installdirs = "$(DESTDIR)$(moduledir)"
LTLIBRARIES = $(module_LTLIBRARIES)
am__DEPENDENCIES_1 =
thermal_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_thermal_la_OBJECTS = thermal_la-thermal.lo
thermal_la_OBJECTS = $(am_thermal_la_OBJECTS)
-AM_V_lt = $(am__v_lt_@AM_V@)
-am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
-am__v_lt_1 =
thermal_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(thermal_la_CFLAGS) \
$(CFLAGS) $(thermal_la_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_P = $(am__v_P_@AM_V@)
-am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
-am__v_P_0 = false
-am__v_P_1 = :
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo " GEN " $@;
-am__v_GEN_1 =
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
-am__v_at_0 = @
-am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -159,42 +88,24 @@
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_@AM_V@)
-am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
-am__v_CC_0 = @echo " CC " $@;
-am__v_CC_1 =
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_@AM_V@)
-am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
-am__v_CCLD_0 = @echo " CCLD " $@;
-am__v_CCLD_1 =
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(thermal_la_SOURCES)
DIST_SOURCES = $(thermal_la_SOURCES)
-am__can_run_installinfo = \
- case $$AM_UPDATE_INFO_DIR in \
- n|no|NO) false;; \
- *) (install-info --version) >/dev/null 2>&1;; \
- esac
-am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
-# Read a list of newline-separated strings from the standard input,
-# and print each of them once, without duplicates. Input order is
-# *not* preserved.
-am__uniquify_input = $(AWK) '\
- BEGIN { nonempty = 0; } \
- { items[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in items) print i; }; } \
-'
-# Make sure the list of sources is unique. This is necessary because,
-# e.g., the same source file might be shared among _SOURCES variables
-# for different programs/libraries.
-am__define_uniq_tagged_files = \
- list='$(am__tagged_files)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -204,8 +115,6 @@
ALL_PLUGINS_LIST = @ALL_PLUGINS_LIST@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-APPLET_CFLAGS = @APPLET_CFLAGS@
-APPLET_LIBS = @APPLET_LIBS@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -236,8 +145,6 @@
GMSGFMT = @GMSGFMT@
GREP = @GREP@
G_CAST_CHECKS = @G_CAST_CHECKS@
-INDICATORDIR = @INDICATORDIR@
-INDICATORICONSDIR = @INDICATORICONSDIR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -249,21 +156,13 @@
INTLTOOL_MERGE = @INTLTOOL_MERGE@
INTLTOOL_PERL = @INTLTOOL_PERL@
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
-INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@
-INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@
-INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@
-INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@
LD = @LD@
LDFLAGS = @LDFLAGS@
-LIBICONV = @LIBICONV@
-LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
-LTLIBICONV = @LTLIBICONV@
-LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
LXPANEL_MODULE = @LXPANEL_MODULE@
MAKEINFO = @MAKEINFO@
@@ -306,8 +205,6 @@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
-WNCK_CFLAGS = @WNCK_CFLAGS@
-WNCK_LIBS = @WNCK_LIBS@
X11_CFLAGS = @X11_CFLAGS@
X11_LIBS = @X11_LIBS@
XGETTEXT = @XGETTEXT@
@@ -348,8 +245,6 @@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
-intltool__v_merge_options_ = @intltool__v_merge_options_@
-intltool__v_merge_options_0 = @intltool__v_merge_options_0@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
@@ -421,9 +316,9 @@
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
-
install-moduleLTLIBRARIES: $(module_LTLIBRARIES)
@$(NORMAL_INSTALL)
+ test -z "$(moduledir)" || $(MKDIR_P) "$(DESTDIR)$(moduledir)"
@list='$(module_LTLIBRARIES)'; test -n "$(moduledir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
@@ -431,8 +326,6 @@
else :; fi; \
done; \
test -z "$$list2" || { \
- echo " $(MKDIR_P) '$(DESTDIR)$(moduledir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(moduledir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(moduledir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(moduledir)"; \
}
@@ -448,16 +341,13 @@
clean-moduleLTLIBRARIES:
-test -z "$(module_LTLIBRARIES)" || rm -f $(module_LTLIBRARIES)
- @list='$(module_LTLIBRARIES)'; \
- locs=`for p in $$list; do echo $$p; done | \
- sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
- sort -u`; \
- test -z "$$locs" || { \
- echo rm -f $${locs}; \
- rm -f $${locs}; \
- }
-
-thermal.la: $(thermal_la_OBJECTS) $(thermal_la_DEPENDENCIES) $(EXTRA_thermal_la_DEPENDENCIES)
+ @list='$(module_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+thermal.la: $(thermal_la_OBJECTS) $(thermal_la_DEPENDENCIES)
$(AM_V_CCLD)$(thermal_la_LINK) -rpath $(moduledir) $(thermal_la_OBJECTS) $(thermal_la_LIBADD) $(LIBS)
mostlyclean-compile:
@@ -471,30 +361,34 @@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
thermal_la-thermal.lo: thermal.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(thermal_la_CFLAGS) $(CFLAGS) -MT thermal_la-thermal.lo -MD -MP -MF $(DEPDIR)/thermal_la-thermal.Tpo -c -o thermal_la-thermal.lo `test -f 'thermal.c' || echo '$(srcdir)/'`thermal.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/thermal_la-thermal.Tpo $(DEPDIR)/thermal_la-thermal.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='thermal.c' object='thermal_la-thermal.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='thermal.c' object='thermal_la-thermal.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(thermal_la_CFLAGS) $(CFLAGS) -c -o thermal_la-thermal.lo `test -f 'thermal.c' || echo '$(srcdir)/'`thermal.c
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(thermal_la_CFLAGS) $(CFLAGS) -c -o thermal_la-thermal.lo `test -f 'thermal.c' || echo '$(srcdir)/'`thermal.c
mostlyclean-libtool:
-rm -f *.lo
@@ -502,15 +396,26 @@
clean-libtool:
-rm -rf .libs _libs
-ID: $(am__tagged_files)
- $(am__define_uniq_tagged_files); mkid -fID $$unique
-tags: tags-am
-TAGS: tags
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
-tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
- $(am__define_uniq_tagged_files); \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
@@ -522,11 +427,15 @@
$$unique; \
fi; \
fi
-ctags: ctags-am
-
-CTAGS: ctags
-ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
- $(am__define_uniq_tagged_files); \
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
@@ -535,21 +444,6 @@
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
-cscopelist: cscopelist-am
-
-cscopelist-am: $(am__tagged_files)
- list='$(am__tagged_files)'; \
- case "$(srcdir)" in \
- [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
- *) sdir=$(subdir)/$(srcdir) ;; \
- esac; \
- for i in $$list; do \
- if test -f "$$i"; then \
- echo "$(subdir)/$$i"; \
- else \
- echo "$$sdir/$$i"; \
- fi; \
- done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -601,15 +495,10 @@
installcheck: installcheck-am
install-strip:
- if test -z '$(STRIP)'; then \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- install; \
- else \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
- fi
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
@@ -694,20 +583,19 @@
.MAKE: install-am install-strip
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-moduleLTLIBRARIES cscopelist-am ctags \
- ctags-am distclean distclean-compile distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-moduleLTLIBRARIES \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
- pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
- uninstall-moduleLTLIBRARIES
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-moduleLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-moduleLTLIBRARIES install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-moduleLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.

View File

@ -1,493 +0,0 @@
--- ./src/plugins/thermal/thermal.c.orig 2014-05-09 08:55:42.000000000 -0400
+++ ./src/plugins/thermal/thermal.c 2014-05-20 09:56:16.000000000 -0400
@@ -32,29 +32,17 @@
#include "dbg.h"
-#define PROC_THERMAL_DIRECTORY "/proc/acpi/thermal_zone/" /* must be slash-terminated */
-#define PROC_THERMAL_TEMPF "temperature"
-#define PROC_THERMAL_TRIP "trip_points"
-#define PROC_TRIP_CRITICAL "critical (S5):"
-
-#define SYSFS_THERMAL_DIRECTORY "/sys/class/thermal/" /* must be slash-terminated */
-#define SYSFS_THERMAL_SUBDIR_PREFIX "thermal_zone"
-#define SYSFS_THERMAL_TEMPF "temp"
-#define SYSFS_THERMAL_TRIP "trip_point_0_temp"
-
-#define MAX_NUM_SENSORS 10
-#define MAX_AUTOMATIC_CRITICAL_TEMP 150 /* in degrees Celsius */
-
+#include <sys/sysctl.h>
-typedef struct thermal {
+typedef struct {
Plugin * plugin;
GtkWidget *main;
GtkWidget *namew;
- GString *tip;
+ GtkTooltips *tip;
int critical;
int warning1;
int warning2;
- int not_custom_levels, auto_sensor;
+ int custom_levels, auto_sensor;
char *sensor,
*str_cl_normal,
*str_cl_warning1,
@@ -63,197 +51,43 @@
GdkColor cl_normal,
cl_warning1,
cl_warning2;
- int numsensors;
- char *sensor_array[MAX_NUM_SENSORS];
- gint (*get_temperature[MAX_NUM_SENSORS])(char const* sensor_path);
- gint (*get_critical[MAX_NUM_SENSORS])(char const* sensor_path);
- gint temperature[MAX_NUM_SENSORS];
} thermal;
-
-static gint
-proc_get_critical(char const* sensor_path){
- FILE *state;
- char buf[ 256 ], sstmp [ 100 ];
- char* pstr;
-
- if(sensor_path == NULL) return -1;
-
- sprintf(sstmp,"%s%s",sensor_path,PROC_THERMAL_TRIP);
-
- if (!(state = fopen( sstmp, "r"))) {
- ERR("thermal: cannot open %s\n", sstmp);
- return -1;
- }
-
- while( fgets(buf, 256, state) &&
- ! ( pstr = strstr(buf, PROC_TRIP_CRITICAL) ) );
- if( pstr )
- {
- pstr += strlen(PROC_TRIP_CRITICAL);
- while( *pstr && *pstr == ' ' )
- ++pstr;
-
- pstr[strlen(pstr)-3] = '\0';
- fclose(state);
- return atoi(pstr);
- }
-
- fclose(state);
- return -1;
-}
-
-static gint
-proc_get_temperature(char const* sensor_path){
- FILE *state;
- char buf[ 256 ], sstmp [ 100 ];
- char* pstr;
-
- if(sensor_path == NULL) return -1;
-
- sprintf(sstmp,"%s%s",sensor_path,PROC_THERMAL_TEMPF);
-
- if (!(state = fopen( sstmp, "r"))) {
- ERR("thermal: cannot open %s\n", sstmp);
- return -1;
- }
-
- while( fgets(buf, 256, state) &&
- ! ( pstr = strstr(buf, "temperature:") ) );
- if( pstr )
- {
- pstr += 12;
- while( *pstr && *pstr == ' ' )
- ++pstr;
-
- pstr[strlen(pstr)-3] = '\0';
- fclose(state);
- return atoi(pstr);
- }
-
- fclose(state);
- return -1;
-}
-
static gint
-sysfs_get_critical(char const* sensor_path){
- FILE *state;
- char buf[ 256 ], sstmp [ 100 ];
- char* pstr;
-
- if(sensor_path == NULL) return -1;
-
- sprintf(sstmp,"%s%s",sensor_path,SYSFS_THERMAL_TRIP);
+get_temperature_value(thermal *th, const char *which)
+{
+ char sstmp[ 100 ];
+ int t;
+ size_t tlen = sizeof t;
- if (!(state = fopen( sstmp, "r"))) {
- ERR("thermal: cannot open %s\n", sstmp);
- return -1;
- }
+ if(th->sensor == NULL) return -1;
- while( fgets(buf, 256, state) &&
- ! ( pstr = buf ) );
- if( pstr )
- {
- fclose(state);
- return atoi(pstr)/1000;
- }
+ 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
-sysfs_get_temperature(char const* sensor_path){
- FILE *state;
- char buf[ 256 ], sstmp [ 100 ];
- char* pstr;
-
- if(sensor_path == NULL) return -1;
-
- sprintf(sstmp,"%s%s",sensor_path,SYSFS_THERMAL_TEMPF);
-
- if (!(state = fopen( sstmp, "r"))) {
- ERR("thermal: cannot open %s\n", sstmp);
- return -1;
- }
-
- while (fgets(buf, 256, state) &&
- ! ( pstr = buf ) );
- if( pstr )
- {
- fclose(state);
- return atoi(pstr)/1000;
- }
-
- fclose(state);
- return -1;
-}
-
-static gboolean
-is_sysfs(char const* path)
-{
- return path && strncmp(path, "/sys/", 5) == 0;
-}
-
-/* get_temp_function():
- * - This function is called 'get_temp_function'.
- * - It takes 'path' as argument.
- * - It returns a pointer to a function.
- * - The returned function takes a pointer to a char const as arg.
- * - The returned function returns a gint. */
-static gint (*get_temp_function(char const* path))(char const* sensor_path)
-{
- if (is_sysfs(path))
- return sysfs_get_temperature;
- else
- return proc_get_temperature;
-}
-
-static gint (*get_crit_function(char const* path))(char const* sensor_path)
-{
- if (is_sysfs(path))
- return sysfs_get_critical;
- else
- return proc_get_critical;
-}
-
-static gint get_temperature(thermal *th)
+get_critical(thermal *th)
{
- gint max = -273;
- gint cur, i;
-
- for(i = 0; i < th->numsensors; i++){
- cur = th->get_temperature[i](th->sensor_array[i]);
- if (cur > max)
- max = cur;
- th->temperature[i] = cur;
- }
-
- return max;
+ return (get_temperature_value(th, "_CRT"));
}
-static gint get_critical(thermal *th)
+static gint
+get_temperature(thermal *th)
{
- gint min = MAX_AUTOMATIC_CRITICAL_TEMP;
- gint cur, i;
-
- for(i = 0; i < th->numsensors; i++){
- cur = th->get_critical[i](th->sensor_array[i]);
- if (cur < min)
- min = cur;
- }
-
- return min;
+ return (get_temperature_value(th, "temperature"));
}
static gint
update_display(thermal *th)
{
char buffer [60];
- int i;
+ int n;
int temp = get_temperature(th);
GdkColor color;
- gchar *separator;
if(temp >= th->warning2)
color = th->cl_warning2;
@@ -264,117 +98,20 @@
ENTER;
if(temp == -1)
- panel_draw_label_text(th->plugin->panel, th->namew, "NA", TRUE, 1, TRUE);
+ panel_draw_label_text(th->plugin->panel, th->namew, "NA", TRUE, 1, TRUE);
else
{
- 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) ;
}
- g_string_truncate(th->tip, 0);
- separator = "";
- for (i = 0; i < th->numsensors; i++){
- g_string_append_printf(th->tip, "%s%s:\t%2d°C", separator, th->sensor_array[i], th->temperature[i]);
- separator = "\n";
- }
- gtk_widget_set_tooltip_text(th->namew, th->tip->str);
-
RET(TRUE);
}
-
-static int
-add_sensor(thermal* th, char const* sensor_path)
-{
- if (th->numsensors + 1 > MAX_NUM_SENSORS){
- ERR("thermal: Too many sensors (max %d), ignoring '%s'\n",
- MAX_NUM_SENSORS, sensor_path);
- return -1;
- }
-
- th->sensor_array[th->numsensors] = g_strdup(sensor_path);
- th->get_critical[th->numsensors] = get_crit_function(sensor_path);
- th->get_temperature[th->numsensors] = get_temp_function(sensor_path);
- th->numsensors++;
-
- LOG(LOG_ALL, "thermal: Added sensor %s\n", sensor_path);
-
- return 0;
-}
-
-/* find_sensors():
- * - Get the sensor directory, and store it in '*sensor'.
- * - It is searched for in 'directory'.
- * - Only the subdirectories starting with 'subdir_prefix' are accepted as sensors.
- * - 'subdir_prefix' may be NULL, in which case any subdir is considered a sensor. */
-static void
-find_sensors(thermal* th, char const* directory, char const* subdir_prefix)
-{
- GDir *sensorsDirectory;
- const char *sensor_name;
- char sensor_path[100];
-
- if (! (sensorsDirectory = g_dir_open(directory, 0, NULL)))
- return;
-
- /* Scan the thermal_zone directory for available sensors */
- while ((sensor_name = g_dir_read_name(sensorsDirectory))) {
- if (sensor_name[0] == '.')
- continue;
- if (subdir_prefix) {
- if (strncmp(sensor_name, subdir_prefix, strlen(subdir_prefix)) != 0)
- continue;
- }
- sprintf(sensor_path,"%s%s/", directory, sensor_name);
- add_sensor(th, sensor_path);
- }
- g_dir_close(sensorsDirectory);
-}
-
-static void
-remove_all_sensors(thermal *th)
-{
- int i;
-
- LOG(LOG_ALL, "thermal: Removing all sensors (%d)\n", th->numsensors);
-
- for (i = 0; i < th->numsensors; i++)
- g_free(th->sensor_array[i]);
-
- th->numsensors = 0;
-}
-
static void
-check_sensors( thermal *th )
-{
- find_sensors(th, PROC_THERMAL_DIRECTORY, NULL);
- find_sensors(th, SYSFS_THERMAL_DIRECTORY, SYSFS_THERMAL_SUBDIR_PREFIX);
- LOG(LOG_INFO, "thermal: Found %d sensors\n", th->numsensors);
-}
-
-
-static void applyConfig(Plugin* p)
+check_sensors( thermal* th )
{
- thermal *th = p->priv;
- ENTER;
-
- if (th->str_cl_normal) gdk_color_parse(th->str_cl_normal, &th->cl_normal);
- if (th->str_cl_warning1) gdk_color_parse(th->str_cl_warning1, &th->cl_warning1);
- if (th->str_cl_warning2) gdk_color_parse(th->str_cl_warning2, &th->cl_warning2);
-
- remove_all_sensors(th);
- if(th->sensor == NULL) th->auto_sensor = TRUE;
- if(th->auto_sensor) check_sensors(th);
- else add_sensor(th, th->sensor);
-
- th->critical = get_critical(th);
-
- if(th->not_custom_levels){
- th->warning1 = th->critical - 10;
- th->warning2 = th->critical - 5;
- }
-
- RET();
+ th->sensor = strdup("tz0");
}
static int
@@ -395,12 +132,7 @@
gtk_container_add(GTK_CONTAINER(p->pwid), th->namew);
th->main = p->pwid;
- th->tip = g_string_new(NULL);
-
- /* By default, use automatic, that is, "not custom" temperature levels. If
- * we were using custom levels, they would be 0°C at startup, so we would
- * display in warning colors by default. */
- th->not_custom_levels = TRUE;
+ th->tip = gtk_tooltips_new();
g_signal_connect (G_OBJECT (p->pwid), "button_press_event",
G_CALLBACK (plugin_button_press_event), (gpointer) p);
@@ -425,7 +157,7 @@
}else if (!g_ascii_strcasecmp(s.t[0], "AutomaticSensor")){
th->auto_sensor= atoi(s.t[1]);
}else if (!g_ascii_strcasecmp(s.t[0], "CustomLevels")){
- th->not_custom_levels= atoi(s.t[1]);
+ th->custom_levels= atoi(s.t[1]);
}else if (!g_ascii_strcasecmp(s.t[0], "Sensor")){
th->sensor= g_strdup(s.t[1]);
}else if (!g_ascii_strcasecmp(s.t[0], "Warning1Temp")){
@@ -441,6 +173,7 @@
goto error;
}
}
+
}
if(!th->str_cl_normal)
@@ -450,12 +183,25 @@
if(!th->str_cl_warning2)
th->str_cl_warning2 = g_strdup("#ff0000");
- applyConfig(p);
+ gdk_color_parse(th->str_cl_normal, &(th->cl_normal));
+ gdk_color_parse(th->str_cl_warning1, &(th->cl_warning1));
+ gdk_color_parse(th->str_cl_warning2, &(th->cl_warning2));
+
+
+ if(th->sensor == NULL) th->auto_sensor = TRUE;
+ if(th->auto_sensor) check_sensors(th);
+
+ th->critical = get_critical(th);
+
+ if(!th->custom_levels){
+ th->warning1 = th->critical - 10;
+ th->warning2 = th->critical - 5;
+ }
gtk_widget_show(th->namew);
update_display(th);
- th->timer = g_timeout_add_seconds(3, (GSourceFunc) update_display, (gpointer)th);
+ th->timer = g_timeout_add(1000, (GSourceFunc) update_display, (gpointer)th);
RET(TRUE);
@@ -463,6 +209,27 @@
RET(FALSE);
}
+static void applyConfig(Plugin* p)
+{
+
+ thermal *th = (thermal *)p->priv;
+
+ ENTER;
+
+ if (th->str_cl_normal) gdk_color_parse(th->str_cl_normal, &th->cl_normal);
+ if (th->str_cl_warning1) gdk_color_parse(th->str_cl_warning1, &th->cl_warning1);
+ if (th->str_cl_warning2) gdk_color_parse(th->str_cl_warning2, &th->cl_warning2);
+
+ if(th->auto_sensor) check_sensors(th);
+
+ if(th->custom_levels){
+ th->warning1 = th->critical - 10;
+ th->warning2 = th->critical - 5;
+ }
+
+ RET();
+}
+
static void config(Plugin *p, GtkWindow* parent) {
ENTER;
@@ -476,7 +243,7 @@
_("Warning2"), &th->str_cl_warning2, CONF_TYPE_STR,
_("Automatic sensor location"), &th->auto_sensor, CONF_TYPE_BOOL,
_("Sensor"), &th->sensor, CONF_TYPE_STR,
- _("Automatic temperature levels"), &th->not_custom_levels, CONF_TYPE_BOOL,
+ _("Automatic temperature levels"), &th->custom_levels, CONF_TYPE_BOOL,
_("Warning1 Temperature"), &th->warning1, CONF_TYPE_INT,
_("Warning2 Temperature"), &th->warning2, CONF_TYPE_INT,
NULL);
@@ -492,8 +259,6 @@
ENTER;
th = (thermal *) p->priv;
- remove_all_sensors(th);
- g_string_free(th->tip, TRUE);
g_free(th->sensor);
g_free(th->str_cl_normal);
g_free(th->str_cl_warning1);
@@ -510,7 +275,7 @@
lxpanel_put_str( fp, "NormalColor", th->str_cl_normal );
lxpanel_put_str( fp, "Warning1Color", th->str_cl_warning1 );
lxpanel_put_str( fp, "Warning2Color", th->str_cl_warning2 );
- lxpanel_put_int( fp, "CustomLevels", th->not_custom_levels );
+ lxpanel_put_int( fp, "CustomLevels", th->custom_levels );
lxpanel_put_int( fp, "Warning1Temp", th->warning1 );
lxpanel_put_int( fp, "Warning2Temp", th->warning2 );
lxpanel_put_int( fp, "AutomaticSensor", th->auto_sensor );
@@ -532,6 +297,3 @@
save : save_config,
panel_configuration_changed : NULL
};
-
-
-/* vim: set sw=4 sts=4 et : */

View File

@ -1,24 +0,0 @@
===============================================================================
LXPanel has been installed.
Additional features require devd and HAL:
echo devd_enable=\"YES\" >> /etc/rc.conf
service devd start
cd /usr/ports/sysutils/hal/ && make install clean
echo hald_enable=\"YES\" >> /etc/rc.conf
service hald start
Some plugins require linprocfs and linsysfs:
mkdir -p /mnt/compat/linux/proc
echo "linproc /compat/linux/proc linprocfs rw 0 0" >> /etc/fstab
mount -t linprocfs linproc /compat/linux/proc
mkdir -p /mnt/compat/linux/sys
echo "linsys /compat/linux/sys linsysfs rw 0 0" >> /etc/fstab
mount -t linsysfs linsys /compat/linux/sys
===============================================================================

View File

@ -1,18 +1,26 @@
bin/lxpanel
bin/lxpanelctl
etc/xdg/lxpanel/default/config
etc/xdg/lxpanel/default/panels/panel
etc/xdg/lxpanel/two_panels/config
etc/xdg/lxpanel/two_panels/panels/bottom
etc/xdg/lxpanel/two_panels/panels/top
include/lxpanel/conf.h
include/lxpanel/icon-grid.h
include/lxpanel/misc.h
include/lxpanel/panel.h
include/lxpanel/plugin.h
lib/lxpanel/plugins/batt.so
lib/lxpanel/liblxpanel.so
lib/lxpanel/liblxpanel.so.0
lib/lxpanel/liblxpanel.so.0.0.0
lib/lxpanel/plugins/cpu.so
lib/lxpanel/plugins/cpufreq.so
lib/lxpanel/plugins/deskno.so
lib/lxpanel/plugins/kbled.so
lib/lxpanel/plugins/monitors.so
lib/lxpanel/plugins/netstatus.so
lib/lxpanel/plugins/thermal.so
%%NO_ALSA%%lib/lxpanel/plugins/volume.so
%%ALSA%%lib/lxpanel/plugins/volumealsa.so
lib/lxpanel/plugins/volume.so
%%WEATHER%%lib/lxpanel/plugins/weather.so
lib/lxpanel/plugins/xkb.so
lib/lxpanel/plugins/wnckpager.so
libdata/pkgconfig/lxpanel.pc
man/man1/lxpanel.1.gz
man/man1/lxpanelctl.1.gz
@ -29,7 +37,6 @@ man/man1/lxpanelctl.1.gz
%%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
@ -42,6 +49,7 @@ man/man1/lxpanelctl.1.gz
%%NLS%%share/locale/hr/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/hu/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/id/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/is/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/it/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/ja/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/kk/LC_MESSAGES/lxpanel.mo
@ -49,6 +57,7 @@ man/man1/lxpanelctl.1.gz
%%NLS%%share/locale/ko/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/lg/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/lt/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/lv/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
@ -76,6 +85,7 @@ man/man1/lxpanelctl.1.gz
%%NLS%%share/locale/ur_PK/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/vi/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/zh_CN/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/zh_HK/LC_MESSAGES/lxpanel.mo
%%NLS%%share/locale/zh_TW/LC_MESSAGES/lxpanel.mo
%%DATADIR%%/images/background.png
%%DATADIR%%/images/capslock-off.png
@ -83,6 +93,7 @@ man/man1/lxpanelctl.1.gz
%%DATADIR%%/images/clock.png
%%DATADIR%%/images/cpufreq-icon.png
%%DATADIR%%/images/file-manager.png
%%DATADIR%%/images/gnome-fs-desktop.png
%%DATADIR%%/images/gnome-logout.png
%%DATADIR%%/images/gnome-netstatus-0-24.png
%%DATADIR%%/images/gnome-netstatus-25-49.png
@ -111,6 +122,7 @@ man/man1/lxpanelctl.1.gz
%%DATADIR%%/images/volume-high.png
%%DATADIR%%/images/volume-low.png
%%DATADIR%%/images/volume-medium.png
%%DATADIR%%/images/volume.png
%%DATADIR%%/images/window-manager.png
%%DATADIR%%/images/xkb-flags/ad.png
%%DATADIR%%/images/xkb-flags/ae.png
@ -150,6 +162,7 @@ man/man1/lxpanelctl.1.gz
%%DATADIR%%/images/xkb-flags/epo.png
%%DATADIR%%/images/xkb-flags/es.png
%%DATADIR%%/images/xkb-flags/et.png
%%DATADIR%%/images/xkb-flags/eu.png
%%DATADIR%%/images/xkb-flags/fi.png
%%DATADIR%%/images/xkb-flags/fo.png
%%DATADIR%%/images/xkb-flags/fr.png
@ -203,8 +216,10 @@ man/man1/lxpanelctl.1.gz
%%DATADIR%%/images/xkb-flags/ph.png
%%DATADIR%%/images/xkb-flags/pk.png
%%DATADIR%%/images/xkb-flags/pl.png
%%DATADIR%%/images/xkb-flags/ps.png
%%DATADIR%%/images/xkb-flags/pt.png
%%DATADIR%%/images/xkb-flags/qa.png
%%DATADIR%%/images/xkb-flags/qc.png
%%DATADIR%%/images/xkb-flags/ro.png
%%DATADIR%%/images/xkb-flags/rs.png
%%DATADIR%%/images/xkb-flags/ru.png
@ -225,18 +240,16 @@ man/man1/lxpanelctl.1.gz
%%DATADIR%%/images/xkb-flags/tw.png
%%DATADIR%%/images/xkb-flags/tz.png
%%DATADIR%%/images/xkb-flags/ua.png
%%DATADIR%%/images/xkb-flags/uk.png
%%DATADIR%%/images/xkb-flags/un.png
%%DATADIR%%/images/xkb-flags/us.png
%%DATADIR%%/images/xkb-flags/uy.png
%%DATADIR%%/images/xkb-flags/uz.png
%%DATADIR%%/images/xkb-flags/vn.png
%%DATADIR%%/images/xkb-flags/ye.png
%%DATADIR%%/images/xkb-flags/yu.png
%%DATADIR%%/images/xkb-flags/za.png
%%DATADIR%%/profile/default/config
%%DATADIR%%/profile/default/panels/panel
%%DATADIR%%/profile/two_panels/config
%%DATADIR%%/profile/two_panels/panels/bottom
%%DATADIR%%/profile/two_panels/panels/top
%%DATADIR%%/ui/launchbar.ui
%%DATADIR%%/ui/launchtaskbar.ui
%%DATADIR%%/ui/netstatus.ui
%%DATADIR%%/ui/panel-pref.ui
%%DATADIR%%/xkeyboardconfig/layouts.cfg