maniacx / Battery-Health-Charging

GNU General Public License v3.0
157 stars 14 forks source link

Threshold not updated/delayed toggle #55

Closed e34rrsff closed 9 months ago

e34rrsff commented 10 months ago

I have a Lenovo Yoga/Ideapad & there's this error that I don't know what to do with. Any help please?

Screenshot from 2023-08-04 18-41-38

maniacx commented 10 months ago

Which distro are you using?

Also can you check if you can set and read charging threshold manually using terminal. Try these command

echo 1 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode echo 0 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode

Send me the output of this.

e34rrsff commented 10 months ago

It's the same directories my computer has & I've made a script to change it for myself so I know it does work on mine

user@pc:~$ distro
Name: Ubuntu 23.04
Version: 23.04 (lunar)
Codename: lunar
user@pc:~$ ls /sys/bus/platform/drivers/ideapad_acpi/VPC2004\:00/conservation_mode
/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode

Now that I'm checking it again, the extension is working & it's changing the contents of the file to 1/0, but it's still is showing me the error notification. Maybe it detected the wrong device?

user@pc:~$ cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004\:00/conservation_mode 
1

Then after toggling it again:

user@pc:~$ cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004\:00/conservation_mode 
0
maniacx commented 10 months ago

When do you get the error?

  1. Is it when you change conservation_mode from extension?
  2. Or does it show during logging in from lockkscreen, sleep, or power off??
e34rrsff commented 10 months ago

Only when I'm toggling conservation mode with the extension

maniacx commented 10 months ago

I have added debugging message to this trial version to know whats going on. Install it. debug.zip

if installation fails with msgfmt error install gettext. (sudo apt install gettext)

After installing thre trial extension logout and relogin

Open new terminal and paste this command

journalctl -f -o cat /usr/bin/gnome-shell

You will see a live logging. Toggle 4 time conservation mode using extension and there will be some output on the terminal. Paste it here

e34rrsff commented 10 months ago
user@pc:~$ journalctl -f -o cat /usr/bin/gnome-shell
GNOME Shell terminated with an error: Xwayland exited unexpectedly
DING: Detected async api for thumbnails
DING: DBus interface for Switcheroo control (net.hadess.SwitcherooControl) is now available.
DING: DBus interface for Nautilus (org.gnome.Nautilus.FileOperations2) is now available.
DING: DBus interface for Nautilus (org.freedesktop.FileManager1) is now available.
DING: DBus interface for Gvfs daemon (org.gtk.vfs.Metadata) is now available.
DING: ** Message: 16:08:34.590: Connecting to org.freedesktop.Tracker3.Miner.Files
DING: GNOME nautilus 44.2.1
Received notification for window. 0 notifications remaining.
DING: DBus interface for File-roller (org.gnome.ArchiveManager1) is now available.
argv = pkexec,/usr/local/bin/batteryhealthchargingctl-user,LENOVO,1
stdout = 
stderr = 
Battery Health Charging: xxxxxxxxxxxx status = 0
Battery Health Charging: xxxxxxxxxxxx readMode = 0
Battery Health Charging: xxxxxxxxxxxx condition not met
argv = pkexec,/usr/local/bin/batteryhealthchargingctl-user,LENOVO,0
stdout = 
stderr = 
Battery Health Charging: xxxxxxxxxxxx status = 0
Battery Health Charging: xxxxxxxxxxxx readMode = 1
Battery Health Charging: xxxxxxxxxxxx condition not met
argv = pkexec,/usr/local/bin/batteryhealthchargingctl-user,LENOVO,1
stdout = 
stderr = 
Battery Health Charging: xxxxxxxxxxxx status = 0
Battery Health Charging: xxxxxxxxxxxx readMode = 0
Battery Health Charging: xxxxxxxxxxxx condition not met
argv = pkexec,/usr/local/bin/batteryhealthchargingctl-user,LENOVO,0
stdout = 
stderr = 
Battery Health Charging: xxxxxxxxxxxx status = 0
Battery Health Charging: xxxxxxxxxxxx readMode = 1
Battery Health Charging: xxxxxxxxxxxx condition not met
maniacx commented 10 months ago

