Tiny Core Linux

Tiny Core Base => CorePlus => Topic started by: 0day on April 18, 2017, 08:04:37 AM

Title: Battery monitor or icon?
Post by: 0day on April 18, 2017, 08:04:37 AM
A battery indicator for tiny core?
Title: Re: Battery monitor or icon?
Post by: bmarkus on April 18, 2017, 08:17:24 AM
A battery indicator for tiny core?

Check your desktop plugins. In general there are no such thing that Tiny Core icon :(

Title: Re: Battery monitor or icon?
Post by: Juanito on April 18, 2017, 08:47:46 AM
there's the watcher extension
Title: Re: Battery monitor or icon?
Post by: Misalf on April 18, 2017, 09:40:10 AM
Or Conky.
Title: Re: Battery monitor or icon?
Post by: h2sammo on January 26, 2019, 03:22:57 AM
i installed watcher but no battery monitor. just %C, %M and %S
Title: Re: Battery monitor or icon?
Post by: Juanito on January 26, 2019, 04:03:59 AM
It looks like there's a patch pending:

http://forum.tinycorelinux.net/index.php/topic,21360.msg133540.html#msg133540

..but the %m, and presumeably %s, part works for me.
Title: Re: Battery monitor or icon?
Post by: NewUser on January 28, 2019, 11:18:36 PM
I use flit. I serves my needs, and takes little desktop space. 32-bit only, though.
Title: Re: Battery monitor or icon?
Post by: Juanito on January 29, 2019, 01:01:59 AM
flit added to CorePure64 repo

Edit: and recompiled for fltk-1.1.0 -> fltk-1.3 in Core repo
Title: Re: Battery monitor or icon?
Post by: Rich on January 29, 2019, 01:30:52 PM
Hi h2sammo
i installed watcher but no battery monitor. just %C, %M and %S

It looks like there's a patch pending:

http://forum.tinycorelinux.net/index.php/topic,21360.msg133540.html#msg133540

..but the %m, and presumeably %s, part works for me.

I did some checking and it seems my patch was applied to the source code but the repo was never updated. I confirmed
this by examining the executable that's currently in the repo.  I did some minor cleanup and recompiled the program. A new
package has been submitted and will be available as soon as the repo is updated.
Title: Re: Battery monitor or icon?
Post by: NewUser on January 29, 2019, 09:07:21 PM
flit added to CorePure64 repo

Edit: and recompiled for fltk-1.1.0 -> fltk-1.3 in Core repo
Thank you Juanito. Looks like I'll be going 64-bit.
Title: Re: Battery monitor or icon?
Post by: Juanito on January 29, 2019, 09:50:07 PM
updated watcher posted - thanks

On my machine (dell e7240) running tc-10.x, I get this:
Code: [Select]
$ ls /sys/class/power_supply/BAT0
alarm               current_now         present             uevent
capacity            cycle_count         serial_number       voltage_min_design
capacity_level      device              status              voltage_now
charge_full         manufacturer        subsystem
charge_full_design  model_name          technology
charge_now          power/              type

..and:
Code: [Select]
$ ls /sys/class/power_supply/AC
device     online     power/     subsystem  type       uevent

It looks like watcher is calculating C% from either charge_now or energy_now divided by either charge_full or energy_full.

I get 1742000/2457000=71%, but the watcher display varies slowly between 6.7% and 7.2% - i.e. a factor of 10 out?
Title: Re: Battery monitor or icon?
Post by: Rich on January 29, 2019, 10:30:55 PM
Hi Juanito
The calculation code looks correct:
Code: [Select]
sprintf(batmsg, " %.1f%%B", (float)(batnow / batfull) * 100);
BAT0  looks like the correct value to pass to watcher.
Title: Re: Battery monitor or icon?
Post by: Rich on January 29, 2019, 10:44:38 PM
Hi Juanito
Quote
... It looks like watcher is calculating C% from either charge_now or energy_now divided by either charge_full or energy_full. ...
You mean %B. %C is the CPU. Did you start watcher like this:
Code: [Select]
watcher -bat BAT0to tell it where to find the battery?
Title: Re: Battery monitor or icon?
Post by: Juanito on January 29, 2019, 10:53:26 PM
doh  :-[

It works now (and matches flit) - thanks

..but constantly repeats this to stdout:
Code: [Select]
$ ./watcher -bat BAT0
Error opening batinfo /sys/class/power_supply/BAT0/energy_now
Error opening batinfo /sys/class/power_supply/BAT0/energy_full
Title: Re: Battery monitor or icon?
Post by: Rich on January 29, 2019, 11:00:45 PM
Hi Juanito
Maybe I should remove that error message? It seemed like a good idea at the time but it really isn't an error unless the
fallback values (charge_now and charge_full) can't be read. It's late here but if you'd like I'll clean up the error handling
and submit an update tomorrow.
Title: Re: Battery monitor or icon?
Post by: Juanito on January 29, 2019, 11:05:28 PM
No rush  :)

That's fine by me, @curaga?

In the meantime, updated watcher posted to the CorePure64-10.x repo
Title: Re: Battery monitor or icon?
Post by: curaga on January 30, 2019, 01:17:58 AM
Yeah I'll take that patch.
Title: Re: Battery monitor or icon?
Post by: Rich on January 30, 2019, 06:46:30 AM
Hi Juanito & curaga
Premature error messages have been removed and an updated package has been sent to tcesubmit. A patch called
watcher2.patch (the old watcher.patch from Sept 1, 2017 was never deleted)  has been uploaded to:
http://patches.tinycorelinux.net/

This is what it looks like:
Code: [Select]
--- watcher.cxx.old 2019-01-30 08:55:54.945634735 +0000
+++ watcher.cxx 2019-01-30 08:57:32.015633230 +0000
@@ -7,6 +7,16 @@
 // wmbluemem :)
 // Thank You Mihai Drãghicioiu
 
+// Jan 30, 2019 v1.10.1 by Rich
+// Removed 2 error messages from batcheckup() because they were not errors yet.
+
+// Jan 29, 2019 v1.10 by Rich
+// Compiled in the energy patch that was added on Sep 1, 2017
+// Added parameter assignment to parser() to shut up compiler unused parameter warning.
+
+// Nov 22, 2014 v1.9
+// Rebuilt with FLTK 1.3
+
 // v1.8: update battery support for linux 3.0
 
 // Changes from Softwaregurl:
@@ -21,7 +31,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-static const char version[] = "1.9";
+static const char version[] = "1.10.1";
 
 static float timeout = 1.5, mem = 0, swap = 0, cpu = 0, used = 0, oldused = 0,
  cputotal = 0, oldcputotal = 0;
@@ -37,7 +47,6 @@
  sprintf(longpath, "/sys/class/power_supply/%s/energy_now", batname);
  if ((batinfo = fopen(longpath, "r")) == NULL)
  {
- fprintf(stderr, "Error opening batinfo %s\n", longpath);
  sprintf(longpath, "/sys/class/power_supply/%s/charge_now", batname);
  if ((batinfo = fopen(longpath, "r")) == NULL)
  {
@@ -51,7 +60,6 @@
  sprintf(longpath, "/sys/class/power_supply/%s/energy_full", batname);
  if ((batinfo = fopen(longpath, "r")) == NULL)
  {
- fprintf(stderr, "Error opening batinfo %s\n", longpath);
  sprintf(longpath, "/sys/class/power_supply/%s/charge_full", batname);
  if ((batinfo = fopen(longpath, "r")) == NULL)
  {
@@ -184,6 +192,7 @@
 }
 
 static int parser(int argc, char **argv, int &z) {
+ argc=argc; // Added to shut up compiler unused parameter warning.
  if (strcmp(argv[z], "-h") == 0) {
  printf("Watcher %s\n"
         "(C) Curaga\n"

@Juanito: Maybe add an options hint similar to this to the CorePure64 watcher.tcz.info file:
Code: [Select]
To start watcher on X start, add to .xsession:
[ $(which watcher) ] && watcher -g +0-0 &
-
For more options, run  watcher -h
Title: Re: Battery monitor or icon?
Post by: curaga on January 30, 2019, 09:46:48 AM
Applied except the argc assignment, I find that ugly. Thanks!

I see the patch cron job hadn't been updated with the server change to nginx and corresponding script update. Updated now.
Title: Re: Battery monitor or icon?
Post by: Rich on January 30, 2019, 10:07:11 AM
Hi curaga
Applied except the argc assignment, I find that ugly. Thanks! ...
I've been bitten in the past where I became complacent with the same handful of harmless warnings showing up during compilation
and not noticing an extra warning that caused a problem. As a result, I usually try to make the compiler happy and add comments
indicating such. As I'm sure you are aware, the compiler is smart enough to optimize out that assignment.
Title: Re: Battery monitor or icon?
Post by: Juanito on January 30, 2019, 10:22:25 PM
Premature error messages have been removed and an updated package has been sent to tcesubmit.

posted - thanks
Title: Re: Battery monitor or icon?
Post by: curaga on January 31, 2019, 12:25:49 AM
For hiding unused var warnings, it's better IMO to use __attribute__((unused)).
Title: Re: Battery monitor or icon?
Post by: Rich on January 31, 2019, 07:30:05 AM
Hi curaga
For hiding unused var warnings, it's better IMO to use __attribute__((unused)).
Now that I'm aware that option exists, I'm inclined to agree.
Title: Re: Battery monitor or icon?
Post by: h2sammo on February 01, 2019, 02:04:08 AM
sorry guys but watcher still shows no battery info for me (conky does)
Title: Re: Battery monitor or icon?
Post by: Juanito on February 01, 2019, 02:17:15 AM
Does this give an error message:
Code: [Select]
$ watcher -bat BAT0
Title: Re: Battery monitor or icon?
Post by: h2sammo on February 01, 2019, 05:27:50 PM
odd. than command does not give an error it actually starts watcher AND it displays the battery %. however, starting watcher with "watcher" command alone does not display battery.
Title: Re: Battery monitor or icon?
Post by: Rich on February 01, 2019, 05:46:54 PM
Hi h2sammo
That's correct. It's up to the user to tell  watcher  the name of the battery to be monitored. If you're running a desktop
computer there is no battery to monitor. Running:
Code: [Select]
watcher -hwill show you  watchers  help screen.
Title: Re: Battery monitor or icon?
Post by: TomyTurbos on February 07, 2019, 05:10:41 PM
REPORT:

TC10 on a Dell Mini10.

Flit runs, reports current time and Battery State, does not update either one.

Trying 'watcher' next.  Stay tuned.
Title: Re: Battery monitor or icon?
Post by: Juanito on February 08, 2019, 12:00:58 AM
flit works fine here - both battery percentage and time update.

If you start flit from a terminal window, do you get any error messages?
Title: Re: Battery monitor or icon?
Post by: TomyTurbos on February 08, 2019, 12:52:14 PM
flit works fine here - both battery percentage and time update.

If you start flit from a terminal window, do you get any error messages?

Nope. 

I also note that it's not recognizing that it is on Battery rather than on AC. (Tried it both ways.)