[arch-commits] Commit in osdbattery/repos (5 files)

Felix Yan felixonmars at archlinux.org
Tue Jul 7 16:07:06 UTC 2020


    Date: Tuesday, July 7, 2020 @ 16:07:06
  Author: felixonmars
Revision: 659122

archrelease: copy trunk to community-staging-x86_64

Added:
  osdbattery/repos/community-staging-x86_64/
  osdbattery/repos/community-staging-x86_64/PKGBUILD
    (from rev 659121, osdbattery/trunk/PKGBUILD)
  osdbattery/repos/community-staging-x86_64/osdbattery.install
    (from rev 659121, osdbattery/trunk/osdbattery.install)
  osdbattery/repos/community-staging-x86_64/showbatt
    (from rev 659121, osdbattery/trunk/showbatt)
  osdbattery/repos/community-staging-x86_64/sysfs.patch
    (from rev 659121, osdbattery/trunk/sysfs.patch)

--------------------+
 PKGBUILD           |   34 ++++++++++++++
 osdbattery.install |    9 +++
 showbatt           |   12 +++++
 sysfs.patch        |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 174 insertions(+)

Copied: osdbattery/repos/community-staging-x86_64/PKGBUILD (from rev 659121, osdbattery/trunk/PKGBUILD)
===================================================================
--- community-staging-x86_64/PKGBUILD	                        (rev 0)
+++ community-staging-x86_64/PKGBUILD	2020-07-07 16:07:06 UTC (rev 659122)
@@ -0,0 +1,34 @@
+# Maintainer: Jaroslav Lichtblau <dragonlord at aur.archlinux.org>
+# Contributor: dibblethewrecker <dibblethewrecker at jiwe.org>
+
+pkgname=osdbattery
+pkgver=1.4
+pkgrel=8
+pkgdesc="Displays battery information in the OSD style"
+arch=('x86_64')
+url="http://osdbattery.sourceforge.net/"
+license=('GPL2')
+depends=('xosd')
+makedepends=('patch')
+install=$pkgname.install
+source=(https://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}_${pkgver}.tar.gz
+        sysfs.patch showbatt)
+sha256sums=('b1f775c746cd78b6aa7fc9ee75ecf2806ef3da93a42dd806c0414dcae55aed9f'
+            'd7a00e918929d36aaf3eb398649ea070ed6c4840e3da2407226fc5d9ae15d776'
+            '69969053235642315b49fe6ea5df7f8c391befbf492fd4ff71afbf4d438333b2')
+
+build() {
+  cd ${srcdir}/${pkgname}_${pkgver}
+  
+  patch -i ${srcdir}/sysfs.patch
+
+  make
+}
+
+package() {
+  cd ${srcdir}/${pkgname}_${pkgver}
+
+  install -D -m755 $pkgname ${pkgdir}/usr/bin/${pkgname}
+  install -D -m755 ${srcdir}/showbatt ${pkgdir}/usr/bin/showbatt
+  install -D -m644 $pkgname.cfg ${pkgdir}/etc/${pkgname}/${pkgname}.cfg
+}

Copied: osdbattery/repos/community-staging-x86_64/osdbattery.install (from rev 659121, osdbattery/trunk/osdbattery.install)
===================================================================
--- community-staging-x86_64/osdbattery.install	                        (rev 0)
+++ community-staging-x86_64/osdbattery.install	2020-07-07 16:07:06 UTC (rev 659122)
@@ -0,0 +1,9 @@
+post_install() {
+  echo "  : Remember to copy /etc/osdbattery/osdbattery.cfg to a ".osdbattery" directory in your home dir"
+  echo "  : mkdir ~/.osdbattery"
+  echo "  : cp /etc/osdbattery/osdbattery.cfg ~/.osdbattery"
+  echo
+  echo "  : The /usr/bin/showbatt script can be bound to a key combo to"
+  echo "  : easily show and hide the monitor"
+}
+

Copied: osdbattery/repos/community-staging-x86_64/showbatt (from rev 659121, osdbattery/trunk/showbatt)
===================================================================
--- community-staging-x86_64/showbatt	                        (rev 0)
+++ community-staging-x86_64/showbatt	2020-07-07 16:07:06 UTC (rev 659122)
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# osdbattery start/stop script - best bound to a keyboard combo
+
+PID=`pidof -o %PPID /usr/bin/osdbattery`
+if [ -z "$PID" ] ; then
+	/usr/bin/osdbattery &
+	echo $PID > /var/run/osdbattery.pid
+elif [ ! -z "$PID" ] ; then
+	kill $PID &> /dev/null
+	rm /var/run/osdbattery.pid
+fi