I failed to add a debug line. Silly me .so those logs are becoming meaningless..

Anyways, the extension as soon as it write threshold on /sys/...../conservation_mode, it will read and verify if its written value has accepted. Probably it seems like you laptop takes time to update the value after they have been writter.

So kindly help me with another test and give me the output of these 2 command in terminal. Send me the output of this.

echo 1 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode && cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode && cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode

echo 0 | sudo tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode && cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode && cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode

Also I have created another debug extension adding the missing lines. Also added a fix, If verifying fails, the extension will verify again after 200ms. Kindly install and test and monitor/send me the logs using journalctl -f -o cat /usr/bin/gnome-shell debug-2.zip

e34rrsff commented 10 months ago
user@pc:~$ journalctl -f -o cat /usr/bin/gnome-shell 
stderr = 
Battery Health Charging: xxxxxxxxxxxx status = 0
Battery Health Charging: xxxxxxxxxxxx readMode = 0
Battery Health Charging: xxxxxxxxxxxx condition not met
argv = pkexec,/usr/local/bin/batteryhealthchargingctl-user,LENOVO,0
stdout = 
stderr = 
Battery Health Charging: xxxxxxxxxxxx status = 0
Battery Health Charging: xxxxxxxxxxxx readMode = 1
Battery Health Charging: xxxxxxxxxxxx condition not met
user@pc:~$ file=/sys/bus/platform/drivers/ideapad_acpi/VPC2004\:00/conservation_mode 
user@pc:~$ cat $file
0
user@pc:~$ echo 1 | sudo tee $file && cat $file
1
0
user@pc:~$ cat $file
1

That seems odd to me, I think it might take longer than 200ms because it still gives me the notification. Do you know if it taking that long is normal?

e34rrsff commented 10 months ago

Oh, I copied just the files directly from the zip, not the ones in the debug folder. Copying the ones in the debug folder made it go away now, thanks.

user@pc:~$ journalctl -f -o cat /usr/bin/gnome-shell 
Battery Health Charging: xxxxxxxxxxxx readMode after timer = 1
Battery Health Charging: xxxxxxxxxxxx this._conservationMode changed after timer 
Battery Health Charging: xxxxxxxxxxxx this._conservationMode = 0
argv = pkexec,/usr/local/bin/batteryhealthchargingctl-e34,LENOVO,0
stdout = 
stderr = 
Battery Health Charging: xxxxxxxxxxxx status = 0
Battery Health Charging: xxxxxxxxxxxx readMode before timer = 1
Battery Health Charging: xxxxxxxxxxxx readMode after timer = 0
Battery Health Charging: xxxxxxxxxxxx this._conservationMode changed after timer
maniacx commented 10 months ago

@E34rrsff Hi Can you Please test this new version for me. test.zip

I have added 200ms reverification, but it is a litttle different than debug2.zip that I have sent previosly. If everything works well, I will upload for review and publish on Gnome-extension website

Thanks

e34rrsff commented 9 months ago

I fully restarted my computer to make sure nothing is cached or whatever, but I'm getting the "Charging threshold not updated" error again like before. Also I checked if there were any logs with journalctl just in case, but yeah there's nothing showing up. It is still toggling the conservation_mode file's contents with 1 & 0, though.

maniacx commented 9 months ago

I made a mistake with test.zip Try this one test2.zip Hopefully no more mistake.

e34rrsff commented 9 months ago

Yeah it seems to work now, although I don't know if the gschemas.compiled file is intentionally meant to be excluded in that zip 'cause I got an error that it was missing before

maniacx commented 9 months ago

Thanks for testing. I will take check on the schema

e34rrsff commented 9 months ago

Thanks for helping, the update is working perfectly