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

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

Closed
poltpolt opened this issue Feb 6, 2024 · 12 comments · Fixed by #36
Closed

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

poltpolt opened this issue Feb 6, 2024 · 12 comments · Fixed by #36
Assignees
Labels
enhancement New feature or request os:linux non-ubuntu distros os:windows

Comments

@poltpolt
Copy link

poltpolt commented Feb 6, 2024

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
Copy link
Owner

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
Copy link
Author

poltpolt commented Feb 6, 2024

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
Copy link
Owner

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.

@alexVinarskis alexVinarskis added os:windows os:linux non-ubuntu distros enhancement New feature or request labels Feb 6, 2024
@poltpolt
Copy link
Author

poltpolt commented Feb 7, 2024 via email

@xAlvzx
Copy link

xAlvzx commented Feb 9, 2024

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
Copy link
Owner

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

@alexVinarskis
Copy link
Owner

@poltpolt powerprofilectl error message resolved in #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.

@alexVinarskis alexVinarskis changed the title [BUG] Powerprofile switching makes no effect [BUG] Unable to switch modes when BIOS SetupPwd/SysPwd/OwnerPwd is set Feb 11, 2024
@poltpolt
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

alexVinarskis commented Feb 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request os:linux non-ubuntu distros os:windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants