Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Dell laptop libsmbios #7

Closed
maniacx opened this issue Mar 7, 2023 · 17 comments
Closed

Support for Dell laptop libsmbios #7

maniacx opened this issue Mar 7, 2023 · 17 comments
Labels

Comments

@maniacx
Copy link
Owner

maniacx commented Mar 7, 2023

No description provided.

@maniacx maniacx changed the title Support for Dell laptop lib smbios Support for Dell laptop libsmbios Mar 7, 2023
@monethass
Copy link

Let me know if you need any additional information for Dell laptops

@maniacx
Copy link
Owner Author

maniacx commented Mar 7, 2023

Hey monethass .

Hey.
I need to know the exit codes and results after executing the following commands.
To get the exit code type echo $? after you have run the command.

for me when I run smbios-battery-ctl --get-charging-cfg the result is shown below and the exit code is 1.
My results are this becasue, I do not have dell laptop.

[123@fedora ~]$ sudo smbios-battery-ctl --get-charging-cfg
[sudo] password for 123: 
Traceback (most recent call last):
  File "/usr/sbin/smbios-battery-ctl", line 275, in <module>
    sys.exit( main() )
              ^^^^^^
  File "/usr/sbin/smbios-battery-ctl", line 241, in main
    print_primary_battery_cfg()
  File "/usr/sbin/smbios-battery-ctl", line 190, in print_primary_battery_cfg
    mode = get_charging_mode()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/sbin/smbios-battery-ctl", line 140, in get_charging_mode
    active = table[mode.value].isActive()
             ~~~~~^^^^^^^^^^^^
  File "/usr/lib64/python3.11/site-packages/libsmbios_c/trace_decorator.py", line 103, in trace
    result = func(*args, **kw)
             ^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/site-packages/libsmbios_c/smbios_token.py", line 145, in __getitem__
    raise IndexError(_("SMBIOS Token ID 0x%04x not found") % id )
IndexError: SMBIOS Token ID 0x0341 not found
[123@fedora ~]$ echo $?
1
[123@fedora ~]$ 

So If you can copy paste and post the results of the following command.

sudo --set-charging-mode='express'

echo $?

sudo smbios-battery-ctl --get-charging-cfg

echo $?

sudo --set-charging-mode='custom'

echo $?

sudo smbios-battery-ctl --set-custom-charge-interval=55 60

echo $?

sudo smbios-battery-ctl --get-charging-cfg

echo $?

Can you post the result of this. If there are any mistakes in commands that I have written, please correct them and let me know with the results.

I am read on that running all smbios-battery-ctl needs root permissions(sudo) Is that correct?

@monethass
Copy link

monethass commented Mar 7, 2023

sudo smbios-battery-ctl --set-charging-mode='express'

Charging mode has been set to: express

sudo smbios-battery-ctl --get-charging-cfg

Charging mode: express

sudo smbios-battery-ctl --set-charging-mode='custom'

Charging mode has been set to: custom

sudo smbios-battery-ctl --set-custom-charge-interval=55 60

Custom charge interval has been set to (55, 60)

sudo smbios-battery-ctl --get-charging-cfg

Charging mode: custom
Charging interval: (55, 60)

All of them exits 0.

I am read on that running all smbios-battery-ctl needs root permissions(sudo) Is that correct?

Yes, that is correct. If permission is denied, exit code will be 3.

smbios-battery-ctl --get-charging-cfg (without sudo):

ERROR: Could not parse system SMBIOS table.

Common problems are:

    -- 'SMM Mitigations' is enabled in BIOS setup.
        Run kernel 4.15 or later with 
        dell-smbios-wmi enabled.
         or 
        Disable 'SMM mitigations' in BIOS setup.

    -- Insufficient permissions to perform operation.
       Try running as a more privileged account.
          Linux  : run as 'root' user
          Windows: run as 'administrator' user

    -- dell-smbios-wmi driver not loaded 
       Try loading the dell-smbios-wmi driver 
          Linux : modprobe dell-smbios-wmi 

    -- Call filtered by Linux kernel 
       Some functionality is natively supported 
       by the Linux kernel 

    -- dcdbas device driver not loaded.
       Try loading the dcdbas driver
          Linux  : modprobe dcdbas

echo $?

3

@maniacx
Copy link
Owner Author

maniacx commented Mar 8, 2023

