This commit is contained in:
CTK 2015-06-08 13:46:39 +02:00
commit 9658a9f4ef
3 changed files with 225 additions and 0 deletions

19
.SRCINFO Normal file
View file

@ -0,0 +1,19 @@
pkgbase = fbpanel-svn
pkgdesc = NetWM compliant desktop panel
pkgver = 515
pkgrel = 5
url = http://fbpanel.sourceforge.net/
arch = i686
arch = x86_64
license = GPL
makedepends = subversion
depends = gtk2
provides = fbpanel
conflicts = fbpanel
source = fbpanel-svn::svn+https://fbpanel.svn.sourceforge.net/svnroot/fbpanel/trunk#revision=515
source = https://sourceforge.net/p/fbpanel/patches/_discuss/thread/b77d09e7/4927/attachment/fbpanel_sys_battery.patch
md5sums = SKIP
md5sums = d0e40eeb3b32e941e2e656bda1da2428
pkgname = fbpanel-svn

61
PKGBUILD Normal file
View file

@ -0,0 +1,61 @@
# Maintainer: Calimero <calimeroteknik@free.fr>
pkgname=fbpanel-svn
pkgver=515
pkgrel=5
pkgdesc='NetWM compliant desktop panel'
arch=('i686' 'x86_64')
url='http://fbpanel.sourceforge.net/'
depends=('gtk2')
makedepends=('subversion')
conflicts=('fbpanel')
provides=('fbpanel')
license=('GPL')
source=("$pkgname"::"svn+https://fbpanel.svn.sourceforge.net/svnroot/fbpanel/trunk#revision=$pkgver"
'https://sourceforge.net/p/fbpanel/patches/_discuss/thread/b77d09e7/4927/attachment/fbpanel_sys_battery.patch')
md5sums=('SKIP'
'd0e40eeb3b32e941e2e656bda1da2428')
pkgver() {
cd "${srcdir}/${pkgname}"
local ver="$(svnversion)"
printf "%s" "${ver//[[:alpha:]]}"
}
prepare() {
cd "${srcdir}/${pkgname}"
# Why is the menu icon highlighted in red?
# Fix this to a white highlight.
sed -i 's/0x702020/0x282828/' plugins/menu/menu.c
# Fix battery plugin
patch -d plugins/battery -Np0 -i "${srcdir}/fbpanel_sys_battery.patch"
}
build() {
cd "${srcdir}/${pkgname}"
# Fix missing linker flags
export LDFLAGS="${LDFLAGS} -lX11 -lm"
# Python2 fix
sed -i 's|/usr/bin/python$|/usr/bin/python2|' configure
./configure --prefix=/usr \
--mandir=/usr/share/man/man1 \
--libexecdir="/usr/lib$([[ "$pkgver" > 515 ]] && echo '/fbpanel')"
# Additional python2 fix for the new build system introduced in r516
[[ "$pkgver" > 515 ]] && sed -i 's|/usr/bin/python$|/usr/bin/python2|' repl.py
make
}
package() {
cd "${srcdir}/${pkgname}"
make DESTDIR="${pkgdir}" install
# Man page was forgotten before r516
[[ "$pkgver" > 515 ]] || install -Dm 644 data/man/fbpanel.1 "${pkgdir}/usr/share/man/man1/fbpanel.1"
}

145
fbpanel_sys_battery.patch Normal file
View file

