alexVinarskis / dell-powermanager

Cross-Platform Dell Power Manager re-implementation
GNU General Public License v3.0
48 stars 1 forks source link

[BUG] Unable to switch modes when BIOS SetupPwd/SysPwd/OwnerPwd is set #31

Closed poltpolt closed 7 months ago

poltpolt commented 8 months ago

I installed the binary amd64 release in ~/bin/dell-powermanager I get the errors below, I suspect i miss powerprofiles-deamon.

My default powermanagement package is TLP - which conflicts with powerprofiles-deamon. am I right?

Maybe an option to use tlp?

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ShellException(powerprofilesctl get, error: ProcessException: Nie ma takiego pliku ani katalogu Command: powerprofilesctl get, workingDirectory: /home/polrus/bin/dell-powermanager)

$ powerprofilesctl get $ bash -c "export PATH=/opt/dell/dcc:$PATH && sudo -n $(which cctk) --ThermalManagement --PrimaryBattChargeCfg" ProcessException: Nie ma takiego pliku ani katalogu Command: powerprofilesctl get $ powerprofilesctl get workingDirectory: /home/polrus/bin/dell-powermanager

Check that powerprofilesctl exists command: powerprofilesctl get

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ShellException(powerprofilesctl get, error: ProcessException: Nie ma takiego pliku ani katalogu Command: powerprofilesctl get, workingDirectory: /home/polrus/bin/dell-powermanager)

$ cat /sys/class/power_supply/AC/uevent /sys/class/power_supply/BAT0/uevent POWER_SUPPLY_NAME=AC POWER_SUPPLY_TYPE=Mains POWER_SUPPLY_ONLINE=1 POWER_SUPPLY_NAME=BAT0 POWER_SUPPLY_TYPE=Battery POWER_SUPPLY_STATUS=Full POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_TECHNOLOGY=Li-poly POWER_SUPPLY_CYCLE_COUNT=0 POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11400000 POWER_SUPPLY_VOLTAGE_NOW=12969000 POWER_SUPPLY_CURRENT_NOW=1000 POWER_SUPPLY_CHARGE_FULL_DESIGN=8339000 POWER_SUPPLY_CHARGE_FULL=8339000 POWER_SUPPLY_CHARGE_NOW=8339000 POWER_SUPPLY_CAPACITY=100 POWER_SUPPLY_CAPACITY_LEVEL=Full POWER_SUPPLY_MODEL_NAME=DELL F8CPG26 POWER_SUPPLY_MANUFACTURER=BYD POWER_SUPPLY_SERIAL_NUMBER=71 ThermalManagement=Optimized PrimaryBattChargeCfg=Custom:50-55 $ powerprofilesctl get ProcessException: Nie ma takiego pliku ani katalogu Command: powerprofilesctl get $ powerprofilesctl get

alexVinarskis commented 8 months ago

Good find, thanks. powermanagement is actually only used to display OS's power setting. On this pic, top right corner, yellow box:

image

Does power profile switching itself do anything? Does battery mode switching changes modes?

poltpolt commented 8 months ago

it's due to my password in bios i guess, this aditional option to set it up in the program would be nice

$ powerprofilesctl get power-saver ThermalManagement=Optimized PrimaryBattChargeCfg=Custom:50-55 $ bash -c "export PATH=/opt/dell/dcc:$PATH && sudo -n $(which cctk) --ThermalManagement=UltraPerformance" $ powerprofilesctl get power-saver

