--- wmwave-0.4.orig/wmwave.1 +++ wmwave-0.4/wmwave.1 @@ -6,7 +6,8 @@ wmwave .SH SYNOPSIS .B wmwave -[\-c command] +.BI [\-r \ time ] +.B [\-v] .SH DESCRIPTION .B wmwave displays, as a WindowMaker dockapp, statistical information for @@ -14,13 +15,15 @@ .SH OPTIONS .TP -.I \-r time +.BI \-v +Display the version +.TP +.BI \-r \ time Sets the update interval (in milliseconds), default: 100 - -.I \-display display +.TP +.BI \-display \ display This option specifies the X server to contact; see X(1). - .SH BUGS Please report any bugs you may find to: .TP --- wmwave-0.4.orig/wmwave.c +++ wmwave-0.4/wmwave.c @@ -1,11 +1,11 @@ /* - * wmtop.c -- WindowMaker process view dock app + * wmwave.c -- WindowMaker wireless statistics view dock app * Derived by Carsten Schuermann carsten@schuermann.org * http://www.schuermann.org/~carsten * from * Dan Piponi dan@tanelorn.demon.co.uk * http://www.tanelorn.demon.co.uk - * who derived it + * who derived it * from code originally contained in wmsysmon by Dave Clark (clarkd@skynet.ca) * This software is licensed through the GNU General Public License. * $Log: wmwave.c,v $ @@ -50,9 +50,11 @@ #include #include #include -#include +#include #include +#include + #include #include #include @@ -76,7 +78,6 @@ time_t prevtime; int mode = 0; // default: no card detected -int screen = 0; // default: Quality screen is displayed void usage(void); void printversion(void); @@ -85,11 +86,12 @@ void wmwave_routine(int, char **); void DrawBar(float percent, int dx, int dy); void DrawGreenBar(float percent, int dx, int dy); +int iw_getinf_stats(const char *ifname, struct iw_range *range, struct iw_statistics *stats); inline void DrawBar(float percent, int dx, int dy) { int tx; - tx = (float)((float)54 * ((float)percent / (float)100.0)); + tx = (int)(54.0 * (percent * 0.01)); copyXPMArea(67, 36, tx, 4, dx, dy); copyXPMArea(67, 43, 54-tx, 4, dx+tx, dy); } @@ -98,7 +100,7 @@ inline void DrawGreenBar(float percent, int dx, int dy) { int tx; - tx = (float)((float)54 * ((float)percent / (float)100.0)); + tx = (int)(54.0 * (percent * 0.01)); copyXPMArea(67, 58, tx, 4, dx, dy); copyXPMArea(67, 43, 54-tx, 4, dx+tx, dy); } @@ -124,50 +126,101 @@ else {return y;} } -/* - * Find CPU times for all processes - */ void DisplayWireless(void) { + + struct iw_range range; + struct iw_statistics stats; + + float link; + float level; + float noise; + + FILE *wireless; // File handle for /proc/net/wireless - char line[255]; - char iface[5]; + char iface[6]; char status [3]; - float link = 0; - float level = 0; - float noise = 0; int nwid = 0; int crypt = 0; int misc = 0; - + if ((wireless = fopen ("/proc/net/wireless", "r")) != NULL) { fgets(line,sizeof(line),wireless); fgets(line,sizeof(line),wireless); if (fgets(line,sizeof(line),wireless) == NULL) { mode = 0; - } - else { + } else { sscanf(line,"%s %s %f %f %f %d %d %d", iface,status,&link,&level,&noise,&nwid,&crypt,&misc); + iface[strlen(iface)-1] = 0; /* remove ':' */ + if( (!iw_getinf_stats(iface, &range, &stats)) || (!range.max_qual.qual) ) + range.max_qual.qual = 100; mode = 1; } fclose(wireless); - - + + + /* dBm values need a special treatment */ + if ((stats.qual.updated & IW_QUAL_DBM) || + (stats.qual.level > range.max_qual.level)) + { + /* some cards (like the atheros) simply don't give a floor */ + float noise_floor = range.max_qual.noise ? (float)(range.max_qual.noise - 0x100) : -128.0; + float level_floor = range.max_qual.level ? (float)(range.max_qual.level - 0x100) : -128.0; + + level = (float)(stats.qual.level - 0x100); + noise = (float)(stats.qual.noise - 0x100); + + level = 100.0 * ( 1.0 - (level / level_floor)); + noise = 100.0 * ( 1.0 - (noise / noise_floor)); + } + else + { + float max_level = (float)range.max_qual.level; + float max_noise = (float)range.max_qual.noise; + + level = (float)stats.qual.level; + noise = (float)stats.qual.noise; + + level = 100.0 * level / max_level; + noise = 100.0 * noise / max_noise; + } + + if ((stats.qual.updated & IW_QUAL_LEVEL_INVALID) + || level < 0.0 || level > 100.0 ) + level = 0.0; + + if ((stats.qual.updated & IW_QUAL_NOISE_INVALID) + || noise < 0.0 || noise > 100.0 ) + noise = 0.0; + + if (!(stats.qual.updated & IW_QUAL_QUAL_INVALID) + && (abs(stats.qual.qual) <= abs(range.max_qual.qual))) + { + link = stats.qual.qual; + link /= (float) range.max_qual.qual; + link *= 100.0; + } + else + link = 0.0; + /* Print channel information, and signal ratio */ - switch (mode) { case 1: BlitString("Quality",4,4); - if (link<=10) {DrawRedDot ();} - else if (link<=20) {DrawYellowDot ();} - else {DrawGreenDot();}; + if (link<=0.1 * range.max_qual.qual) { + DrawRedDot (); + } else if (link<=0.2 * range.max_qual.qual) { + DrawYellowDot (); + } else { + DrawGreenDot(); + } BlitString("Link ", 4,18); - DrawBar(min ((int)(link * 1.8), 100.0), 4, 27); + DrawBar(min(link, 100.0), 4, 27); BlitString("Level ", 4,32); - DrawGreenBar(min ((int)(level * 0.3), 100.0), 4, 41); + DrawGreenBar(min(level, 100.0), 4, 41); BlitString("Noise ", 4,46); - DrawGreenBar(min ((int)(noise * 0.3), 100.0), 4, 55); + DrawGreenBar(min(noise, 100.0), 4, 55); break; case 0: BlitString("NO CARD",4,4); DrawEmptyDot(); @@ -181,7 +234,8 @@ }; } else { - printf ("Wirless device /proc/net/wireless not found\nEnable radio networking and recompile your kernel\n"); + printf ("Wirless device /proc/net/wireless not found\n" + "Enable radio networking and recompile your kernel\n"); exit (0); } } @@ -237,7 +291,7 @@ } } } - + wmwave_routine(argc, argv); return 0; @@ -285,11 +339,6 @@ case DestroyNotify: XCloseDisplay(display); exit(0); - case ButtonPress: - switch (screen) { - case 0: screen=1; break; - case 1: screen=0; break; - }; break; } } @@ -298,6 +347,29 @@ } } +/* get stats & range information */ +int iw_getinf_stats(const char *ifname, struct iw_range *range, struct iw_statistics *stats) +{ + int skfd; + int has_range; + + memset(range, 0, sizeof(struct iw_range)); + memset(stats, 0, sizeof(struct iw_statistics)); + + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + return 0; + } + + has_range = (iw_get_range_info(skfd, ifname, range) >= 0); + + if(iw_get_stats(skfd, ifname, stats, range, has_range) < 0) { + close(skfd); + return 0; + }; + close(skfd); + return 1; +} + /* * Blits a string at given co-ordinates */ --- wmwave-0.4.orig/Makefile +++ wmwave-0.4/Makefile @@ -7,21 +7,21 @@ # Added wmwave project to repository LIBDIR = -L/usr/X11R6/lib -LIBS = -lXpm -lXext -lX11 -lm -FLAGS = -O6 +LIBS = -lXpm -lXext -lX11 -lm -liw +CFLAGS = -O2 -Wall OBJS = \ wmgeneral.o \ default:all .c.o: - cc -I/usr/X11R6/share/include $(FLAGS) -c -Wall $< -o $*.o + cc $(CFLAGS) -I/usr/X11R6/share/include -c $< -o $*.o wmwave.o: wmwave.c wmwave-master.xpm - cc -I/usr/X11R6/share/include $(FLAGS) -c -Wall wmwave.c -o $*.o + cc $(CFLAGS) -I/usr/X11R6/share/include -c wmwave.c -o $*.o wmwave: $(OBJS) wmwave.o - cc $(FLAGS) -o wmwave $(OBJS) -lXext $(LIBDIR) $(LIBS) wmwave.o + cc $(CFLAGS) -o wmwave wmwave.o $(OBJS) -lXext $(LIBDIR) $(LIBS) all:: wmwave @@ -31,11 +31,5 @@ rm -f *~ install:: wmwave - strip wmwave - cp -f wmwave /usr/bin/ - chmod 755 /usr/bin/wmwave - chown root:root /usr/bin/wmwave - cp -f wmwave.1 /usr/man/man1 - chmod 644 /usr/man/man1/wmwave.1 - chown root:root /usr/man/man1/wmwave.1 - @echo "wmwave Installation finished..." + install $(INSTALL_OPTS) -o root -g root -m 0755 wmwave $(DESTDIR)/usr/bin/ + install -o root -g root -m 0644 wmwave.1 $(DESTDIR)/usr/share/man/man1/ --- wmwave-0.4.orig/debian/compat +++ wmwave-0.4/debian/compat @@ -0,0 +1 @@ +4 --- wmwave-0.4.orig/debian/changelog +++ wmwave-0.4/debian/changelog @@ -0,0 +1,97 @@ +wmwave (0.4-9ubuntu1) natty; urgency=low + + * Makefile: Fix linking with ld --as-needed. + + -- Michael Bienia Mon, 06 Dec 2010 10:56:14 +0100 + +wmwave (0.4-9build1) lucid; urgency=low + + * No change rebuild for libiw29 transition + + -- Scott Kitterman Wed, 31 Mar 2010 21:39:26 -0400 + +wmwave (0.4-9) unstable; urgency=low + + * fix noise and level calculation for dBm. Thanks to Paul Martin for + feedback and suggestions (Closes: #406947) + + -- Guido Guenther Fri, 15 Jun 2007 16:33:33 +0200 + +wmwave (0.4-8) unstable; urgency=low + + * use iwlib instead of doing the ioctl ourselfes (Closes: #427594, #406947, #225279) + * update homepage in debian/copyright and debian/control (Closes: #421405) + * switch to debhelper 5 + + -- Guido Guenther Sat, 09 Jun 2007 14:23:36 +0200 + +wmwave (0.4-7) unstable; urgency=low + + * add patch from Julien BLACHE to use the proper ioctl + instead of parsing /proc/net/wireless, this also fixes some problems when + the driver reports values in dB or displays erratic values like the level + being higher than the max level - thanks a lot Julien. + * bump standards version + * update email address + + -- Guido Guenther Sat, 13 Jan 2007 22:16:01 +0100 + +wmwave (0.4-6) unstable; urgency=low + + * Build-Depend on the specific x libraries instead of libx11-dev + (Closes: 346783) + * Bump standards version to 3.6.2 (no source changes) + * quote all menu strings + + -- Guido Guenther Mon, 9 Jan 2006 10:10:35 +0100 + +wmwave (0.4-5) unstable; urgency=low + + * recompile against linux-kernel-headers, fixing segfault on 2.6 kernels + (Closes: #201713) + * minor source code cleanups + + -- Guido Guenther Tue, 23 Dec 2003 00:10:32 +0100 + +wmwave (0.4-4) unstable; urgency=low + + * manpage cleanups by Ludovic Rousseau, thanks (Closes: #216597) + * fix typo in copyright file + * sanitize Makfile a bit and handle DH_BUILD_OPTIONS + * fix possible overflow in iface[]/wmwave.c + * bump Standards-Version to 3.6.1 + + -- Guido Guenther Sun, 26 Oct 2003 19:59:59 +0100 + +wmwave (0.4-3) unstable; urgency=low + + * package taken from Noah L. Meyerhans, thanks. + * remove CVS/ directories (Closes: #201220) + * remove executable bits from wmwave.c + * fix wrong link display by calling SIOCGIWRANGE ioctl (Closes: #151376) + * fix typo in description (Closes: #125502) + * echo 4 > debian/compat, adjust debhelper dependency + * bump standards version to 3.5.6 + + -- Guido Guenther Sun, 13 Jul 2003 22:32:27 +0200 + +wmwave (0.4-2.1) unstable; urgency=low + + * NMU + * debian/control: added xlibs-dev to Build-Depends + + -- Branden Robinson Fri, 13 Jul 2001 16:45:23 -0500 + +wmwave (0.4-2) unstable; urgency=low + + * Fixed a bug in the entry in the Debian menu system. (Closes: Bug#99745) + * Bumped the standards version up to 3.5.4.0 + + -- Noah Meyerhans Sat, 2 Jun 2001 22:29:54 -0400 + +wmwave (0.4-1) unstable; urgency=low + + * Initial Release. + + -- Noah Meyerhans Tue, 07 Feb 2001 16:42:03 -0500 + --- wmwave-0.4.orig/debian/copyright +++ wmwave-0.4/debian/copyright @@ -0,0 +1,12 @@ +This package was debianized by Noah Meyerhans on +Tue, 12 Dec 2000 16:42:03 -0500. + +It was downloaded from http://wmwave.sourceforge.net + +Copyright: +WMWave is copyright(c) 1999 Carsten Schuermann +and is licensed under version 2 of the GPL. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + --- wmwave-0.4.orig/debian/rules +++ wmwave-0.4/debian/rules @@ -0,0 +1,90 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_OPTS = -s +endif + +configure: configure-stamp +configure-stamp: + dh_testdir + touch configure-stamp + +build: configure-stamp build-stamp +build-stamp: + dh_testdir + + # Add here commands to compile the package. + $(MAKE) CFLAGS="$(CFLAGS)" + #/usr/bin/docbook-to-man debian/wmwave.sgml > wmwave.1 + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/tmp. + $(MAKE) install DESTDIR=`pwd`/debian/wmwave INSTALL_OPTS="$(INSTALL_OPTS)" + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install +# dh_testversion + dh_testdir + dh_testroot +# dh_installdebconf + dh_installdocs + dh_installexamples + dh_installmenu +# dh_installemacsen +# dh_installpam +# dh_installinit + dh_installcron + dh_installmanpages + dh_installinfo +# dh_undocumented + dh_installchangelogs + dh_link + dh_strip + dh_compress + dh_fixperms + # You may want to make some executables suid here. + #dh_suidregister +# dh_makeshlibs + dh_installdeb +# dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure --- wmwave-0.4.orig/debian/control +++ wmwave-0.4/debian/control @@ -0,0 +1,17 @@ +Source: wmwave +Section: x11 +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Guido Guenther +Build-Depends: debhelper (>= 5), libxpm-dev, libxext-dev, libx11-dev, libiw-dev +Standards-Version: 3.7.2 + +Package: wmwave +Architecture: any +Depends: ${shlibs:Depends} +Description: Monitor status of an 802.11 wireless ethernet link + wmwave is dockapp for Window Maker to display statistical information + about a current wireless ethernet connection. While made for Window + Maker, it works with other window managers. + . + Homepage: http://wmwave.sourceforge.net --- wmwave-0.4.orig/debian/menu +++ wmwave-0.4/debian/menu @@ -0,0 +1,2 @@ +?package(wmwave):needs="X11" section="Apps/System"\ + title="wmwave" command="/usr/bin/wmwave" --- wmwave-0.4.orig/debian/dirs +++ wmwave-0.4/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/man/man1 --- wmwave-0.4.orig/debian/docs +++ wmwave-0.4/debian/docs @@ -0,0 +1 @@ +README