@ -0,0 +1,145 @@
Index: os_linux.c
===================================================================
--- os_linux.c (revision 513)
+++ os_linux.c (working copy)
@@ -1,9 +1,11 @@
#include <string.h>
#include <ctype.h>
+#include <stdlib.h>
#define LEN 100
#define PROC_ACPI "/proc/acpi/battery/"
+#define SYS_PS "/sys/class/power_supply/"
static gboolean
@@ -119,14 +121,126 @@
RET(ret);
}
+
static gboolean
-battery_update_os_sys(battery_priv *c)
+read_sys(battery_priv *c, GString *path)
{
- ENTER;
+ int len, charge_full, charge_now;
+ gchar *buf;
+ gboolean ret, exist, charging;
+
+ ENTER;
+ len = path->len;
+
+ g_string_append(path, "/present");
+ ret = g_file_get_contents(path->str, &buf, 0, NULL);
+ DBG("reading %s %s\n", path->str, ret ? "ok" : "fail");
+ g_string_truncate(path, len);
+ if (!ret)
RET(FALSE);
+ exist = (*buf == '1');
+ g_free(buf);
+
+ if (!exist)
+ RET(FALSE);
+
+ g_string_append(path, "/status");
+ ret = g_file_get_contents(path->str, &buf, 0, NULL);
+ DBG("reading %s %s\n", path->str, ret ? "ok" : "fail");
+ g_string_truncate(path, len);
+ if (!ret)
+ RET(FALSE);
+ charging = strcmp(buf,"Discharging\n");
+ if (charging < 0) charging = 1;
+ g_free(buf);
+
+ g_string_append(path, "/energy_full");
+ ret = g_file_test(path->str, G_FILE_TEST_EXISTS);
+ if (!ret) { // check for old charge_full file
+ g_string_truncate(path, len);
+ g_string_append(path, "/charge_full");
+ ret = g_file_test(path->str, G_FILE_TEST_EXISTS);
+ if (!ret) {
+ g_string_truncate(path, len);
+ RET(FALSE);
+ }
+ }
+ ret = g_file_get_contents(path->str, &buf, 0, NULL);
+ DBG("reading %s %s\n", path->str, ret ? "ok" : "fail");
+ g_string_truncate(path, len);
+ if (!ret)
+ RET(FALSE);
+ charge_full = atoi(buf);
+ g_free(buf);
+
+ g_string_append(path, "/energy_now");
+ ret = g_file_test(path->str, G_FILE_TEST_EXISTS);
+ if (!ret) { // check for old charge_now file
+ g_string_truncate(path, len);
+ g_string_append(path, "/charge_now");
+ ret = g_file_test(path->str, G_FILE_TEST_EXISTS);
+ if (!ret) {
+ g_string_truncate(path, len);
+ RET(FALSE);
+ }
+ }
+
+ ret = g_file_get_contents(path->str, &buf, 0, NULL);
+ DBG("reading %s %s\n", path->str, ret ? "ok" : "fail");
+ g_string_truncate(path, len);
+ if (!ret)
+ RET(FALSE);
+ charge_now = atoi(buf);
+ g_free(buf);
+
+ DBG("battery=%s\nfull charge=%d\ncharge now=%d\n"
+ "charging=%d\n",
+ path->str, charge_full, charge_now, charging);
+
+ if (!(charge_full >= charge_now && charge_full > 0 && charge_now >= 0))
+ RET(FALSE);
+
+ c->exist = TRUE;
+ c->charging = charging;
+ c->level = (int) ((gfloat) charge_now * 100 / (gfloat) charge_full);
+ RET(TRUE);
}
static gboolean
+battery_update_os_sys(battery_priv *c)
+{
+ GString *path;
+ int len;
+ GDir *dir;
+ gboolean ret = FALSE;
+ const gchar *file;
+
+ ENTER;
+
+ c->exist = FALSE;
+ path = g_string_sized_new(200);
+ g_string_append(path, SYS_PS);
+ len = path->len;
+ if (!(dir = g_dir_open(path->str, 0, NULL)))
+ DBG("can't open dir %s\n", path->str);
+ else {
+ while (!ret && (file = g_dir_read_name(dir))) {
+ if (!strcmp(file,"AC"))
+ continue; // skip the AC dir
+ g_string_append(path, file);
+ DBG("testing %s\n", path->str);
+ ret = g_file_test(path->str, G_FILE_TEST_IS_DIR);
+ if (ret)
+ ret = read_sys(c, path);
+ g_string_truncate(path, len);
+ }
+ g_dir_close(dir);
+ }
+ g_string_free(path, TRUE);
+ RET(ret);
+}
+
+static gboolean
battery_update_os(battery_priv *c)
{
ENTER;