diff -Naupr lxpanel_orig/patch1.patch lxpanel/patch1.patch --- lxpanel_orig/patch1.patch 1970-01-01 07:00:00.000000000 +0700 +++ lxpanel/patch1.patch 2016-12-08 10:03:29.000000000 +0700 @@ -0,0 +1,114 @@ +From ad0022eb8b1524b18d2b512d7dd8d2920c0f8dab Mon Sep 17 00:00:00 2001 +From: Andriy Grytsenko +Date: Fri, 25 Nov 2016 01:18:47 +0200 +Subject: [PATCH] Fix battery selection, it appears incompatible with 0.7.2 + behavior. + +See https://bugs.debian.org/845555 +--- + ChangeLog | 2 ++ + TODO | 2 +- + plugins/batt/batt_sys.c | 30 +++++++++++++++--------------- + 3 files changed, 18 insertions(+), 16 deletions(-) + +diff --git a/ChangeLog b/ChangeLog +index a21a14e..0abe16b 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,5 @@ ++* Fixed battery selection, it appears incompatible with 0.7.2 behavior. ++ + 0.9.1 + ------------------------------------------------------------------------- + * Fixed build failure without ALSA. +diff --git a/TODO b/TODO +index 965b17c..8d9f91f 100644 +--- a/TODO ++++ b/TODO +@@ -17,7 +17,7 @@ + * decide 'netstat' vs 'netstatus' + * optional libnotify support (useful for battery and volume plugins) + * pull improvements from Raspbian +-* add Most Recent support into 'menu' plugin ++* add Most Recent support into 'menu' plugin (option: ones not by Run too) + * check and use weather-* standard themed icons for weather plugin + * "Remove this Launch Button" option in launchbar context menu + * 'usb-unmount' plugin +diff --git a/plugins/batt/batt_sys.c b/plugins/batt/batt_sys.c +index 154bd3d..2482c6f 100644 +--- a/plugins/batt/batt_sys.c ++++ b/plugins/batt/batt_sys.c +@@ -4,6 +4,7 @@ + * Copyright 2009 Juergen Hötzel + * 2015 Henry Gebhardt + * 2015 Stanislav Kozina, Ersin ++ * 2016 Andriy Grytsenko + * + * Parts shameless stolen and glibified from acpi package + * Copyright (C) 2001 Grahame Bowland +@@ -295,15 +296,8 @@ battery *battery_get(int battery_number) { + const gchar *entry; + gchar *batt_name = NULL; + gchar *batt_path = NULL; +- GDir * dir = g_dir_open( ACPI_PATH_SYS_POWER_SUPPLY, 0, &error ); ++ GDir * dir; + battery *b = NULL; +- int i; +- +- if ( dir == NULL ) +- { +- g_warning( "NO ACPI/sysfs support in kernel: %s", error->message ); +- return NULL; +- } + + /* Try the expected path in sysfs first */ + batt_name = g_strdup_printf(ACPI_BATTERY_DEVICE_NAME "%d", battery_number); +@@ -324,13 +318,20 @@ battery *battery_get(int battery_number) { + g_free(batt_path); + + if (b != NULL) +- goto done; ++ return b; + + /* + * We didn't find the expected path in sysfs. +- * Walk the dir and blindly return n-th entry. ++ * Walk the dir and return any battery. + */ +- i = 0; ++ dir = g_dir_open( ACPI_PATH_SYS_POWER_SUPPLY, 0, &error ); ++ if ( dir == NULL ) ++ { ++ g_warning( "NO ACPI/sysfs support in kernel: %s", error->message ); ++ g_error_free(error); ++ return NULL; ++ } ++ + while ( ( entry = g_dir_read_name (dir) ) != NULL ) + { + b = battery_new(); +@@ -339,9 +340,7 @@ battery *battery_get(int battery_number) { + + /* We're looking for a battery with the selected ID */ + if (b->type_battery == TRUE) { +- if (i == battery_number) +- break; +- i++; ++ break; + } + battery_free(b); + b = NULL; +@@ -349,9 +348,10 @@ battery *battery_get(int battery_number) { + if (b != NULL) + g_warning( "Battery entry " ACPI_BATTERY_DEVICE_NAME "%d not found, using %s", + battery_number, b->path); ++ // FIXME: update config? + else + g_warning( "Battery %d not found", battery_number ); +-done: ++ + g_dir_close( dir ); + return b; + } +-- +2.1.4 diff -Naupr lxpanel_orig/patch2.patch lxpanel/patch2.patch --- lxpanel_orig/patch2.patch 1970-01-01 07:00:00.000000000 +0700 +++ lxpanel/patch2.patch 2016-12-08 10:03:43.000000000 +0700 @@ -0,0 +1,64 @@ +From 138ff9b22b45192a3b020ebbbed04e9060470a66 Mon Sep 17 00:00:00 2001 +From: Andriy Grytsenko +Date: Fri, 25 Nov 2016 02:06:39 +0200 +Subject: [PATCH] Fix battery percentage calculations if charge isn't available + but energy is. + +Should fix https://bugs.debian.org/845555 bug. +--- + ChangeLog | 4 +++- + plugins/batt/batt_sys.c | 17 ++++++++++------- + 2 files changed, 13 insertions(+), 8 deletions(-) + +diff --git a/ChangeLog b/ChangeLog +index 0abe16b..f4e4f61 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,4 +1,6 @@ +-* Fixed battery selection, it appears incompatible with 0.7.2 behavior. ++* Fixed battery selection if battery detached but another is available. ++* Fixed battery percentage calculations if charge isn't available but ++ energy is, it appears broken in 0.9.0. + + 0.9.1 + ------------------------------------------------------------------------- +diff --git a/plugins/batt/batt_sys.c b/plugins/batt/batt_sys.c +index 2482c6f..bd01e08 100644 +--- a/plugins/batt/batt_sys.c ++++ b/plugins/batt/batt_sys.c +@@ -167,6 +167,7 @@ static gboolean battery_inserted(gchar* path) + battery* battery_update(battery *b) + { + gchar *gctmp; ++ int promille; + + if (b == NULL) + return NULL; +@@ -253,16 +254,18 @@ battery* battery_update(battery *b) + } + #endif + +- if (b->charge_full < MIN_CAPACITY) +- b->percentage = 0; +- else { +- int promille = (b->charge_now * 1000) / b->charge_full; +- b->percentage = (promille + 5) / 10; /* round properly */ +- } ++ if (b->charge_now != -1 && b->charge_full != -1) ++ promille = (b->charge_now * 1000) / b->charge_full; ++ else if (b->energy_full != -1 && b->energy_now != -1) ++ /* no charge data, let try energy instead */ ++ promille = (b->energy_now * 1000) / b->energy_full; ++ else ++ promille = 0; ++ ++ b->percentage = (promille + 5) / 10; /* round properly */ + if (b->percentage > 100) + b->percentage = 100; + +- + if (b->current_now == -1) { + //b->poststr = "rate information unavailable"; + b->seconds = -1; +-- +2.1.4 diff -Naupr lxpanel_orig/PKGBUILD lxpanel/PKGBUILD --- lxpanel_orig/PKGBUILD 2016-12-08 05:23:48.000000000 +0700 +++ lxpanel/PKGBUILD 2016-12-08 10:08:05.000000000 +0700 @@ -6,7 +6,7 @@ pkgname=lxpanel pkgver=0.9.1 -pkgrel=1 +pkgrel=2 pkgdesc='Lightweight X11 desktop panel for LXDE' arch=('i686' 'x86_64') license=('GPL2') @@ -15,8 +15,23 @@ groups=('lxde') depends=('alsa-lib' 'menu-cache' 'lxmenu-data' 'libwnck' 'libfm-gtk2' 'libkeybinder2') makedepends=('intltool' 'docbook-xml' 'docbook-xsl' 'wireless_tools') optdepends=('wireless_tools: netstat plugin') -source=(https://downloads.sourceforge.net/lxde/$pkgname-$pkgver.tar.xz) -sha256sums=('11c7be044616c457cd18555758ae00c953c118cbfe0b0d6f4010bdacecc751b1') +source=(https://downloads.sourceforge.net/lxde/$pkgname-$pkgver.tar.xz + patch1.patch + patch2.patch) +sha256sums=('11c7be044616c457cd18555758ae00c953c118cbfe0b0d6f4010bdacecc751b1' + 'fe05c47856d1433bcec357fbfd3dfa39117cc416cfde32af85fd14923565fab4' + 'a5af5050531ac9a1d73802182635bcc166e15c8ba5fb625529cc6617f105ce1d') + +prepare() { + cd $pkgname-$pkgver + + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=845555 + + # Fix battery selection, it appears incompatible with 0.7.2 behavior. + patch -p1 -i ../patch1.patch + # Fix battery percentage calculations if charge isn't available but energy is. + patch -p1 -i ../patch2.patch +} build() { cd $pkgname-$pkgver