Undelete sysutils/xbattbar providing live distfile sources.

Requested by:	Nick Kostirya
This commit is contained in:
Eugene Grosbein 2021-01-01 05:02:59 +00:00
parent 6ebff72b31
commit 91e0bd3437
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=559801
9 changed files with 209 additions and 2 deletions

1
MOVED
View File

@ -13278,7 +13278,6 @@ sysutils/skill||2019-10-16|Has expired: Unfetchable, unmaintained
sysutils/sloth||2019-10-16|Has expired: Unfetchable, unmaintained
sysutils/snowlog||2019-10-16|Has expired: Unfetchable, unmaintained
sysutils/wmfire||2019-10-16|Has expired: Unfetchable, unmaintained
sysutils/xbattbar||2019-10-16|Has expired: Unfetchable, unmaintained
textproc/bedic-data||2019-10-16|Has expired: Unfetchable, unmaintained
textproc/clit||2019-10-16|Has expired: Unfetchable, unmaintained
textproc/docbook-tdg||2019-10-16|Has expired: Unfetchable, unmaintained

View File

@ -1487,6 +1487,7 @@
SUBDIR += wuzzah
SUBDIR += x86info
SUBDIR += xbatt
SUBDIR += xbattbar
SUBDIR += xcdroast
SUBDIR += xcpustate
SUBDIR += xdu

View File

@ -22,7 +22,7 @@ LIBSECRET_LIB_DEPENDS= libsecret-*.so:security/libsecret
DOCSDIR= ${PREFIX}/share/doc/${PORTNAME}-${PORTVERSION}
USES= compiler:c11 fuse gnome iconv pkgconfig samba:lib tar:bzip2
USES= autoreconf compiler:c11 fuse gnome iconv pkgconfig samba:lib tar:bzip2
USE_GNOME= glib20:build
GNU_CONFIGURE= yes

View File

@ -0,0 +1,26 @@
# Created by: sumikawa
# $FreeBSD$
PORTNAME= xbattbar
PORTVERSION= 1.4.2
PORTREVISION= 8
CATEGORIES= sysutils
MASTER_SITES= http://ftp.corbina.net/gentoo-distfiles/d6/ \
https://ftp.fau.de/gentoo/distfiles/ \
https://mirrors.mit.edu/gentoo-distfiles/distfiles/d6/
DISTNAME= ${PORTNAME}_${PORTVERSION}
MAINTAINER= ports@FreeBSD.org
COMMENT= Simple battery meter
LICENSE= GPLv2+
LICENSE_FILE= ${WRKSRC}/COPYING
USES= imake
USE_XORG= x11 xext
WRKSRC= ${WRKDIR}/xbattbar-${PORTVERSION}
PLIST_FILES= bin/xbattbar \
man/man1/xbattbar.1.gz
.include <bsd.port.mk>

View File

@ -0,0 +1,2 @@
SHA256 (xbattbar_1.4.2.tar.gz) = 55a5ed609282398f55e0141e473f9f04300d1ad3070810c7c6930f6c45970b4a
SIZE (xbattbar_1.4.2.tar.gz) = 14079

View File

@ -0,0 +1,12 @@
--- Imakefile- Fri Oct 16 02:14:52 1998
+++ Imakefile Fri Oct 16 02:15:41 1998
@@ -4,9 +4,6 @@
XCOMM All rights reserved.
XCOMM
-BINDIR = /usr/local/bin
-MANDIR = /usr/local/man/cat1
-
LOCAL_LIBRARIES = $(XLIB)
SRCS = xbattbar.c

View File

