Hello community, here is the log from the commit of package xosview for openSUSE:Factory checked in at 2015-01-20 19:01:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/xosview (Old) and /work/SRC/openSUSE:Factory/.xosview.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "xosview" Changes: -------- --- /work/SRC/openSUSE:Factory/xosview/xosview.changes 2014-10-06 22:05:01.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.xosview.new/xosview.changes 2015-01-20 19:01:16.000000000 +0100 @@ -1,0 +2,49 @@ +Sat Jan 17 04:14:45 UTC 2015 - [email protected] + +- Update to version 1.16: + + Changes from 1.14 to 1.15: + - Build system changes for GNU/Hurd + - Add 64-bit support for ARM and PPC to MeterMaker + - Increase MAX_PROCSTAT_LENGTH + - Make Buffer size for interrupt meter an overall variable + - Change USE_SYSCALLS to 0, to reduce I/O load + - Read /usr/share/X11/app-defaults/xosview if available + - Avoid removable and loop devices in disk stats + - Do not ignore removable devices + - Re-enable background pixmaps + - Use XPM handling by default + - Add command line shorthand for seeing all CPU cores + seperately + - Kernel disk stats are always in 512-byte units + - Do not ignore floppy disks in diskmeter + + Changes from 1.15 to 1.16 + - Added keywords entry in desktop file + - New battery meter for *BSD + - Support DragonflyBSD 4.3 in netmeter + - Use correct size integer for sysctl return value + - Use snprintf() instead of std::ostringstream when + updating speed in loadmeter + - Make loadmeter autoscaling predictable + + Patches Refactored, and deversioned, xosview-1.14.dif renamed + to xosview-configuration.patch + + Removed: + - xosview-1.14.tar.gz + - xosview-1.14.dif + - xosview-1.14-appdef.dif + - xosview-1.14-diskstat.dif + - xosview-1.14-maxlimit.patch + - xosview-1.14-longint.patch + - xosview-1.14-pixmap.patch + - xosview-1.14-serial.patch + - xosview-1.14-sysinfo.patch + + Added: + - xosview-1.16.tar.gz + - xosview-configuration.patch + - xosview-appdef.patch + - xosview-diskstat.patch + - xosview-maxlimit.patch + - xosview-pixmap.patch + - xosview-serial.patch + - xosview-sysinfo.patch + +------------------------------------------------------------------- Old: ---- xosview-1.14-appdef.dif xosview-1.14-diskstat.dif xosview-1.14-longint.patch xosview-1.14-maxlimit.patch xosview-1.14-pixmap.patch xosview-1.14-serial.patch xosview-1.14-sysinfo.patch xosview-1.14.dif xosview-1.14.tar.gz New: ---- xosview-1.16.tar.gz xosview-appdef.patch xosview-configuration.patch xosview-diskstat.patch xosview-maxlimit.patch xosview-pixmap.patch xosview-serial.patch xosview-sysinfo.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ xosview.spec ++++++ --- /var/tmp/diff_new_pack.Rz9zqX/_old 2015-01-20 19:01:17.000000000 +0100 +++ /var/tmp/diff_new_pack.Rz9zqX/_new 2015-01-20 19:01:17.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package xosview # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -27,27 +27,26 @@ #Requires: desktop-data-SuSE # This because /usr/bin/xrdb is part of xorg-x11 Requires: xorg-x11 -Version: 1.14 +Version: 1.16 Release: 0 Summary: System Load Information License: GPL-2.0+ Group: System/Monitoring -Url: https://github.com/hills/xosview +Url: http://www.pogo.org.uk/~mark/xosview/ Source: xosview-%{version}.tar.gz Source1: rc.config.xosview Source2: xosview.png Source3: xosview.desktop Source4: xosview.sh Source5: xosview-rpmlintrc -Patch: xosview-%{version}.dif -Patch1: xosview-%{version}-serial.patch -Patch3: xosview-%{version}-maxlimit.patch -Patch7: xosview-%{version}-longint.patch -Patch8: xosview-%{version}-sysinfo.patch -Patch10: xosview-%{version}-appdef.dif -Patch11: xosview-%{version}-diskstat.dif +Patch1: xosview-serial.patch +Patch3: xosview-maxlimit.patch +Patch8: xosview-sysinfo.patch +Patch10: xosview-appdef.patch +Patch11: xosview-diskstat.patch # PATCH-FIX-OPENSUSE: Re-add xpm background pximap support (bnc#817558) -Patch12: xosview-%{version}-pixmap.patch +Patch12: xosview-pixmap.patch +Patch13: xosview-configuration.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %define _appdefdir %{_datadir}/X11/app-defaults @@ -58,14 +57,13 @@ %prep %setup -q -%patch1 -p0 -b .serial -%patch3 -p0 -b .maxlimit -%patch7 -p0 -b .ulong -%patch8 -p0 -b .sysinfo -%patch10 -p0 -b .appdef -%patch11 -p0 -b .diskstat -%patch12 -p0 -b .pixmap -%patch +%patch1 -p1 +%patch3 -p1 +%patch8 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 %build OPTFLAGS="$RPM_OPT_FLAGS" ++++++ xosview-1.14.tar.gz -> xosview-1.16.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/Makefile new/xosview-1.16/Makefile --- old/xosview-1.14/Makefile 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/Makefile 2013-08-23 11:40:35.000000000 +0200 @@ -18,7 +18,7 @@ # Required build arguments CPPFLAGS += $(OPTFLAGS) -I. -MMD -LDLIBS += -lX11 +LDLIBS += -lX11 -lXpm OBJS = Host.o \ Xrm.o \ @@ -98,6 +98,16 @@ CPPFLAGS += -Isunos5/ endif +ifeq ($(PLATFORM), gnu) +OBJS += gnu/get_def_pager.o \ + gnu/loadmeter.o \ + gnu/memmeter.o \ + gnu/MeterMaker.o \ + gnu/pagemeter.o \ + gnu/swapmeter.o +CPPFLAGS += -Ignu/ +endif + DEPS := $(OBJS:.o=.d) xosview: $(OBJS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/README new/xosview-1.16/README --- old/xosview-1.14/README 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/README 2013-08-23 11:40:35.000000000 +0200 @@ -22,6 +22,7 @@ $ make PLATFORM=bsd $ make PLATFORM=irix65 $ make PLATFORM=sunos5 + $ make PLATFORM=gnu Please see the README file for your platform for any special instructions for running xosview on that platform. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/README.gnu new/xosview-1.16/README.gnu --- old/xosview-1.14/README.gnu 1970-01-01 01:00:00.000000000 +0100 +++ new/xosview-1.16/README.gnu 2013-08-23 11:40:35.000000000 +0200 @@ -0,0 +1,2 @@ + Support for GNU/Hurd added by Samuel Thibault ([email protected]). + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/Xrm.cc new/xosview-1.16/Xrm.cc --- old/xosview-1.14/Xrm.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/Xrm.cc 2013-08-23 11:40:35.000000000 +0200 @@ -154,6 +154,10 @@ XrmQuarkToString(_class)); if (result >= 0 && result < rlen) XrmCombineFileDatabase (rfilename, &_db, 1); + result = snprintf(rfilename, sizeof rfilename, "/usr/share/X11/app-defaults/%s", + XrmQuarkToString(_class)); + if (result >= 0 && result < rlen) + XrmCombineFileDatabase (rfilename, &_db, 1); // Try a few more, for SunOS/Solaris folks. result = snprintf(rfilename, sizeof rfilename, "/usr/openwin/lib/X11/app-defaults/%s", XrmQuarkToString(_class)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/Xrmcommandline.h new/xosview-1.16/Xrmcommandline.h --- old/xosview-1.14/Xrmcommandline.h 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/Xrmcommandline.h 2013-08-23 11:40:35.000000000 +0200 @@ -30,6 +30,7 @@ // CPU resources { "-cpu", "*cpu", XrmoptionNoArg, "False" }, { "+cpu", "*cpu", XrmoptionNoArg, "True" }, +{ "+cpus", "*cpuFormat", XrmoptionNoArg, "all" }, // Load resources { "-load", "*load", XrmoptionNoArg, "False" }, { "+load", "*load", XrmoptionNoArg, "True" }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/bsd/MeterMaker.cc new/xosview-1.16/bsd/MeterMaker.cc --- old/xosview-1.14/bsd/MeterMaker.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/bsd/MeterMaker.cc 2013-08-23 11:40:35.000000000 +0200 @@ -18,9 +18,7 @@ #include "kernel.h" #include "MeterMaker.h" #include "xosview.h" -#ifdef HAVE_BATTERY_METER #include "btrymeter.h" -#endif #include "cpumeter.h" #include "memmeter.h" #include "swapmeter.h" @@ -68,6 +66,9 @@ if ( _xos->isResourceTrue("irqrate") ) push(new IrqRateMeter(_xos)); + if ( _xos->isResourceTrue("battery") && BSDHasBattery() ) + push(new BtryMeter(_xos)); + if ( _xos->isResourceTrue("coretemp") ) { char caption[25]; snprintf(caption, 25, "TEMPERATURE (C)/%s", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/bsd/btrymeter.cc new/xosview-1.16/bsd/btrymeter.cc --- old/xosview-1.14/bsd/btrymeter.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/bsd/btrymeter.cc 2013-08-23 11:40:35.000000000 +0200 @@ -1,106 +1,88 @@ // -// BSD version based on the Linux version by Mike: -// Copyright (c) 1997 by Mike Romberg ( [email protected] ) +// Copyright (c) 2013 by Tomi Tapper ( [email protected] ) // -// This file may be distributed under terms of the GPL +// Based on linux/btrymeter.cc: +// Copyright (c) 1997, 2006 by Mike Romberg ( [email protected] ) // -// BSD porting work done by David W. Talmage -// <[email protected]> +// This file may be distributed under terms of the GPL // -// Only supported for NetBSD so far. +#include <stdlib.h> #include "btrymeter.h" -#ifdef HAVE_BATTERY_METER - #include "xosview.h" -#ifdef HAVE_FSTREAM -#include <fstream> -#else -#include <fstream.h> -#endif -#include <stdlib.h> - -#include <fcntl.h> -#include <machine/apmvar.h> -#include <math.h> -#include <sys/ioctl.h> -#include <unistd.h> +#include "kernel.h" -static const char APMFILENAME[] = "/dev/apm"; BtryMeter::BtryMeter( XOSView *parent ) - : FieldMeter( parent, 2, "BAT", "% LEFT/% USED", 1, 1 ){ + : FieldMeter( parent, 2, "BTRY", "CHRG/USED", 1, 1, 0 ) { + old_state_ = 255; } -BtryMeter::~BtryMeter( void ){ +BtryMeter::~BtryMeter( void ) { } -void BtryMeter::checkResources( void ){ - FieldMeter::checkResources(); +void BtryMeter::checkResources( void ) { + FieldMeter::checkResources(); - setfieldcolor( 0, parent_->getResource( "batteryUsedColor" ) ); - setfieldcolor( 1, parent_->getResource( "batteryLeftColor" ) ); + leftcolor_ = parent_->allocColor( parent_->getResource("batteryLeftColor") ); + usedcolor_ = parent_->allocColor( parent_->getResource("batteryUsedColor") ); + chargecolor_ = parent_->allocColor( parent_->getResource("batteryChargeColor") ); + fullcolor_ = parent_->allocColor( parent_->getResource("batteryFullColor") ); + lowcolor_ = parent_->allocColor( parent_->getResource("batteryLowColor") ); + critcolor_ = parent_->allocColor( parent_->getResource("batteryCritColor") ); + nonecolor_ = parent_->allocColor( parent_->getResource("batteryNoneColor") ); - priority_ = atoi (parent_->getResource( "batteryPriority" ) ); - SetUsedFormat(parent_->getResource( "batteryUsedFormat" ) ); -} - -void BtryMeter::checkevent( void ){ - getpwrinfo(); + setfieldcolor(0, leftcolor_); + setfieldcolor(1, usedcolor_); - drawfields(); + priority_ = atoi( parent_->getResource("batteryPriority") ); + SetUsedFormat( parent_->getResource("batteryUsedFormat") ); } - -void BtryMeter::getpwrinfo( void ){ - struct apm_power_info buff; - float minutes_left, max_left; - int error = 0; - int loadinfo = open(APMFILENAME, O_RDONLY, 0); - - if ( !loadinfo ){ - std::cerr <<"Can not open file : " <<APMFILENAME << std::endl; - parent_->done(1); - return; - } - - error = ioctl(loadinfo, APM_IOC_GETPOWER, &buff); - - if (error != -1) { - if (buff.battery_state != APM_BATT_ABSENT) { - - fields_[0] = (float)buff.battery_life; // percent left - fields_[1] = 100.0 - fields_[0]; // percent used - minutes_left = (float)buff.minutes_left; - - // minutes_left = (percent_left/100.0) * max_minutes; - // minutes_left / (percent_left/100.0) = max_minutes; - // minutes_left * 100.0 / percent_left = max_minutes; - if (minutes_left == 0) { - // This fix a bogus warning when the apm bios doesn't know - // the correct remaining time. - minutes_left = (float)0.01; - } - max_left = minutes_left * 100.0 / fields_[0]; - - // - // Set total_ so that the graphing methods know to set the - // relative sizes of the percent left and percent used graphs. - // - total_ = 100.0; - - // - // This sets the actual number of minutes left. If the resource - // xosview*batteryUsedFormat is "float", then xosview will display - // that number to the left of the battery graph. If it's - // "percent", then you get the percent remaining next to the - // graph. - // - setUsed(minutes_left, max_left); - } - } - - close(loadinfo); +void BtryMeter::checkevent( void ) { + getstats(); + drawfields(); } -#endif // HAVE_BATTERY_METER +void BtryMeter::getstats( void ) { + int remaining; + unsigned int state; + + BSDGetBatteryInfo(&remaining, &state); + + if (state != old_state_) { + if (state == XOSVIEW_BATT_NONE) { // no battery present + setfieldcolor(0, nonecolor_); + legend("NONE/NONE"); + } + else if (state & XOSVIEW_BATT_FULL) { // full battery + setfieldcolor(0, fullcolor_); + legend("CHRG/FULL"); + } + else { // present, not full + if (state & XOSVIEW_BATT_CRITICAL) // critical charge + setfieldcolor(0, critcolor_); + else if (state & XOSVIEW_BATT_LOW) // low charge + setfieldcolor(0, lowcolor_); + else { // above low, below full + if (state & XOSVIEW_BATT_CHARGING) // is charging + setfieldcolor(0, chargecolor_); + else + setfieldcolor(0, leftcolor_); + } + // legend tells if charging or discharging + if (state & XOSVIEW_BATT_CHARGING) + legend("CHRG/AC"); + else + legend("CHRG/USED"); + } + drawlegend(); + parent_->draw(); // make sure the field changes colour too + old_state_ = state; + } + + total_ = 100.0; + fields_[0] = remaining; + fields_[1] = total_ - remaining; + setUsed(fields_[0], total_); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/bsd/btrymeter.h new/xosview-1.16/bsd/btrymeter.h --- old/xosview-1.14/bsd/btrymeter.h 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/bsd/btrymeter.h 2013-08-23 11:40:35.000000000 +0200 @@ -1,35 +1,35 @@ // -// Copyright (c) 1997 by Mike Romberg ( [email protected] ) +// Copyright (c) 2013 by Tomi Tapper ( [email protected] ) +// +// Based on linux/btrymeter.h: +// Copyright (c) 1997, 2005, 2006 by Mike Romberg ( [email protected] ) // // This file may be distributed under terms of the GPL -// Ported to NetBSD by David W. Talmage -// ([email protected]) // #ifndef _BTRYMETER_H_ #define _BTRYMETER_H_ -#include "defines.h" #include "fieldmeter.h" -#ifdef HAVE_BATTERY_METER class BtryMeter : public FieldMeter { public: - BtryMeter( XOSView *parent ); - ~BtryMeter( void ); + BtryMeter( XOSView *parent ); + ~BtryMeter( void ); - const char *name( void ) const { return "BtryMeter"; } - void checkevent( void ); + const char *name( void ) const { return "BtryMeter"; } + void checkevent( void ); + void checkResources( void ); - void checkResources( void ); protected: + void getstats( void ); - void getpwrinfo( void ); private: - int alarmThreshold; + unsigned long leftcolor_, usedcolor_, chargecolor_, fullcolor_, + lowcolor_, critcolor_, nonecolor_; + unsigned int old_state_; }; -#endif // HAVE_BATTERY_METER #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/bsd/defines.h new/xosview-1.16/bsd/defines.h --- old/xosview-1.14/bsd/defines.h 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/bsd/defines.h 2013-08-23 11:40:35.000000000 +0200 @@ -45,4 +45,13 @@ #define USE_KVM_GETSWAPINFO 1 #endif +/* Helper defines for battery meter. */ +#define XOSVIEW_BATT_NONE 0 +#define XOSVIEW_BATT_CHARGING 1 +#define XOSVIEW_BATT_DISCHARGING 2 +#define XOSVIEW_BATT_FULL 4 +#define XOSVIEW_BATT_LOW 8 +#define XOSVIEW_BATT_CRITICAL 16 + + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/bsd/kernel.cc new/xosview-1.16/bsd/kernel.cc --- old/xosview-1.14/bsd/kernel.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/bsd/kernel.cc 2013-08-23 11:40:35.000000000 +0200 @@ -35,8 +35,18 @@ #include <sys/sysctl.h> #include <net/if.h> -#if defined(XOSVIEW_FREEBSD) +#if defined(XOSVIEW_DFBSD) +#define _KERNEL_STRUCTURES +#include <kinfo.h> +#endif + +#if defined(XOSVIEW_FREEBSD) || defined(XOSVIEW_DFBSD) +static const char ACPIDEV[] = "/dev/acpi"; +static const char APMDEV[] = "/dev/apm"; #include <net/if_var.h> +#include <sys/ioctl.h> +#include <dev/acpica/acpiio.h> +#include <machine/apm_bios.h> #endif #if defined(XOSVIEW_NETBSD) @@ -58,13 +68,6 @@ static int mib_spd[2] = { CTL_HW, HW_CPUSPEED }; static int mib_cpt[2] = { CTL_KERN, KERN_CPTIME }; static int mib_ifl[6] = { CTL_NET, AF_ROUTE, 0, 0, NET_RT_IFLIST, 0 }; -static int mib_bcs[3] = { CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT }; -#endif - -#if defined(XOSVIEW_DFBSD) -#define _KERNEL_STRUCTURES -#include <net/if_var.h> -#include <kinfo.h> #endif #if defined(XOSVIEW_OPENBSD) || defined(XOSVIEW_DFBSD) @@ -281,7 +284,7 @@ if ( sysctl(mib_spd, 2, &cpu_speed, &size, NULL, 0) < 0 ) err(EX_OSERR, "syscl hw.cpuspeed failed"); #else /* XOSVIEW_NETBSD || XOSVIEW_DFBSD */ - long speed = 0; + uint64_t speed = 0; size = sizeof(speed); #if defined(XOSVIEW_NETBSD) if ( sysctlbyname("machdep.tsc_freq", &speed, &size, NULL, 0) < 0 ) @@ -494,8 +497,20 @@ skipif = true; } if (!skipif) { +#if defined(XOSVIEW_DFBSD) && __DragonFly_version > 300304 + struct ifdata_pcpu *ifdatap = ifnet.if_data_pcpu; + struct ifdata_pcpu ifdata; + int ncpus = BSDCountCpus(); + for (int cpu = 0; cpu < ncpus; cpu++) { + safe_kvm_read((u_long)ifdatap + cpu * sizeof(ifdata), + &ifdata, sizeof(ifdata)); + *inbytes += ifdata.ifd_ibytes; + *outbytes += ifdata.ifd_obytes; + } +#else *inbytes += ifnet.if_ibytes; *outbytes += ifnet.if_obytes; +#endif } } #endif /* XOSVIEW_OPENBSD */ @@ -1406,3 +1421,240 @@ #endif #endif } + + +// ---------------------- Battery Meter stuff --------------------------------- + +bool +BSDHasBattery() { +#if defined(XOSVIEW_NETBSD) + int fd; + prop_dictionary_t pdict; + prop_object_t pobj; + + if ( (fd = open(_PATH_SYSMON, O_RDONLY)) == -1 ) + return false; + if ( prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &pdict) ) + err(EX_OSERR, "Could not get sensor dictionary"); + if ( close(fd) == -1 ) + err(EX_OSERR, "Could not close %s", _PATH_SYSMON); + + if ( prop_dictionary_count(pdict) == 0 ) + return false; + pobj = prop_dictionary_get(pdict, "acpibat0"); // just check for 1st battery + if ( prop_object_type(pobj) != PROP_TYPE_ARRAY ) + return false; + return true; +#elif defined(XOSVIEW_OPENBSD) + // check if we can get full capacity of the 1st battery + float val = -1.0; + BSDGetSensor("acpibat0", "amphour0", &val); + if (val < 0) + return false; + return true; +#else // XOSVIEW_FREEBSD || XOSVIEW_DFBSD + int fd; + if ( (fd = open(ACPIDEV, O_RDONLY)) == -1 ) { + // No ACPI -> try APM + if ( (fd = open(APMDEV, O_RDONLY)) == -1 ) + return false; + struct apm_info aip; + if ( ioctl(fd, APMIO_GETINFO, &aip) == -1 ) + return false; + if ( close(fd) == -1 ) + err(EX_OSERR, "Could not close %s", APMDEV); + if (aip.ai_batt_stat == 0xff || aip.ai_batt_life == 0xff) + return false; + return true; + } + + union acpi_battery_ioctl_arg battio; + battio.unit = ACPI_BATTERY_ALL_UNITS; + if ( ioctl(fd, ACPIIO_BATT_GET_BATTINFO, &battio) == -1 ) + return false; + if ( close(fd) == -1 ) + err(EX_OSERR, "Could not close %s", ACPIDEV); + return ( battio.battinfo.state != ACPI_BATT_STAT_NOT_PRESENT ); +#endif +} + +void +BSDGetBatteryInfo(int *remaining, unsigned int *state) { + *state = XOSVIEW_BATT_NONE; +#if defined(XOSVIEW_NETBSD) || defined(XOSVIEW_OPENBSD) + int batteries = 0; +#if defined(XOSVIEW_NETBSD) + /* Again adapted from envstat. */ + // All kinds of sensors are read with libprop. We have to go through them + // to find the batteries. We need capacity, charge, presence, charging + // status and discharge rate for each battery for the calculations. + // For simplicity, assume all batteries have the same + // charge/discharge status. + int fd; + int total_capacity = 0, total_charge = 0, total_low = 0, total_crit = 0; + const char *name = NULL; + prop_dictionary_t pdict; + prop_object_t pobj, pobj1; + prop_object_iterator_t piter, piter2; + prop_array_t parray; + + if ( (fd = open(_PATH_SYSMON, O_RDONLY)) == -1 ) { + warn("Could not open %s", _PATH_SYSMON); + return; // this seems to happen occasionally, so only warn + } + if ( prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &pdict) ) + err(EX_OSERR, "Could not get sensor dictionary"); + if ( close(fd) == -1 ) + err(EX_OSERR, "Could not close %s", _PATH_SYSMON); + + if ( prop_dictionary_count(pdict) == 0 ) { + warn("No sensors found"); + return; + } + if ( !(piter = prop_dictionary_iterator(pdict)) ) + err(EX_OSERR, "Could not get sensor iterator"); + + while ( (pobj = prop_object_iterator_next(piter)) ) { + int present = 0, capacity = 0, charge = 0, low = 0, crit = 0; + name = prop_dictionary_keysym_cstring_nocopy((prop_dictionary_keysym_t)pobj); + if ( strncmp(name, "acpibat", 7) ) + continue; + parray = (prop_array_t)prop_dictionary_get_keysym(pdict, (prop_dictionary_keysym_t)pobj); + if ( prop_object_type(parray) != PROP_TYPE_ARRAY ) + continue; + if ( !(piter2 = prop_array_iterator(parray)) ) + err(EX_OSERR, "Could not get sensor iterator"); + + while ( (pobj = prop_object_iterator_next(piter2)) ) { + if ( !(pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "state")) ) + continue; + if ( prop_string_equals_cstring((prop_string_t)pobj1, "invalid") || + prop_string_equals_cstring((prop_string_t)pobj1, "unknown") ) + continue; // skip sensors without valid data + if ( !(pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "description")) ) + continue; + name = prop_string_cstring_nocopy((prop_string_t)pobj1); + if ( strncmp(name, "present", 7) == 0 ) { // is battery present + if ( (pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "cur-value")) ) + present = prop_number_integer_value((prop_number_t)pobj1); + } + else if ( strncmp(name, "design cap", 10) == 0 ) { // get full capacity + if ( (pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "cur-value")) ) + capacity = prop_number_integer_value((prop_number_t)pobj1); + } + else if ( strncmp(name, "charge", 7) == 0 ) { // get present charge, low and critical levels + if ( (pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "cur-value")) ) + charge = prop_number_integer_value((prop_number_t)pobj1); + if ( (pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "warning-capacity")) ) + low = prop_number_integer_value((prop_number_t)pobj1); + if ( (pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "critical-capacity")) ) + crit = prop_number_integer_value((prop_number_t)pobj1); + } + else if ( strncmp(name, "charging", 8) == 0 ) { // charging or not? + if ( (pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "cur-value")) ) + if ( prop_number_integer_value((prop_number_t)pobj1) ) + *state |= XOSVIEW_BATT_CHARGING; + } + else if ( strncmp(name, "discharge rate", 14) == 0 ) { // discharging or not? + if ( (pobj1 = prop_dictionary_get((prop_dictionary_t)pobj, "cur-value")) ) + if ( prop_number_integer_value((prop_number_t)pobj1) ) + *state |= XOSVIEW_BATT_DISCHARGING; + } + } + if (present) { + total_capacity += capacity; + total_charge += charge; + total_low += low; + total_crit += crit; + batteries++; + } + prop_object_iterator_release(piter2); + } + prop_object_iterator_release(piter); + prop_object_release(pdict); +#else // XOSVIEW_OPENBSD + float total_capacity = 0, total_charge = 0, total_low = 0, total_crit = 0; + char battery[16]; + while (batteries < 1024) { + float val = -1.0; + snprintf(battery, 15, "acpibat%d", batteries); + BSDGetSensor(battery, "amphour0", &val); // full capacity + if (val < 0) // no more batteries + break; + batteries++; + total_capacity += val; + BSDGetSensor(battery, "amphour1", &val); // warning capacity + total_low += val; + BSDGetSensor(battery, "amphour2", &val); // low capacity + total_crit += val; + BSDGetSensor(battery, "amphour3", &val); // remaining + total_charge += val; + BSDGetSensor(battery, "raw0", &val); // state + if ((int)val == 1) + *state |= XOSVIEW_BATT_DISCHARGING; + else if ((int)val == 2) + *state |= XOSVIEW_BATT_CHARGING; + // there's also 0 state for idle/full + } +#endif + if (batteries == 0) { // all batteries are off + *state = XOSVIEW_BATT_NONE; + *remaining = 0; + return; + } + *remaining = 100 * total_charge / total_capacity; + if ( !(*state & XOSVIEW_BATT_CHARGING) && + !(*state & XOSVIEW_BATT_DISCHARGING) ) + *state |= XOSVIEW_BATT_FULL; // it's full when not charging nor discharging + if (total_capacity < total_low) + *state |= XOSVIEW_BATT_LOW; + if (total_capacity < total_crit) + *state |= XOSVIEW_BATT_CRITICAL; +#else // XOSVIEW_FREEBSD || XOSVIEW_DFBSD + /* Adapted from acpiconf and apm. */ + int fd; + if ( (fd = open(ACPIDEV, O_RDONLY)) == -1 ) { + // No ACPI -> try APM + if ( (fd = open(APMDEV, O_RDONLY)) == -1 ) + err(EX_OSFILE, "could not open %s or %s", ACPIDEV, APMDEV); + struct apm_info aip; + if ( ioctl(fd, APMIO_GETINFO, &aip) == -1 ) + err(EX_IOERR, "failed to get APM battery info"); + if ( close(fd) == -1 ) + err(EX_OSERR, "Could not close %s", APMDEV); + if (0 <= aip.ai_batt_life && aip.ai_batt_life <= 100) + *remaining = aip.ai_batt_life; // only 0-100 are valid values + else + *remaining = 0; + if (aip.ai_batt_stat == 0) + *state |= XOSVIEW_BATT_FULL; + else if (aip.ai_batt_stat == 1) + *state |= XOSVIEW_BATT_LOW; + else if (aip.ai_batt_stat == 2) + *state |= XOSVIEW_BATT_CRITICAL; + else if (aip.ai_batt_stat == 3) + *state |= XOSVIEW_BATT_CHARGING; + else + *state = XOSVIEW_BATT_NONE; + return; + } + // ACPI + union acpi_battery_ioctl_arg battio; + battio.unit = ACPI_BATTERY_ALL_UNITS; + if ( ioctl(fd, ACPIIO_BATT_GET_BATTINFO, &battio) == -1 ) + err(EX_IOERR, "failed to get ACPI battery info"); + if ( close(fd) == -1 ) + err(EX_OSERR, "Could not close %s", ACPIDEV); + *remaining = battio.battinfo.cap; + if (battio.battinfo.state != ACPI_BATT_STAT_NOT_PRESENT) { + if (battio.battinfo.state == 0) + *state |= XOSVIEW_BATT_FULL; + if (battio.battinfo.state & ACPI_BATT_STAT_CRITICAL) + *state |= XOSVIEW_BATT_CRITICAL; + if (battio.battinfo.state & ACPI_BATT_STAT_DISCHARG) + *state |= XOSVIEW_BATT_DISCHARGING; + if (battio.battinfo.state & ACPI_BATT_STAT_CHARGING) + *state |= XOSVIEW_BATT_CHARGING; + } +#endif +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/bsd/kernel.h new/xosview-1.16/bsd/kernel.h --- old/xosview-1.14/bsd/kernel.h 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/bsd/kernel.h 2013-08-23 11:40:35.000000000 +0200 @@ -78,5 +78,11 @@ void BSDGetSensor(const char *name, const char *valname, float *value); +bool +BSDHasBattery(); + +void +BSDGetBatteryInfo(int *remaining, unsigned int *state); + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/bsd/loadmeter.cc new/xosview-1.16/bsd/loadmeter.cc --- old/xosview-1.14/bsd/loadmeter.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/bsd/loadmeter.cc 2013-08-23 11:40:35.000000000 +0200 @@ -110,18 +110,12 @@ lastalarmstate_ = alarmstate_; } - // This method of auto-adjust is better than the old way. - // If fields[0] is less than 20% of display, shrink display to be - // full-width. Then, if full-width < 1.0, set it to be 1.0. - if (fields_[0] * 5.0 < total_) - total_ = fields_[0]; - else - // If fields[0] is larger, then set it to be 1/5th of full. - if (fields_[0] > total_) - total_ = fields_[0] * 5.0; - - if (total_ < 1.0) - total_ = 1.0; + // Adjust total to next power-of-two of the current load. + if ( (fields_[0]*5.0 < total_ && total_ > 1.0) || fields_[0] > total_ ) { + unsigned int i = fields_[0]; + i |= i >> 1; i |= i >> 2; i |= i >> 4; i |= i >> 8; i |= i >> 16; // i = 2^n - 1 + total_ = i + 1; + } fields_[1] = total_ - fields_[0]; setUsed(fields_[0], total_); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/linux/MeterMaker.cc new/xosview-1.16/linux/MeterMaker.cc --- old/xosview-1.14/linux/MeterMaker.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/linux/MeterMaker.cc 2013-08-23 11:40:35.000000000 +0200 @@ -111,7 +111,7 @@ // check for the serial meters. -#if defined (__arm__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__s390__) || defined(__s390x__) +#if defined(__aarch64__) || defined (__arm__) || defined(__mc68000__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__sparc__) || defined(__s390__) || defined(__s390x__) /* these architectures have no ioperm() */ #else for (int i = 0 ; i < SerialMeter::numDevices() ; i++) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/linux/cpumeter.cc new/xosview-1.16/linux/cpumeter.cc --- old/xosview-1.14/linux/cpumeter.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/linux/cpumeter.cc 2013-08-23 11:40:35.000000000 +0200 @@ -13,6 +13,7 @@ #include <string> #include <sstream> #include <ctype.h> +#include <sys/utsname.h> static const char STATFILENAME[] = "/proc/stat"; static const char VERSIONFILENAME[] = "/proc/sys/kernel/osrelease"; @@ -337,17 +338,11 @@ } int CPUMeter::getkernelversion(void){ - std::ifstream f(VERSIONFILENAME); - if (!f) { - std::cerr << "Can not get kernel version from " << VERSIONFILENAME << "." << std::endl; - exit(1); + static int major = 0, minor = 0, micro = 0; + if (!major) { + struct utsname myosrelease; + uname(&myosrelease); + sscanf(myosrelease.release, "%d.%d.%d", &major, &minor, µ); } - - std::string version; - int major = 0, minor = 0, micro = 0; - - f >> version; - sscanf(version.c_str(), "%d.%d.%d", &major, &minor, µ); - - return ( major*1000000 + minor*1000 + micro); + return (major*1000000 + minor*1000 + micro); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/linux/diskmeter.cc new/xosview-1.16/linux/diskmeter.cc --- old/xosview-1.14/linux/diskmeter.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/linux/diskmeter.cc 2013-08-23 11:40:35.000000000 +0200 @@ -15,7 +15,7 @@ #include <errno.h> #include <limits.h> -#define MAX_PROCSTAT_LENGTH 2048 +#define MAX_PROCSTAT_LENGTH 4096 DiskMeter::DiskMeter( XOSView *parent, float max ) : FieldMeterGraph( @@ -209,7 +209,7 @@ float itim = IntervalTimeInMicrosecs(); // the sum of all disks unsigned long long all_bytes_read = 0, all_bytes_written = 0; - unsigned int sect_size = 512; // disk stats in /sys are always in 512 byte units + unsigned int sect_size = 512; // from linux-3.10/Documentation/block/stat.txt // avoid strange values at first call // (by this - the first value displayed becomes zero) @@ -240,8 +240,8 @@ XOSDEBUG("disk: read: %llu, written: %llu\n", all_bytes_read, all_bytes_written); // convert rate from bytes/microsec into bytes/second - fields_[0] = all_bytes_read * 1e6 / itim; - fields_[1] = all_bytes_written * 1e6 / itim; + fields_[0] = all_bytes_read * ( 1e6 / itim ); + fields_[1] = all_bytes_written * ( 1e6 / itim ); // fix overflow (conversion bug?) if (fields_[0] < 0.0) @@ -273,9 +273,9 @@ // just sum up everything in /sys/block/*/stat std::string sysfs_dir = _statFileName; - std::string disk; - struct stat buf; + std::string disk, tmp; std::ifstream diskstat; + struct stat buf; char line[128]; unsigned long vals[7]; diskmap reads, writes; @@ -293,11 +293,18 @@ // visit every /sys/block/*/stat and sum up the values: for (struct dirent *dirent; (dirent = readdir(dir)) != NULL; ) { if (strncmp(dirent->d_name, ".", 1) == 0 || - strncmp(dirent->d_name, "..", 2) == 0) + strncmp(dirent->d_name, "..", 2) == 0 || + strncmp(dirent->d_name, "loop", 4) == 0 || + strncmp(dirent->d_name, "ram", 3) == 0) continue; disk = sysfs_dir + dirent->d_name; if (stat(disk.c_str(), &buf) == 0 && buf.st_mode & S_IFDIR) { + // only scan for real HW (raid, md, and lvm all mapped on them) + tmp = disk + "/device"; + if (lstat(tmp.c_str(), &buf) != 0 || (buf.st_mode & S_IFLNK) == 0) + continue; + // is a dir, locate 'stat' file in it disk += "/stat"; diskstat.open(disk.c_str()); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/linux/intmeter.cc new/xosview-1.16/linux/intmeter.cc --- old/xosview-1.14/linux/intmeter.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/linux/intmeter.cc 2013-08-23 11:40:35.000000000 +0200 @@ -12,11 +12,11 @@ #include <stdlib.h> static const char *INTFILE = "/proc/interrupts"; -static std::map<int,int> realintnum; +static std::map<const int,int> realintnum; IntMeter::IntMeter( XOSView *parent, int cpu) - : BitMeter( parent, "INTS", "", 1, 0, 0 ), _cpu(cpu) { + : BitMeter( parent, "INTS", "", 1, 0, 0 ), _cpu(cpu), max(1024) { _old = ( CPUMeter::getkernelversion() <= 2000000 ? true : false ); irqs_ = lastirqs_ = NULL; initirqcount(); @@ -61,13 +61,15 @@ } if (!_old) - intfile.ignore(1024, '\n'); + intfile.ignore(max, '\n'); while ( !intfile.eof() ){ std::getline(intfile, line); if ( line.find_first_of("0123456789") > line.find_first_of(':') ) break; // reached non-numeric interrupts idx = strtoul(line.c_str(), &end, 10); + if (idx >= max) + break; intno = realintnum[idx]; if ( intno >= numBits() ) updateirqcount(intno, false); @@ -164,7 +166,7 @@ if (!_old) { for (i=0; i<16; i++) realintnum[i] = i; - intfile.ignore(1024, '\n'); + intfile.ignore(max, '\n'); } /* just looking for the highest number interrupt that @@ -181,7 +183,7 @@ intno = idx; realintnum[i] = idx++; } - intfile.ignore(1024, '\n'); + intfile.ignore(max, '\n'); } updateirqcount(intno, true); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/linux/intmeter.h new/xosview-1.16/linux/intmeter.h --- old/xosview-1.14/linux/intmeter.h 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/linux/intmeter.h 2013-08-23 11:40:35.000000000 +0200 @@ -27,6 +27,7 @@ int _cpu; bool _old; bool separate_; + const int max; void getirqs( void ); void updateirqcount( int n, bool init ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/linux/loadmeter.cc new/xosview-1.16/linux/loadmeter.cc --- old/xosview-1.14/linux/loadmeter.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/linux/loadmeter.cc 2013-08-23 11:40:35.000000000 +0200 @@ -11,9 +11,7 @@ #include "xosview.h" #include "cpumeter.h" #include <fstream> -#include <sstream> #include <stdlib.h> -#include <math.h> static const char LOADFILENAME[] = "/proc/loadavg"; static const char SPEEDFILENAME[] = "/proc/cpuinfo"; @@ -78,15 +76,14 @@ void LoadMeter::checkevent( void ){ getloadinfo(); if ( do_cpu_speed ) { - getspeedinfo(); - if ( old_cpu_speed_ != cur_cpu_speed_ ) { - // update the legend: - std::ostringstream legnd; - XOSDEBUG("SPEED: %d\n",cur_cpu_speed_); - legnd << "PROCS/MIN" << " " << cur_cpu_speed_ << " MHz"<< std::ends; - legend( legnd.str().c_str() ); - drawlegend(); - } + getspeedinfo(); + if ( old_cpu_speed_ != cur_cpu_speed_ ) { + // update the legend: + char l[32]; + snprintf(l, 32, "PROCS/MIN %d MHz", cur_cpu_speed_); + legend(l); + drawlegend(); + } } drawfields(); @@ -120,14 +117,12 @@ lastalarmstate = alarmstate; } - if ( fields_[0]*5.0<total_ ) - total_ = fields_[0]; - else - if ( fields_[0]>total_ ) - total_ = fields_[0]*5.0; - - if ( total_ < 1.0) - total_ = 1.0; + // Adjust total to next power-of-two of the current load. + if ( (fields_[0]*5.0 < total_ && total_ > 1.0) || fields_[0] > total_ ) { + unsigned int i = fields_[0]; + i |= i >> 1; i |= i >> 2; i |= i >> 4; i |= i >> 8; i |= i >> 16; // i = 2^n - 1 + total_ = i + 1; + } fields_[1] = (float) (total_ - fields_[0]); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/linux/pagemeter.cc new/xosview-1.16/linux/pagemeter.cc --- old/xosview-1.14/linux/pagemeter.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/linux/pagemeter.cc 2013-08-23 11:40:35.000000000 +0200 @@ -12,7 +12,7 @@ #include <sys/stat.h> #include <unistd.h> -#define MAX_PROCSTAT_LENGTH 2048 +#define MAX_PROCSTAT_LENGTH 4096 PageMeter::PageMeter( XOSView *parent, float max ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/linux/swapmeter.cc new/xosview-1.16/linux/swapmeter.cc --- old/xosview-1.14/linux/swapmeter.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/linux/swapmeter.cc 2013-08-23 11:40:35.000000000 +0200 @@ -9,6 +9,7 @@ #include <fstream> #include <sstream> #include <stdlib.h> +#include <sys/sysinfo.h> static const char MEMFILENAME[] = "/proc/meminfo"; @@ -37,42 +38,18 @@ drawfields(); } - void SwapMeter::getswapinfo( void ){ - std::ifstream meminfo( MEMFILENAME ); - if ( !meminfo ){ - std::cerr <<"Cannot open file : " <<MEMFILENAME << std::endl; - exit( 1 ); - } - - total_ = fields_[0] = fields_[1] = 0; - - char buf[256]; - bool found_total = false, found_free = false; - unsigned long long val; - - // Get the info from the "standard" meminfo file. - while ( !meminfo.eof() && !(found_total && found_free) ){ - meminfo.getline(buf, 256); - - if ( !strncmp(buf, "SwapTotal", 9) ){ - val = strtoull(buf+10, NULL, 10); - total_ = val<<10; // unit is always kB - found_total = true; - } - if ( !strncmp(buf, "SwapFree", 8) ){ - val = strtoull(buf+9, NULL, 10); - fields_[1] = val<<10; // unit is always kB - found_free = true; - } - } + struct sysinfo sinfo; + typeof (sinfo.mem_unit) unit; - fields_[0] = total_ - fields_[1]; + sysinfo(&sinfo); + unit = (sinfo.mem_unit ? sinfo.mem_unit : 1); + total_ = (double)sinfo.totalswap * unit; + fields_[0] = (double)(sinfo.totalswap - sinfo.freeswap) * unit; if ( total_ == 0 ){ total_ = 1; fields_[0] = 0; - fields_[1] = 1; } if (total_) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/xosview.1 new/xosview-1.16/xosview.1 --- old/xosview-1.14/xosview.1 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/xosview.1 2013-08-23 11:40:35.000000000 +0200 @@ -57,6 +57,7 @@ This option overrides the xosview*\\$1 resource. It is equivalent to setting xosview*\\$1 to "False". .RE + +\\$1 .RS This option overrides the xosview*\\$1 resource. It is @@ -175,6 +176,7 @@ \fBBattery Level\fP: charge and status of batteries Linux : available | used + *BSD : available | used \fBRAID\fP: State of disks in a software RAID array Linux : disk0 disk1 disk2 ... diskN | rebuild @@ -238,45 +240,23 @@ xosview*geometry resource. .RE -.\" Handle -/+captions .pm captions - -.\" Handle -/+labels .pm labels +.pm usedlabels +.pm cpu -\-usedlabels -.RS -This option overrides the xosview*usedlabels resource. It is equivalent to -setting xosview*usedlabels to "False". -.RE -+usedlabels +\+cpus .RS -This option overrides the xosview*usedlabels resource. It is equivalent to -setting xosview*usedlabels to "True". +Force the display of all CPUs in the system. This option is equivalent +to setting xosview*cpuFormat to "all". .RE -.\" Handle -/+cpu -.pm cpu - -.\" Handle -/+load .pm load - -.\" Handle -/+mem .pm mem - -.\" Handle -/+swap .pm swap - -.\" Handle -/+battery .pm battery - -.\" Handle -/+gfx .pm gfx - -.\" Handle -/+wireless .pm wireless - -.\" Handle -/+net .pm net \-network \fImaxbandwidth\fP @@ -291,7 +271,6 @@ 0 no longer disables the meter \-\- use the ``\-net'' option instead. .RE -.\" Handle \-/+page .pm page \-pagespeed \fIval\fP @@ -300,10 +279,7 @@ xosview*pageBandWidth will be set to \fIval\fP. .RE -.\" Handle -/+disk .pm disk - -.\" Handle -/+ int .pm int \-ints +ints @@ -320,16 +296,9 @@ Equivalent to \-irqrate and +irqrate. .RE -.\" Handle -/+lmstemp .pm lmstemp - -.\" Handle -/+coretemp .pm coretemp - -.\" Handle -/+acpitemp .pm acpitemp - -.\" Handle -/+bsdsensor .pm bsdsensor .RE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/xosview.desktop new/xosview-1.16/xosview.desktop --- old/xosview-1.14/xosview.desktop 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/xosview.desktop 2013-08-23 11:40:35.000000000 +0200 @@ -6,3 +6,4 @@ Type=Application Icon=xosview.xpm Categories=Application;System; +Keywords=System;Utility;System Monitor diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xosview-1.14/xwin.cc new/xosview-1.16/xwin.cc --- old/xosview-1.14/xwin.cc 2013-03-27 18:26:15.000000000 +0100 +++ new/xosview-1.16/xwin.cc 2013-08-23 11:40:35.000000000 +0200 @@ -1,4 +1,5 @@ #include <X11/Xatom.h> +#include <X11/xpm.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> @@ -78,6 +79,7 @@ void XWin::init( int argc, char **argv ){ XGCValues gcv; XSetWindowAttributes xswa; + Pixmap background_pixmap; setFont(); setColors(); @@ -107,6 +109,10 @@ XChangeWindowAttributes(display_, window_, (CWColormap | CWBitGravity), &xswa); + // If there is a pixmap file, set it as the background + if (getPixmap(&background_pixmap)) + XSetWindowBackgroundPixmap(display_,window_,background_pixmap); + // add the events Event *tmp = events_; while ( tmp != NULL ){ @@ -217,6 +223,35 @@ } //----------------------------------------------------------------------------- +int XWin::getPixmap(Pixmap *pixmap) +{ + char *pixmap_file; + XWindowAttributes root_att; + XpmAttributes pixmap_att; + + pixmap_file = (char*) getResourceOrUseDefault("pixmapName",NULL); + + if (!pixmap_file) + return 0; + + XGetWindowAttributes(display_, DefaultRootWindow(display_),&root_att); + pixmap_att.closeness=30000; + pixmap_att.colormap=root_att.colormap; + pixmap_att.valuemask=XpmSize|XpmReturnPixels|XpmColormap|XpmCloseness; + + if (XpmReadFileToPixmap(display_,DefaultRootWindow(display_),pixmap_file, + pixmap, NULL, &pixmap_att)) + { + std::cerr << "Pixmap " << pixmap_file << " not found" << std::endl; + std::cerr << "Defaulting to blank" << std::endl; + pixmap = NULL; + return 0; + } + + return 1; +} + +//----------------------------------------------------------------------------- void XWin::getGeometry( void ){ char default_geometry[80]; int bitmask; ++++++ xosview-appdef.patch ++++++ Index: xosview-1.16/Xrm.cc =================================================================== --- xosview-1.16.orig/Xrm.cc +++ xosview-1.16/Xrm.cc @@ -9,6 +9,7 @@ #include <stdio.h> // For snprintf(). #include <ctype.h> #include <iostream> +#include <sys/stat.h> // For stat(). #include <unistd.h> // for access(), etc. BCG #ifndef NULL #define NULL 0 @@ -138,34 +139,35 @@ Listed from weakest to strongest: // Merge in the system resource database. char rfilename[2048]; + struct stat st; int result; const int rlen = sizeof rfilename; // Get the app-defaults result = snprintf(rfilename, sizeof rfilename, "/etc/X11/app-defaults/%s", XrmQuarkToString(_class)); - if (result >= 0 && result < rlen) + if (result >= 0 && result < rlen && stat(rfilename, &st) == 0) XrmCombineFileDatabase (rfilename, &_db, 1); result = snprintf(rfilename, sizeof rfilename, "/usr/lib/X11/app-defaults/%s", XrmQuarkToString(_class)); - if (result >= 0 && result < rlen) + if (result >= 0 && result < rlen && stat(rfilename, &st) == 0) XrmCombineFileDatabase (rfilename, &_db, 1); result = snprintf(rfilename, sizeof rfilename, "/usr/X11R6/lib/X11/app-defaults/%s", XrmQuarkToString(_class)); - if (result >= 0 && result < rlen) + if (result >= 0 && result < rlen && stat(rfilename, &st) == 0) XrmCombineFileDatabase (rfilename, &_db, 1); result = snprintf(rfilename, sizeof rfilename, "/usr/share/X11/app-defaults/%s", XrmQuarkToString(_class)); - if (result >= 0 && result < rlen) + if (result >= 0 && result < rlen && stat(rfilename, &st) == 0) XrmCombineFileDatabase (rfilename, &_db, 1); // Try a few more, for SunOS/Solaris folks. result = snprintf(rfilename, sizeof rfilename, "/usr/openwin/lib/X11/app-defaults/%s", XrmQuarkToString(_class)); - if (result >= 0 && result < rlen) + if (result >= 0 && result < rlen && stat(rfilename, &st) == 0) XrmCombineFileDatabase (rfilename, &_db, 1); result = snprintf(rfilename, sizeof rfilename, "/usr/local/X11R6/lib/X11/app-defaults/%s", XrmQuarkToString(_class)); - if (result >= 0 && result < rlen) + if (result >= 0 && result < rlen && stat(rfilename, &st) == 0) XrmCombineFileDatabase (rfilename, &_db, 1); // Now, check for an XOSView file in the XAPPLRESDIR directory... ++++++ xosview-configuration.patch ++++++ ++++ 904 lines (skipped) ++++++ xosview-diskstat.patch ++++++ Index: xosview-1.16/linux/diskmeter.cc =================================================================== --- xosview-1.16.orig/linux/diskmeter.cc +++ xosview-1.16/linux/diskmeter.cc @@ -209,7 +209,6 @@ void DiskMeter::update_info(const diskma float itim = IntervalTimeInMicrosecs(); // the sum of all disks unsigned long long all_bytes_read = 0, all_bytes_written = 0; - unsigned int sect_size = 512; // from linux-3.10/Documentation/block/stat.txt // avoid strange values at first call // (by this - the first value displayed becomes zero) @@ -235,13 +234,11 @@ void DiskMeter::update_info(const diskma all_bytes_written += it->second - sysfs_write_prev_[it->first]; } - all_bytes_read *= sect_size; - all_bytes_written *= sect_size; XOSDEBUG("disk: read: %llu, written: %llu\n", all_bytes_read, all_bytes_written); // convert rate from bytes/microsec into bytes/second - fields_[0] = all_bytes_read * ( 1e6 / itim ); - fields_[1] = all_bytes_written * ( 1e6 / itim ); + fields_[0] = all_bytes_read * ( 1e5 / itim ); + fields_[1] = all_bytes_written * ( 1e5 / itim ); // fix overflow (conversion bug?) if (fields_[0] < 0.0) @@ -273,8 +270,6 @@ void DiskMeter::getsysfsdiskinfo( void ) // just sum up everything in /sys/block/*/stat std::string sysfs_dir = _statFileName; - std::string disk, tmp; - std::ifstream diskstat; struct stat buf; char line[128]; unsigned long vals[7]; @@ -292,6 +287,9 @@ void DiskMeter::getsysfsdiskinfo( void ) // visit every /sys/block/*/stat and sum up the values: for (struct dirent *dirent; (dirent = readdir(dir)) != NULL; ) { + std::string disk; + std::ifstream diskstat; + unsigned long sect_size; if (strncmp(dirent->d_name, ".", 1) == 0 || strncmp(dirent->d_name, "..", 2) == 0 || strncmp(dirent->d_name, "loop", 4) == 0 || @@ -300,11 +298,49 @@ void DiskMeter::getsysfsdiskinfo( void ) disk = sysfs_dir + dirent->d_name; if (stat(disk.c_str(), &buf) == 0 && buf.st_mode & S_IFDIR) { + std::string tmp; + // only scan for real HW (raid, md, and lvm all mapped on them) tmp = disk + "/device"; if (lstat(tmp.c_str(), &buf) != 0 || (buf.st_mode & S_IFLNK) == 0) continue; + // ignore removable devices + tmp = disk + "/removable"; + if (stat(tmp.c_str(), &buf) == 0 && buf.st_mode & S_IFREG) { + std::ifstream removable; + int isremovable = 0; + + removable.open(tmp.c_str()); + if (removable.good()) { + removable >> isremovable; + removable.close(); + removable.clear(); + } + if (isremovable) + continue; + } + + tmp = "/dev/"; + tmp += dirent->d_name; + if (lstat(tmp.c_str(), &buf) == 0) + sect_size = (unsigned long)buf.st_blksize; + + if (sect_size == 0UL) { + tmp = disk + "/queue/hw_sectors_kb"; + if (stat(tmp.c_str(), &buf) == 0 && (buf.st_mode & S_IFREG)) { + std::ifstream hw_sectors_kb; + + hw_sectors_kb.open(tmp.c_str()); + if (hw_sectors_kb.good()) { + hw_sectors_kb >> sect_size; + //XOSDEBUG("disk stat: %lu\n", sect_size); + hw_sectors_kb.close(); + hw_sectors_kb.clear(); + } + } + } + // is a dir, locate 'stat' file in it disk += "/stat"; diskstat.open(disk.c_str()); @@ -315,8 +351,8 @@ void DiskMeter::getsysfsdiskinfo( void ) vals[i] = strtoul(cur, &end, 10); cur = end; } - reads[dirent->d_name] = vals[2]; - writes[dirent->d_name] = vals[6]; + reads[dirent->d_name] = (unsigned long long)vals[2] * (unsigned long long)sect_size; + writes[dirent->d_name] = (unsigned long long)vals[6] * (unsigned long long)sect_size; XOSDEBUG("disk stat: %s | read: %lu, written: %lu\n", disk.c_str(), vals[2], vals[6]); diskstat.close(); ++++++ xosview-maxlimit.patch ++++++ Index: xosview-1.16/linux/cpumeter.cc =================================================================== --- xosview-1.16.orig/linux/cpumeter.cc +++ xosview-1.16/linux/cpumeter.cc @@ -19,7 +19,7 @@ static const char STATFILENAME[] = "/pro static const char VERSIONFILENAME[] = "/proc/sys/kernel/osrelease"; static int cputime_to_field[10] = { 0, 1, 2, 9, 5, 4, 3, 8, 6, 7 }; -#define MAX_PROCSTAT_LENGTH 4096 +#define MAX_PROCSTAT_LENGTH BUFFER_SIZE CPUMeter::CPUMeter(XOSView *parent, const char *cpuID) : FieldMeterGraph( parent, 10, toUpper(cpuID), "USR/NIC/SYS/SI/HI/WIO/GST/NGS/STL/IDLE" ) { Index: xosview-1.16/linux/diskmeter.cc =================================================================== --- xosview-1.16.orig/linux/diskmeter.cc +++ xosview-1.16/linux/diskmeter.cc @@ -15,7 +15,7 @@ #include <errno.h> #include <limits.h> -#define MAX_PROCSTAT_LENGTH 4096 +#define MAX_PROCSTAT_LENGTH BUFFER_SIZE DiskMeter::DiskMeter( XOSView *parent, float max ) : FieldMeterGraph( Index: xosview-1.16/linux/pagemeter.cc =================================================================== --- xosview-1.16.orig/linux/pagemeter.cc +++ xosview-1.16/linux/pagemeter.cc @@ -12,7 +12,7 @@ #include <sys/stat.h> #include <unistd.h> -#define MAX_PROCSTAT_LENGTH 4096 +#define MAX_PROCSTAT_LENGTH BUFFER_SIZE PageMeter::PageMeter( XOSView *parent, float max ) Index: xosview-1.16/xosview.h =================================================================== --- xosview-1.16.orig/xosview.h +++ xosview-1.16/xosview.h @@ -7,6 +7,7 @@ #ifndef _XOSVIEW_H_ #define _XOSVIEW_H_ +#define BUFFER_SIZE 4096 #include "xwin.h" #include "Xrm.h" // For Xrm resource manager class. ++++++ xosview-pixmap.patch ++++++ >From 9bb78e2c1ad6bcf9c20ca81209d5000d2b993193 Mon Sep 17 00:00:00 2001 From: Werner Fink <[email protected]> Date: Mon, 29 Apr 2013 14:09:22 +0200 Subject: [PATCH] Re-enable backgroung pixmap xpm ... as expected by some experienced users Signed-off-by: Werner Fink <[email protected]> Index: xosview-1.16/Makefile =================================================================== --- xosview-1.16.orig/Makefile +++ xosview-1.16/Makefile @@ -59,6 +59,8 @@ CPPFLAGS += -Ilinux/ ifneq ($(USE_SYSCALLS),0) CPPFLAGS += -DUSE_SYSCALLS endif +LDLIBS += -lXpm +xwin.o: CPPFLAGS += -DHAVE_XPM endif ifeq ($(PLATFORM), bsd) @@ -77,6 +79,8 @@ OBJS += bsd/MeterMaker.o \ bsd/coretemp.o \ bsd/sensor.o CPPFLAGS += -Ibsd/ +LDLIBS += -lXpm +xwin.o: CPPFLAGS += -DHAVE_XPM endif ifeq ($(PLATFORM), irix65) Index: xosview-1.16/xwin.cc =================================================================== --- xosview-1.16.orig/xwin.cc +++ xosview-1.16/xwin.cc @@ -1,4 +1,7 @@ #include <X11/Xatom.h> +#ifdef HAVE_XPM +# include <X11/xpm.h> +#endif #include <X11/xpm.h> #include <stdlib.h> #include <stdio.h> @@ -79,7 +82,6 @@ XWin::~XWin( void ){ void XWin::init( int argc, char **argv ){ XGCValues gcv; XSetWindowAttributes xswa; - Pixmap background_pixmap; setFont(); setColors(); @@ -108,10 +110,13 @@ void XWin::init( int argc, char **argv ) xswa.bit_gravity = NorthWestGravity; XChangeWindowAttributes(display_, window_, (CWColormap | CWBitGravity), &xswa); +#ifdef HAVE_XPM + Pixmap background_pixmap; // If there is a pixmap file, set it as the background if (getPixmap(&background_pixmap)) XSetWindowBackgroundPixmap(display_,window_,background_pixmap); +#endif // add the events Event *tmp = events_; @@ -225,6 +230,7 @@ void XWin::setColors( void ){ int XWin::getPixmap(Pixmap *pixmap) { +#ifdef HAVE_XPM char *pixmap_file; XWindowAttributes root_att; XpmAttributes pixmap_att; @@ -249,6 +255,10 @@ int XWin::getPixmap(Pixmap *pixmap) } return 1; +#else + pixmap = NULL; + return 0; +#endif } //----------------------------------------------------------------------------- ++++++ xosview-serial.patch ++++++ Index: xosview-1.16/linux/serialmeter.cc =================================================================== --- xosview-1.16.orig/linux/serialmeter.cc +++ xosview-1.16/linux/serialmeter.cc @@ -29,10 +29,10 @@ typedef unsigned long long u64; #include <unistd.h> #if defined(GNULIBC) || defined(__GLIBC__) -#if !defined(__powerpc__) && !defined(__hppa__) && !defined(__mips__) && !defined(__sparc__) && !defined(__sh__) && !defined(__s390__) && !defined(__s390x__) && !defined(__m68k__) +#if !defined(__aarch64__) && !defined(__powerpc__) && !defined(__hppa__) && !defined(__mips__) && !defined(__sparc__) && !defined(__sh__) && !defined(__s390__) && !defined(__s390x__) && !defined(__m68k__) #include <sys/io.h> #endif -#if !defined(__alpha__) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) && !defined(__mips__) && !defined(__sh__) && !defined(__s390__) && !defined (__s390x__) && !defined(__m68k__) +#if !defined(__aarch64__) && !defined(__alpha__) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) && !defined(__mips__) && !defined(__sh__) && !defined(__s390__) && !defined (__s390x__) && !defined(__m68k__) #include <sys/perm.h> #define HAVE_IOPERM #endif ++++++ xosview-sysinfo.patch ++++++ Index: xosview-1.16/Makefile =================================================================== --- xosview-1.16.orig/Makefile +++ xosview-1.16/Makefile @@ -3,6 +3,7 @@ AWK ?= awk INSTALL ?= install PLATFORM ?= linux +USE_SYSCALLS ?= 0 # Installation paths @@ -55,6 +56,9 @@ OBJS += linux/MeterMaker.o \ linux/acpitemp.o \ linux/coretemp.o CPPFLAGS += -Ilinux/ +ifneq ($(USE_SYSCALLS),0) +CPPFLAGS += -DUSE_SYSCALLS +endif endif ifeq ($(PLATFORM), bsd) Index: xosview-1.16/linux/cpumeter.cc =================================================================== --- xosview-1.16.orig/linux/cpumeter.cc +++ xosview-1.16/linux/cpumeter.cc @@ -13,7 +13,9 @@ #include <string> #include <sstream> #include <ctype.h> +#if defined(USE_SYSCALLS) && (USE_SYSCALLS > 0) #include <sys/utsname.h> +#endif static const char STATFILENAME[] = "/proc/stat"; static const char VERSIONFILENAME[] = "/proc/sys/kernel/osrelease"; @@ -340,9 +342,20 @@ const char *CPUMeter::toUpper(const char int CPUMeter::getkernelversion(void){ static int major = 0, minor = 0, micro = 0; if (!major) { +#if defined(USE_SYSCALLS) && (USE_SYSCALLS > 0) struct utsname myosrelease; uname(&myosrelease); sscanf(myosrelease.release, "%d.%d.%d", &major, &minor, µ); +#else + std::ifstream f(VERSIONFILENAME); + if (!f) { + std::cerr << "Can not get kernel version from " << VERSIONFILENAME << "." << std::endl; + exit(1); + } + std::string version; + f >> version; + sscanf(version._str(), "%d.%d.%d", &major, &minor, µ); +#endif } return (major*1000000 + minor*1000 + micro); } -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
