Package: battery-stats Version: 0.5.2-1 Severity: normal Tags: patch I was plyaing around with battery-stats and noticed this odd message from systemd.
rrs@learner:~$ sudo /etc/init.d/battery-stats status [sudo] password for rrs: ● battery-stats.service - LSB: start/stop the battery statistics collector Loaded: loaded (/etc/init.d/battery-stats; bad; vendor preset: enabled) Active: active (exited) since Fri 2016-04-22 16:23:41 IST; 1min 5s ago Docs: man:systemd-sysv-generator(8) Process: 7235 ExecStop=/etc/init.d/battery-stats stop (code=exited, status=0/SUCCESS) Process: 7243 ExecStart=/etc/init.d/battery-stats start (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 512) Apr 22 16:23:41 learner systemd[1]: Starting LSB: start/stop the battery statistics collector.. Apr 22 16:23:41 learner battery-stats[7243]: Starting Battery statistics collector: battery-sta Apr 22 16:23:41 learner systemd[1]: Started LSB: start/stop the battery statistics collector. I also noticed that there was no daemon process running. rrs@learner:~$ cat /var/run/battery-stats-collector.pid 7250 2016-04-22 / 16:27:21 ♒♒♒ ☺ rrs@learner:~$ ps aux | grep 7250 rrs 7841 0.0 0.0 12752 2344 pts/1 S+ 16:27 0:00 grep --color=auto 7250 2016-04-22 / 16:27:27 ♒♒♒ ☺ And manually trying to run it resulted in the following: rrs@learner:~$ sudo battery-stats-collector [sudo] password for rrs: cat: /sys/class/power_supply/AC/online: No such file or directory 2016-04-22 / 16:28:17 ♒♒♒ ☹ => 1 Ah!! I remember something. That's standard path what you lookup for. I did the same with Laptop Mode Tools until I realized that my newer Lenovo Yoga 2 had a different naming for the power supply. rrs@learner:~$ tree /sys/class/power_supply/ACAD/ /sys/class/power_supply/ACAD/ ├── device -> ../../../ACPI0003:00 ├── online ├── power │ ├── async │ ├── autosuspend_delay_ms │ ├── control │ ├── runtime_active_kids │ ├── runtime_active_time │ ├── runtime_enabled │ ├── runtime_status │ ├── runtime_suspended_time │ ├── runtime_usage │ ├── wakeup │ ├── wakeup_abort_count │ ├── wakeup_active │ ├── wakeup_active_count │ ├── wakeup_count │ ├── wakeup_expire_count │ ├── wakeup_last_time_ms │ ├── wakeup_max_time_ms │ └── wakeup_total_time_ms ├── subsystem -> ../../../../../../../../class/power_supply ├── type └── uevent 3 directories, 21 files 2016-04-22 / 16:30:42 ♒♒♒ ☺ I've attached a patch. I think your assumptions that the paths is sysfs are valid and persistent could be wrong. -- System Information: Debian Release: stretch/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 'unstable'), (101, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.5.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_IN.utf8, LC_CTYPE=en_IN.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages battery-stats depends on: ii gzip 1.6-5 ii logrotate 3.8.7-2 Versions of packages battery-stats recommends: ii gnuplot 4.6.6-3 ii libtext-csv-perl 1.33-1 ii python 2.7.11-1 ii python-matplotlib 1.5.1-1+b2 battery-stats suggests no packages. -- no debconf information
--- a/src/battery-stats-collector +++ b/src/battery-stats-collector @@ -22,7 +22,14 @@ secstamp=$(date +%s) stamp=$(date +"%Y/%m/%d %H:%M:%S") - aconline=$(cat /sys/class/power_supply/AC/online) + if [ -f /sys/class/power_supply/AC/online ]; then + aconline=$(cat /sys/class/power_supply/AC/online) + elif [ -f /sys/class/power_supply/ACAD/online ]; then + aconline=$(cat /sys/class/power_supply/ACAD/online) + else + echo "No power supply found" + fi + if [ 1 = "$aconline" ]; then state=2 else