Copied: osdbattery/repos/community-staging-x86_64/sysfs.patch (from rev 659121, osdbattery/trunk/sysfs.patch)
===================================================================
--- community-staging-x86_64/sysfs.patch	                        (rev 0)
+++ community-staging-x86_64/sysfs.patch	2020-07-07 16:07:06 UTC (rev 659122)
@@ -0,0 +1,119 @@
+--- osdbattery.c	2005-08-23 09:31:10.000000000 +0200
++++ osdbattery-1.5.c	2011-12-03 23:41:24.655759085 +0100
+@@ -17,77 +17,55 @@
+ #include <xosd.h>
+ #endif
+ 
++int get_acpi_line(char* file, char* b, int size) {
++        FILE *fp;
++        fp = fopen(file, "r");
++        if (fp == NULL) {
++                printf("Cannot open ACPI info: \"%s\"\n Is ACPI supported by the kernel and is the \"display battery\" configuration correct?\n",file);
++                exit(1);
++        }
++
++        if (fgets(b, size, fp) == NULL) {
++                fclose(fp);
++                return 0;
++        }
++        b[strlen(b)-1] = 0; /* remove trailing newline*/
++
++        fclose(fp);
++        return 1;
++}
++
+ int get_battery_state(battery_state_struct* battery_state, int bnum) {
+-	char present_voltage[64];
+-	char charging_state[64];
+-	char remaining_capacity[64];
+ 	char file[64];
+-	char b[256];
+-	FILE *fp;
++	char b[64];
+ 
+-	sprintf(file, "/proc/acpi/battery/BAT%d/state", bnum );
++        sprintf(file, "/sys/class/power_supply/BAT%d/status", bnum);
++        if ( get_acpi_line(file, b, sizeof(b)) )
++                strcpy(battery_state->charging_state, b);
++
++        sprintf(file, "/sys/class/power_supply/BAT%d/voltage_now", bnum);
++        if ( get_acpi_line(file, b, sizeof(b)) )
++                battery_state->present_voltage = atoi(b);
++
++        sprintf(file, "/sys/class/power_supply/BAT%d/charge_now", bnum);
++        if ( get_acpi_line(file, b, sizeof(b)) )
++                battery_state->remaining_capacity = atoi(b);
+ 
+-	fp = fopen(file, "r");
+-	if (fp == NULL) {
+-		printf("Cannot open ACPI info! Is ACPI supported by the kernel?\n");
+-		exit(1);
+-	}
+-
+-	rewind(fp);
+-	while (!feof(fp)) {
+-
+-		if (fgets(b, 256, fp) == NULL) {
+-			fclose(fp);
+-			return 0;
+-		} 		
+-
+-		if (sscanf(b, "present voltage: %63s", present_voltage ) != errno) {
+-			battery_state->present_voltage = atoi(present_voltage);
+-		}
+-
+-		if (sscanf(b, "charging state: %63s", charging_state ) != errno) {
+-			strcpy(battery_state->charging_state, charging_state);
+-		}
+-
+-		if (sscanf(b, "remaining capacity: %63s", remaining_capacity ) != errno) {
+-			battery_state->remaining_capacity = atoi(remaining_capacity);
+-
+-		}
+-	}	
+-	fclose(fp);
+ 	return 0;
+ }
++
+ int get_battery_info(battery_info_struct* battery_info, int bnum) { 	
+-	char design_voltage[64];
+-	char last_full_capacity[64];
+ 	char file[64];
++	char b[64];
+ 
+-	sprintf(file, "/proc/acpi/battery/BAT%d/info", bnum );
+-
+-	FILE *fp = fopen(file,"r");
+-	if (fp == NULL) {
+-		printf("can not open acpi info, acpi supported by kernel?\n");
+-		exit(1);
+-	}
+-
+-	rewind(fp);
+-	char b[256];
+-
+-	while (!feof(fp)) {
+-
+-		if (fgets(b, 256, fp) == NULL) {
+-			fclose(fp);
+-			return 0;
+-		}
+-
+-		if (sscanf(b, "design voltage: %63s", design_voltage) != errno) {
+-			battery_info->design_voltage = atoi(design_voltage);							   	}
+-
+-		if (sscanf(b, "last full capacity: %63s", last_full_capacity) != errno) {
+-			battery_info->last_full_capacity = atoi(last_full_capacity);	
+-		}
++        sprintf(file, "/sys/class/power_supply/BAT%d/voltage_min_design", bnum);
++        if ( get_acpi_line(file, b, sizeof(b)) )
++                battery_info->design_voltage = atoi(b);
++
++        sprintf(file, "/sys/class/power_supply/BAT%d/charge_full", bnum);
++        if ( get_acpi_line(file, b, sizeof(b)) )
++                battery_info->last_full_capacity = atoi(b);
+ 
+-	}
+ 	return 0;
+ }
+ 


More information about the arch-commits mailing list