In the range [60; 100] the full battery icon is displayed
In the range [30; 59] an icon that indicates around 60% battery level is displayed.
In the range [10; 30] an icon that indicates around 30-40% battery level is displayed
In the range [0; 9] an orange bar is displayed
Judging from the themes in 17.xx at /usr/share/icons/elementary-xfce/status/48 there's a lot more battery icon variety than what is being displayed (there's icons for 6 ranges!).
This patch fixes a compilation error, a gcc warning, and disables the 2nd fake battery (by default the git repo creates 2 fake batteries)
And then run:
make
sudo insmod ./fake_battery.ko
echo 'charging = 0' | sudo tee /dev/fake_battery
echo 'capacity0 = 50' | sudo tee /dev/fake_battery
This bug affects Xubuntu 18.04 but not 17.xx or earlier
It can be easily be reproduced on any desktop machine using https:/ /github. com/hoelzro/ linux-fake- battery- module (patch to compile on Xubuntu 18.04 is at the end)
I can see that:
In the range [60; 100] the full battery icon is displayed
In the range [30; 59] an icon that indicates around 60% battery level is displayed.
In the range [10; 30] an icon that indicates around 30-40% battery level is displayed
In the range [0; 9] an orange bar is displayed
Judging from the themes in 17.xx at /usr/share/ icons/elementar y-xfce/ status/ 48 there's a lot more battery icon variety than what is being displayed (there's icons for 6 ranges!).
As for the fake module, apply this patch:
diff --git a/fake_battery.c b/fake_battery.c power_supply. h>
index 2e3c04c..48da386 100644
--- a/fake_battery.c
+++ b/fake_battery.c
@@ -23,6 +23,7 @@
#include <linux/
#include <asm/uaccess.h>
+#include <linux/uaccess.h>
static int get_property1( struct power_supply *psy,
fake_battery_
@@ -63,7 +64,6 @@ static int ac_status = 1;
static char *fake_ac_supplies[] = {
"BAT0",
- "BAT1",
};
static enum power_supply_ property fake_battery_ properties[ ] = {
.get_ property = fake_battery_ get_property1,
@@ -99,14 +99,6 @@ static struct power_supply_desc descriptions[] = {
},
- { TYPE_BATTERY, properties, fake_battery_ properties) , get_property2, TYPE_MAINS, charge_ changes( int ac_status, struct battery_status *battery) device_ write(struct file *file, const char *buffer, size_t count, loff_t *ppos) device_ write(struct file *file, const char *buffer, size_t count, loff_t
- .name = "BAT1",
- .type = POWER_SUPPLY_
- .properties = fake_battery_
- .num_properties = ARRAY_SIZE(
- .get_property = fake_battery_
- },
-
{
.name = "AC0",
.type = POWER_SUPPLY_
@@ -220,7 +212,7 @@ handle_
static ssize_t
control_
{
- char kbuffer[1024]; /* limited by kernel frame size, 1K should be enough */
+ char kbuffer[512]; /* limited by kernel frame size, 1K should be enough */
char *buffer_cursor;
char *newline;
size_t bytes_left = count;
@@ -232,8 +224,8 @@ control_
return -EINVAL;
}
- if(count > 1024) {
- printk(KERN_ERR "Too much data provided to /dev/fake_battery (limit 1024 bytes)\n");
+ if(count > 512) {
+ printk(KERN_ERR "Too much data provided to /dev/fake_battery (limit 512 bytes)\n");
return -EINVAL;
}
@@ -264,7 +256,7 @@ control_ device_ write(struct file *file, const char *buffer, size_t count, loff_t
power_ supply_ changed( supplies[ 0]); supply_ changed( supplies[ 1]); changed( supplies[ 2]); supply_ changed( supplies[ 2]);
power_
- power_supply_
+ //power_
return count;
}
This patch fixes a compilation error, a gcc warning, and disables the 2nd fake battery (by default the git repo creates 2 fake batteries)
And then run:
make
sudo insmod ./fake_battery.ko
echo 'charging = 0' | sudo tee /dev/fake_battery
echo 'capacity0 = 50' | sudo tee /dev/fake_battery