Setup Password is required to change the setting. Use --ValSetupPwd to provide password. $ powerprofilesctl get power-saver $ bash -c "export PATH=/opt/dell/dcc:$PATH && sudo -n $(which cctk) --ThermalManagement --PrimaryBattChargeCfg" $ cat /sys/class/power_supply/AC/uevent /sys/class/power_supply/BAT0/uevent POWER_SUPPLY_NAME=AC POWER_SUPPLY_TYPE=Mains POWER_SUPPLY_ONLINE=1 POWER_SUPPLY_NAME=BAT0 POWER_SUPPLY_TYPE=Battery POWER_SUPPLY_STATUS=Full POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_TECHNOLOGY=Li-poly POWER_SUPPLY_CYCLE_COUNT=0 POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11400000 POWER_SUPPLY_VOLTAGE_NOW=12968000 POWER_SUPPLY_CURRENT_NOW=1000 POWER_SUPPLY_CHARGE_FULL_DESIGN=8339000 POWER_SUPPLY_CHARGE_FULL=8339000 POWER_SUPPLY_CHARGE_NOW=8339000 POWER_SUPPLY_CAPACITY=100 POWER_SUPPLY_CAPACITY_LEVEL=Full POWER_SUPPLY_MODEL_NAME=DELL F8CPG26 POWER_SUPPLY_MANUFACTURER=BYD POWER_SUPPLY_SERIAL_NUMBER=71 $ powerprofilesctl get

alexVinarskis commented 8 months ago

hehe thats an interesting one, didn't even know it exists :P Definitely in this case need to option to provide password, and somehow store it in encrypted form within app's tmp data.

Will look into it in the next weeks (a bit busy these days) and update this thread.

Could you drop full info on your machine and OS? In an unlikely case that I am unable to reproduce these on my side.

poltpolt commented 8 months ago

Dell XPS 9700 , opensuse Tumbleweed

in opensuse you can switch from TLP to powerprofile-manager but TLP is far superior

short openai summary:

"PowerProfiles-daemon" and "TLP" (or TLPUI) are both power management tools for Linux that help optimize the power consumption of your laptop or portable device. They offer various settings and profiles to extend battery life, reduce heat generation, and improve overall power efficiency. The choice between "PowerProfiles-daemon" and "TLP" depends on your specific needs and preferences:

  1. PowerProfiles-daemon:
    • Ease of Use: PowerProfiles-daemon is designed to be user-friendly and offers a simple interface for managing power profiles. It may be a good choice if you prefer a straightforward and easy-to-use tool.
    • Profiles: It provides several predefined power profiles, making it easy to switch between different power-saving modes with a click.
    • Customization: While it offers predefined profiles, it may have limited customization options compared to TLP. If you want fine-grained control over power settings, you might find TLP more suitable.
    • Desktop Environment Integration: PowerProfiles-daemon is known for its integration with the GNOME desktop environment.
      1. TLP (and TLPUI):
        • Customization: TLP is highly customizable and allows you to configure a wide range of power-related settings. This can be useful if you have specific requirements or want to tailor power management to your needs.
        • Advanced Users: TLP is often preferred by advanced Linux users who want more control over power settings and don't mind working with configuration files.
        • Compatibility: TLP is well-maintained and widely used, making it compatible with a variety of Linux distributions and desktop environments.
        • Battery Health: TLP has features that can help improve battery health by optimizing charge thresholds. In summary, if you're looking for a simple, easy-to-use power management tool with predefined profiles, and you're using the GNOME desktop environment, PowerProfiles- daemon might be a good choice. On the other hand, if you want advanced customization and compatibility with various Linux setups, TLP (possibly with a graphical interface like TLPUI) could be more suitable. Your choice ultimately depends on your preferences and requirements. It's worth noting that you can even install both tools and test them to see which one works best for your particular laptop and usage patterns. [1]

On wtorek, 6 lutego 2024 12:32:45 CET Alex wrote:

hehe thats an interesting one, didn't even know it exists :P

Definitely in this case need to option to provide password, and somehow store it in encrypted form within app's tmp data.

Will look into it in the next weeks (a bit busy these days) and update this thread.

Could you drop full info on your machine and OS? In an unlikely case that I am unable to reproduce these on my side.

— Reply to this email directly, view it on GitHub[2], or unsubscribe[3]. You are receiving this because you authored the thread.[4]Message ID: <alexVinarskis/dell- @.***>


[1] https://s.gravatar.com/avatar/e1b918535cca30f96eb9259bcedeb1db? s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fdp.png [2] https://github.com/alexVinarskis/dell-powermanager/issues/ 31#issuecomment-1929329314 [3] https://github.com/notifications/unsubscribe-auth/ ACHY7FM7MXFN66RDZALQIDDYSIIF3AVCNFSM6AAAAABC3Y5NVKVHI2DSMVQWIX3LMV 43OSLTON2WKQ3PNVWWK3TUHMYTSMRZGMZDSMZRGQ [4] https://github.com/notifications/beacon/ ACHY7FN3NDDWDAMUJL346GLYSIIF3A5CNFSM6AAAAABC3Y5NVKWGG33NNVSW45C7O R4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTS745KE.gif