From all the below options
['primarily_ac', 'adaptive', 'custom', 'standard', 'express']
Just curious which options do you usually use??

Cant give all option in extension, it is too much hassle.

I think
standard is equivalent to custom with threshold 95/100 (stop threshold / start threshold)
primarily_ac is equivalent to custom with threshold 75/80
adaptive. well if you are using this mode you dont need this extension.

Since my extension is already provides these modes in "custom" configuration
Full Capacity Mode > custom 98/100 (Customizable)
Balance Mode > custom 78/80 (Customizable)
Maximum LifeSpan Mode > custom 58/60 (Customizable)
The only important mode that is needed, is express mode. Incase in emergency if you need to charge faster.
Any suggestions?

@monethass
Copy link

monethass commented Mar 8, 2023

I don't know about other users, but I don't feel like express is any quicker than standard for me, to be honest. I use custom with 50/85, because most of the places I use my laptop have a wall plug. Occasionally, I might change to standard when I know I'm going to be out for a longer period of time without an AC source.

adaptive I believe is that the laptop figures out, for example, you start your day at 8am to 4pm on weekdays, and 11am to 9pm on weekends, so if you plug in the laptop the night before, it won't charge it until maybe like 6am on weekdays and 9am on weekends, and it'll be fully charged when you're ready to go. That's what Dell claims, I believe, but I've never tested it.

primarily_ac still charges to 100% and stays there, so the same as standard and express, really. Maybe there is something different to how the laptop manages the battery level in the background, but to the user, the differences between these three are not obvious at all (if any).

custom is, well, custom.

Since the extension already has Full Capacity Mode, Balanced Mode, and Maximum Lifespan Mode, I would say:

  • Full Capacity Mode is equivalent with standard
  • Balanced Mode is equivalent to custom 78/80
  • Maximum Lifespan Mode is equivalent to custom 58/60