@ -0,0 +1,149 @@
--- xbattbar.c.orig 2001-02-02 06:25:29.000000000 +0100
+++ xbattbar.c 2012-04-04 17:47:34.000000000 +0200
@@ -29,6 +29,8 @@ static char *ReleaseVersion="1.4.2";
#include <sys/time.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/file.h>
#include <sys/ioctl.h>
@@ -501,6 +503,10 @@ void battery_check(void)
#ifdef __FreeBSD__
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#if defined(__i386__)
#include <machine/apm_bios.h>
#define APMDEV21 "/dev/apm0"
@@ -515,54 +521,90 @@ void battery_check(void)
#define APM_STAT_BATT_LOW 1
#define APM_STAT_BATT_CRITICAL 2
#define APM_STAT_BATT_CHARGING 3
+#endif /* i386 */
int first = 1;
void battery_check(void)
{
- int fd, r, p;
- struct apm_info info;
+ int r, p;
+ static int sysctl = 1;
- if ((fd = open(APMDEV21, O_RDWR)) == -1 &&
- (fd = open(APMDEV22, O_RDWR)) == -1) {
- fprintf(stderr, "xbattbar: cannot open apm device\n");
- exit(1);
- }
- if (ioctl(fd, APMIO_GETINFO, &info) == -1) {
- fprintf(stderr, "xbattbar: ioctl APMIO_GETINFO failed\n");
- exit(1);
+ if (sysctl) {
+ size_t r_size, p_size;
+
+ /* get current status */
+ r_size = sizeof(r);
+ if (sysctl && sysctlbyname("hw.acpi.battery.life", &r, &r_size, NULL, 0) == -1) {
+#if defined(__i386__)
+ fprintf(stderr, "xbattbar: fall back to apm interface\n");
+ sysctl = 0;
+#else /* !i386 */
+ fprintf(stderr, "xbattbar: can not get battery status\n");
+ exit(1);
+#endif /* i386 */
+ }
+
+ /* get AC-line status */
+ p_size = sizeof(p);
+ if (sysctl && sysctlbyname("hw.acpi.acline", &p, &p_size, NULL, 0) == -1) {
+#if defined(__i386__)
+ fprintf(stderr, "xbattbar: fall back to apm interface\n");
+ sysctl = 0;
+#else /* !i386 */
+ fprintf(stderr, "xbattbar: can not get AC-line status\n");
+ exit(1);
+#endif /* i386 */
+ }
}
- close (fd);
- ++elapsed_time;
+#if defined(__i386__)
+ if (!sysctl) {
+ int fd;
+ struct apm_info info;
+
+ if ((fd = open(APMDEV21, O_RDONLY)) == -1 &&
+ (fd = open(APMDEV22, O_RDONLY)) == -1) {
+ fprintf(stderr, "xbattbar: cannot open apm device\n");
+ exit(1);
+ }
+ if (ioctl(fd, APMIO_GETINFO, &info) == -1) {
+ fprintf(stderr, "xbattbar: ioctl APMIO_GETINFO failed\n");
+ exit(1);
+ }
+ close (fd);
- /* get current status */
- if (info.ai_batt_life == APM_STAT_UNKNOWN) {
- switch (info.ai_batt_stat) {
- case APM_STAT_BATT_HIGH:
- r = 100;
- break;
- case APM_STAT_BATT_LOW:
- r = 40;
- break;
- case APM_STAT_BATT_CRITICAL:
- r = 10;
- break;
- default: /* expected to be APM_STAT_UNKNOWN */
+ /* get current status */
+ if (info.ai_batt_life == APM_STAT_UNKNOWN) {
+ switch (info.ai_batt_stat) {
+ case APM_STAT_BATT_HIGH:
+ r = 100;
+ break;
+ case APM_STAT_BATT_LOW:
+ r = 40;
+ break;
+ case APM_STAT_BATT_CRITICAL:
+ r = 10;
+ break;
+ default: /* expected to be APM_STAT_UNKNOWN */
+ r = 100;
+ }
+ } else if (info.ai_batt_life > 100) {
+ /* some APM BIOSes return values slightly > 100 */
r = 100;
+ } else {
+ r = info.ai_batt_life;
}
- } else if (info.ai_batt_life > 100) {
- /* some APM BIOSes return values slightly > 100 */
- r = 100;
- } else {
- r = info.ai_batt_life;
- }
- /* get AC-line status */
- if (info.ai_acline == APM_STAT_LINE_ON) {
- p = APM_STAT_LINE_ON;
- } else {
- p = APM_STAT_LINE_OFF;
+ /* get AC-line status */
+ if (info.ai_acline == APM_STAT_LINE_ON) {
+ p = APM_STAT_LINE_ON;
+ } else {
+ p = APM_STAT_LINE_OFF;
+ }
}
+#endif /* i386 */
+
+ ++elapsed_time;
if (first || ac_line != p || battery_level != r) {
first = 0;

View File

@ -0,0 +1,11 @@
--- xbattbar.man.orig 2012-04-04 17:49:01.000000000 +0200
+++ xbattbar.man 2012-04-04 17:49:17.000000000 +0200
@@ -58,7 +58,7 @@ forces the status indicator to be at the
display,
respectively.
Though it's a default, you can also use
-.Nm buttom
+.Nm bottom
as the option.
.Pp
In the case the AC line is on-line (plugged in),

View File

@ -0,0 +1,7 @@
Xbattbar shows the current (laptop) battery status in the X window
environment. The battery indicator of this program is very simple: a simple
bar in the bottom of your display. With its color, it indicates the
AC-line status (plugged in or off-line), and battery
charging/remaining level.
WWW: http://iplab.aist-nara.ac.jp/member/suguru/xbattbar.html