xAlvzx commented 7 months ago

I also have that error, and I confirm it is because of the BIOS password. I use Arch Linux with the auto-cpufreq power manager.

~sudo cctk --ThermalManagement=Cool Setup Password is required to change the setting. Use --ValSetupPwd to provide password.

~sudo cctk --ThermalManagement=Cool --ValSetupPwd=passwd ThermalManagement=Cool

Laptop: XPS 9520

alexVinarskis commented 7 months ago

Thanks for the input. Will try to get first version up over the weekends!

alexVinarskis commented 7 months ago

@poltpolt powerprofilectl error message resolved in https://github.com/alexVinarskis/dell-powermanager/pull/32.

FYI to get logs you would now need to export POWERMANAGER_DEBUG=true before running the app. This is to prevent insane log spamming during normal operation.

poltpolt commented 7 months ago

Hi Alex I think Logs were not the problem, logs were precise enough but I have tested the new master and still get so I guess it is still work in progress $ bash -c "export PATH=/opt/dell/dcc:$PATH && sudo -n $(which cctk) --ThermalManagement=UltraPerformance" Setup Password is required to change the setting. Use --ValSetupPwd to provide password.

I'm wiling to test and report but I don't know flutter at all so I cannot assist you in programming.

alexVinarskis commented 7 months ago

Correct, logs were removed just for cleaniness, and error wrt to power state fetching was fixed.

Bios password fetching implementation takes much longer than I though. Working branch here. Im actually working on this right now :) Will update here once its ready for testing, currently it still not there.

poltpolt commented 7 months ago

I tried

`static Future _runCctk(String arg) async { String biosPassword = await _readBiosPasswordFromFile();

if (Platform.isLinux) {
  return (await _shell.run('''bash -c "export PATH="${Constants.apiPathLinux}:\$PATH" && sudo -n \$(which cctk) --ValSetupPwd=$biosPassword $arg"'''))[0];
} else {
  return (await _shell.run('''cmd /c cmd /c "${Constants.apiPathWindows}" $arg'''))[0];
}

}

static Future _readBiosPasswordFromFile() async { final file = File('${Platform.environment['HOME']}/.config/dell-powermanager/settings.ini'); // Use expanded path with environment variable if (!await file.exists()) { throw Exception('Dell power manager configuration file not found.'); }

final contents = await file.readAsString();
final passwordLine = contents.split('\n').firstWhere((line) => line.startsWith('bios_password='));
if (passwordLine == null) {
  throw Exception('BIOS password not found in configuration file.');
}

return passwordLine.split('=')[1].trim();

} ` and manually pasted my bios_password=mypassword but cctk reported an error

Report operations and set operations must be separate.

Usage error.

Dell Command Configure Version 4.11.0 3 (Linux - Aug 8 2023, 13:46:48) Copyright 2009 - 2023 Dell Inc. All rights reserved.

so I think that the password should only be passed to setting operations.

If you want to chat for live testing I'm on discord as poltpolt

alexVinarskis commented 7 months ago

Correct, bios password should only be added when setting config. There are also 3 different types of passwords that are supported, owner one is handled a little bit differently. Final difficulty is having adding password to shell securely, such that it is not logged either, as in your example its simply exposed, thats bad.

I tested it as concept on my side, and it worked. Im finishing UI handling part now, as it becomes really convoluted to handle all edge cases. Hopefully will have testsable version in a few hours pushed.

Its better to have bug related conversations here in public forum. Wrt to just debug process, it indeed may be easier on discord - we have a small Dell server here. Initially made to fix speakers sound on XPS 9530, but it grew quite a bit since then :)

alexVinarskis commented 7 months ago

PR linked now supports Windows & Linux, both entering password every time, and to securely sto it on the device. Will do minor UI fixes and further testing, and merge within a few days.

Aiming at new release in ~week.