If you're up to adding other modes, the priority (in my opinion) to be added is:

  1. adaptive (since maybe some people use adaptive as the default, and once in a while they have a day that is off the regular schedule, they can switch to other modes, and switch back to adaptive when they go back to their regular schedule)
  2. express (I don't see any difference for my usage, but maybe for other laptop models with higher wattage chargers, the difference is more obvious, might need other users to chime in about this)
  3. primarily_ac (I honestly think that this is the same as standard, but I might be wrong)

@maniacx
Copy link
Owner Author

maniacx commented Mar 10, 2023

what happens if the difference between both threshold is less than 5.

sudo smbios-battery-ctl --set-custom-charge-interval=78 80

echo $?

What are the result and exit code for this?

Also what happens if the mode is not in custom and we set --set-custom-charge-interval. Does it automatically change mode to custom?

sudo smbios-battery-ctl --set-charging-mode='express'

sudo smbios-battery-ctl --set-custom-charge-interval=70 80

echo $?

sudo smbios-battery-ctl --get-charging-cfg

echo $?

I am almost done, but only for custom threshold.
The extension should apply changes to the threshold.
But problem I am facing is the process of reading from sudo smbios-battery-ctl --get-charging-cfg is too slow .

@monethass
Copy link

sudo smbios-battery-ctl --set-custom-charge-interval=78 80

Traceback (most recent call last):
  File "/usr/sbin/smbios-battery-ctl", line 275, in <module>
    sys.exit( main() )
              ^^^^^^
  File "/usr/sbin/smbios-battery-ctl", line 248, in main
    set_custom_charge_interval(low, high)
  File "/usr/sbin/smbios-battery-ctl", line 178, in set_custom_charge_interval
    raise ValueError("END must be at least (START + 5)")
ValueError: END must be at least (START + 5)

echo $?

1

sudo smbios-battery-ctl --set-charging-mode='standard'

Charging mode has been set to: standard

sudo smbios-battery-ctl --set-custom-charge-interval=70 80

Custom charge interval has been set to (70, 80)

echo $?

0

sudo smbios-battery-ctl --get-charging-cfg

Charging mode: standard

echo $?

0

sudo smbios-battery-ctl --set-charging-mode='custom'

Charging mode has been set to: custom

sudo smbios-battery-ctl --get-charging-cfg

Charging mode: custom
Charging interval: (70, 80)

Also what happens if the mode is not in custom and we set --set-custom-charge-interval. Does it automatically change mode to custom?

It changes the threshold for custom mode, but doesn't change the mode to custom. So the next time you change the mode to custom, it'll use the threshold.

But problem I am facing is the process of reading from sudo smbios-battery-ctl --get-charging-cfg is too slow

I've tried to check if there's any file in /sys you can read directly into, but unfortunately I couldn't find any. If you could find a way to parse /sys/firmware/dmi/tables/DMI, maybe you could read from there.

@maniacx
Copy link
Owner Author

maniacx commented Mar 11, 2023

Hey. Can you help me to test this version of the extension?
Current on custom threshold are supported.

Extract the zip ad open the folder. Open terminal in that folder and install using ./install.sh
Restart gnome shell (Logout and relogin if on Wayland) or (just Alt-F2 and type r if on x11)

The extension will notify to install polkit. Install it and Restart gnome shell again.
Check if the extension works.

It would be helpful if you can send me logs for debugging just to verify.

Open two windows of terminal.
In one run
journalctl -f -o cat /usr/bin/gjs
And in other run
journalctl -f -o cat /usr/bin/gnome-shell

Disable and renable the extension.
Send me logs that start with Battery Health Charging
Remove any username or anyother information for privacy concerns.
Battery-Health-Charging-Dell-trial-01.zip

@monethass
Copy link

monethass commented Mar 12, 2023

journalctl -f -o cat /usr/bin/gjs

JS LOG: Battery Health Extension: Found smbios-battery-ctl at /usr/sbin/smbios-battery-ctl
JS LOG: Battery Health Extension: argv = pkexec,/home/username/.local/share/gnome-shell/extensions/[email protected]/tool/installer.sh,--tool-user,username,install
JS LOG: Battery Health Charging: Installing batteryhealthchargingctl-username tool... Success
Installing policykit rule...Success

JS LOG: Characters Application started
JS LOG: Characters Application exiting

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

`Battery Health Extension: @runCmdPkexecFeedback
Battery Health Extension: argv = pkexec,/usr/local/bin/batteryhealthchargingctl-username,DELL_SMBIOS_BAT_WRITE,100,95
GNOME Shell started at Sun Mar 12 2023 09:03:55 GMT+0100 (Central European Standard Time)
Registering session with GDM
Battery Health Charging: Custom charge interval has been set to (95, 100)
Battery Health Charging: echo 1 = DELL_SMBIOS_BAT_WRITE
Battery Health Charging: echo 2 = 100
Battery Health Charging: echo 3 = 95

`Battery Health Extension: @runCmdPkexecFeedback
Battery Health Extension: argv = pkexec,/usr/local/bin/batteryhealthchargingctl-username,DELL_SMBIOS_BAT_READ
Battery Health Charging: Charging mode: custom
Charging interval: (95, 100)
Battery Health Charging: echo 1 = DELL_SMBIOS_BAT_READ
Battery Health Charging: echo 2 = 
Battery Health Charging: echo 3 = 

Battery Health Extension: Start Value = 95
Battery Health Extension: End Value = 100
meta_window_set_stack_position_no_sync: assertion 'window->stack_position >= 0' failed
Battery Health Extension: Found smbios-battery-ctl at /usr/sbin/smbios-battery-ctl
Battery Health Extension: argv = pkexec,/usr/local/bin/batteryhealthchargingctl-username,CHECKINSTALLATION,/home/username/.local/share/gnome-shell/extensions/[email protected]/resources,username
Battery Health Extension: First run.. Applying Dell custom mode
`Battery Health Extension: @runCmdPkexecFeedback
Battery Health Extension: argv = pkexec,/usr/local/bin/batteryhealthchargingctl-username,DELL_SMBIOS_BAT_CUSTOM_MODE
Battery Health Charging: Charging mode has been set to: custom
Battery Health Charging: echo 1 = DELL_SMBIOS_BAT_CUSTOM_MODE
Battery Health Charging: echo 2 = 
Battery Health Charging: echo 3 = 

`Battery Health Extension: @runCmdPkexecFeedback
Battery Health Extension: argv = pkexec,/usr/local/bin/batteryhealthchargingctl-username,DELL_SMBIOS_BAT_WRITE,100,95
Battery Health Charging: Custom charge interval has been set to (95, 100)
Battery Health Charging: echo 1 = DELL_SMBIOS_BAT_WRITE
Battery Health Charging: echo 2 = 100
Battery Health Charging: echo 3 = 95

`Battery Health Extension: @runCmdPkexecFeedback
Battery Health Extension: argv = pkexec,/usr/local/bin/batteryhealthchargingctl-username,DELL_SMBIOS_BAT_READ
Battery Health Charging: Charging mode: custom
Charging interval: (95, 100)
Battery Health Charging: echo 1 = DELL_SMBIOS_BAT_READ
Battery Health Charging: echo 2 = 
Battery Health Charging: echo 3 = 

Battery Health Extension: Start Value = 95
Battery Health Extension: End Value = 100

It works!

But one thing I notice is that it only changes the mode from anything else to custom on login, and after login, it only changes the threshold and not the mode.

This will cause problem when, for example, if I change the mode manually via command line to, for example, standard, then after that if I change the mode via the extension, it won't change the mode back to custom, although the threshold will be changed (but not applied because the mode is still set to standard). Below is the log for when I did that:

`Battery Health Extension: @runCmdPkexecFeedback
Battery Health Extension: argv = pkexec,/usr/local/bin/batteryhealthchargingctl-username,DELL_SMBIOS_BAT_WRITE,100,95
Battery Health Charging: Custom charge interval has been set to (95, 100)
Battery Health Charging: echo 1 = DELL_SMBIOS_BAT_WRITE
Battery Health Charging: echo 2 = 100
Battery Health Charging: echo 3 = 95

`Battery Health Extension: @runCmdPkexecFeedback
Battery Health Extension: argv = pkexec,/usr/local/bin/batteryhealthchargingctl-username,DELL_SMBIOS_BAT_READ
Battery Health Charging: Charging mode: standard
Battery Health Charging: echo 1 = DELL_SMBIOS_BAT_READ
Battery Health Charging: echo 2 = 
Battery Health Charging: echo 3 = 

@maniacx
Copy link
Owner Author

maniacx commented Mar 12, 2023

Yes it applied custom mode only during the start of the extension. This is to avoid applying two commands every time we change the threshold. Reviewers of gnome extension don't prefer using too many command lines. So I am trying to minimize usage of two many command lines.

@maniacx
Copy link
Owner Author

maniacx commented Mar 16, 2023

Hello @monethass
I have added two addition mode. Adapative and Express.
Also now --set-charging-mode='custom' applies everything the custom threshold are changed.

Please test all modes and apply customize option in settings.
By test I meant just apply the mode/threshold using the extension, and check if it applied to smbios-battery-ctl in terminal using --get-charging-cfg

Let me know if there are any issue.
Thanks.

Battery-Health-Charging-Dell-trial-02.zip

@monethass
Copy link

monethass commented Mar 16, 2023

I'm not able to run this version. After installation and shell restart, the extension is not loaded. Logs:

ReferenceError: assignment to undeclared variable TP_BAT0_END

Stack trace:

@/home/username/.local/share/gnome-shell/extensions/[email protected]/devices/ThinkpadLegacy.js:9:1
@/home/username/.local/share/gnome-shell/extensions/[email protected]/lib/driver.js:10:5
@/home/username/.local/share/gnome-shell/extensions/[email protected]/prefs.js:5:16
_init@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:23:33
ExtensionPrefsDialog@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:10:4
OpenExtensionPrefsAsync@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:124:33
async*LaunchExtensionPrefsAsync@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:110:14
_handleMethodCall@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:368:35
_wrapJSObject/<@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:401:34
run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:186:20
main@resource:///org/gnome/Shell/Extensions/js/main.js:22:13
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
start@resource:///org/gnome/gjs/modules/script/package.js:190:8
@/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17

@maniacx
Copy link
Owner Author

maniacx commented Mar 16, 2023

Sorry about that.
try version 3 plz
Battery-Health-Charging-Dell-trial-03.zip

@monethass
Copy link

Just had it installed and it works. Tried both adaptive and express

@maniacx
Copy link
Owner Author

maniacx commented Mar 17, 2023

Thank you for testing

@maniacx maniacx closed this as completed Mar 18, 2023
@maniacx
Copy link
Owner Author

maniacx commented Mar 18, 2023

Just uploaded the version which supports dell on gnome extension website. Thank you for the information provided and testing the extension

@maniacx
Copy link
Owner Author

maniacx commented Mar 26, 2023

Hello monethass. Looking for some testing of new version if interest please contribute

Link here #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants