bat: issue: Battery percentage setting doesn't persist; systemctl does not indicate that bat@.service is running.
Subject of the issue
Hi, I’ve downloaded and used the bat file from the Release page, version 0.13, following your instruction to the letter but the setting doesn’t persist after restarting.
After running the bat, this is the services I see in systemctl:
When I run the following command in the Terminal after restarting:
systemctl --state=active --type=service
I do not see bat@.service running.
However, when I check for all services:
systemctl --type=service
I see that there’s the service bat@multi-user.service, but not activated
The service file is identical to that in your source code.
Your system
OS: Ubuntu 22.04.3 LTS x86_64 Host: ZenBook UX425EA_UX425EA 1.0 Kernel: 6.2.0-32-generic Shell: bash 5.1.16 Resolution: 1920x1080 DE: Unity 7.6.0 WM: Compiz Terminal: gnome-terminal
Version
0.13 (Latest)
Steps to reproduce
Download and run the bat file as per instructions, then restart/shutdown the laptop.
Expected behaviour
After restart/turn on, the service should automatically be activated by the systemd and the systemctl.
Running bat threshold should return the pre-determined value.
Actual behaviour
The service isn’t run, not after restarting. Running bat threshold returns the default value (100).
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 44 (11 by maintainers)
Commits related to this issue
- fix: restore persistence functionality This commit addresses an issue where the switch to using systemd templates and format specifiers introduced a regression, causing the persistence functionality ... — committed to tshakalekholoane/bat by tshakalekholoane 9 months ago
- fix: restore persistence functionality This commit addresses an issue where the switch to using systemd templates and format specifiers introduced a regression, causing the persistence functionality ... — committed to tshakalekholoane/bat by tshakalekholoane 9 months ago
- fix: restore persistence functionality This commit addresses an issue where the switch to using systemd templates and format specifiers introduced a regression, causing the persistence functionality ... — committed to tshakalekholoane/bat by tshakalekholoane 9 months ago
Ah. I see. Then it might better to do in the unit file template since the setup logic already resolves the actual value.
after I commanded
sudo bat persist, the contents of thebat@.servicereverted back to the previous version. When I try to enable the service with systemctl, this is what it said:That line doesn’t work because
shdoesn’t expand the question mark inecho 60 >/sys/class/power_supply/BAT?/charge_control_end_threshold. You have to do:b=$(echo /sys/class/power_supply/BAT?/charge_control_end_threshold); echo 80 >"$b"(or you have to substitute the actual value into the unit files, soBAT0orBAT1or whatever).Of course NixOS allows you to do basic operations like this. Their focus is on package & configuration management. They use systemd, they have bash.
This works perfectly. Thank you so much 💯
Yes, but being immutable and all, does it allow changing the threshold manually or otherwise?
replacing
%swith/bin/bashdoes though.I’m not sure that’s the case on NixOS but that could be a good default.
@cloudmadeofcandy are you sure you’re running the correct version?
bat@multi-usershouldn’t be there anymore. There should be 5 different services for each event after the change.I haven’t merged the changes yet. They’re in this PR if you want to checkout the code.
Yes I left the
%sin there so that the application doesn’t have to contain logic to find the shell. systemd can take care of that. Does it not work for you?@tshakalekholoane It is also good to include
RemainAfterExit=truein the unit files under[Service], because then the service shows as Active when doingsystemctl status.That confirms there is something wrong that @tshakalekholoane needs to fix.
@pepa65 you are correct.
After I turned the laptop on, the battery indicator turned red again, but when the ubuntu shell appeared, the battery indicator turned white again. This is a most peculiar turn of event.
The
bat@.serviceis stillindirect enabled, tho. What is happening and how do I fix it? The glob should work, right?Should I close the issue when it is not fully solved?
Alright, I’ll try that.
Mine’s
indirect enabledIt is identical to the source file.
There really is no difference.
Looking at the %i and the description in the picture, %i seems to be equal to “multi-user”
I also notice that the battery limiter also works after shutting down, however when I turn it on, the threshold immediately resets to 100