Closed teohhanhui closed 1 year ago
Interesting. I am just trying to understanding somethings
Is Asahi Linux is a kernel? or A linux distro?
Asahi Linux is a project to support Apple Silicon devices on Linux. There is an official distro by the same name which is currently based on Arch Linux ARM. See https://asahilinux.org/about/
which gnome version are you using?
GNOME 44
And currently how to do you set battery threshold? using command line?
Yeah, or udev rules.
What is the command? Do you have to install additional packages or work around to get this command working?
Just use the standard charge_control_start_threshold
/ charge_control_end_threshold
:
[teohhanhui@han-macbook-air ~]$ ls -la /sys/class/power_supply/macsmc-battery/charge_control_*
-rw-r--r--. 1 root root 16384 Apr 26 06:21 /sys/class/power_supply/macsmc-battery/charge_control_end_threshold
-rw-r--r--. 1 root root 16384 Apr 26 06:21 /sys/class/power_supply/macsmc-battery/charge_control_start_threshold
[teohhanhui@han-macbook-air ~]$ cat /sys/class/power_supply/macsmc-battery/uevent
POWER_SUPPLY_NAME=macsmc-battery
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_CHARGE_BEHAVIOUR=auto
POWER_SUPPLY_TIME_TO_EMPTY_NOW=0
POWER_SUPPLY_TIME_TO_FULL_NOW=1020
POWER_SUPPLY_CAPACITY=100
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_VOLTAGE_NOW=13288000
POWER_SUPPLY_CURRENT_NOW=537000
POWER_SUPPLY_POWER_NOW=7135000
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=9000000
POWER_SUPPLY_CHARGE_CONTROL_START_THRESHOLD=100
POWER_SUPPLY_CHARGE_CONTROL_END_THRESHOLD=100
POWER_SUPPLY_CHARGE_TERM_CURRENT=127000
POWER_SUPPLY_CONSTANT_CHARGE_CURRENT=1836000
POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=5473000
POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE=13305000
POWER_SUPPLY_CHARGE_FULL_DESIGN=4563000
POWER_SUPPLY_CHARGE_FULL=4598000
POWER_SUPPLY_CHARGE_NOW=4510000
POWER_SUPPLY_TEMP=308
POWER_SUPPLY_CHARGE_COUNTER=4970565
POWER_SUPPLY_CYCLE_COUNT=41
POWER_SUPPLY_SCOPE=System
POWER_SUPPLY_HEALTH=Good
POWER_SUPPLY_MODEL_NAME=bq40z651
POWER_SUPPLY_SERIAL_NUMBER=XXXXXXXXXXXXXXXXX
POWER_SUPPLY_MANUFACTURE_YEAR=2022
POWER_SUPPLY_MANUFACTURE_MONTH=12
POWER_SUPPLY_MANUFACTURE_DAY=29
Can you check is "/sys/module/applesmc" file is present on your system.?
Cause Apple-Intel uses it and it might conflict with Asahi linux.
ls -l /sys/module/applesmc
It is not present:
[teohhanhui@han-macbook-air ~]$ ls -la /sys/module/applesmc
ls: cannot access '/sys/module/applesmc': No such file or directory
But there's macsmc
:
[teohhanhui@han-macbook-air ~]$ ls -la /sys/module/ | grep -i smc
drwxr-xr-x. 6 root root 0 Apr 26 06:32 gpio_macsmc
drwxr-xr-x. 5 root root 0 Apr 26 06:32 macsmc
drwxr-xr-x. 6 root root 0 Apr 26 06:32 macsmc_hid
drwxr-xr-x. 7 root root 0 Apr 26 06:32 macsmc_power
drwxr-xr-x. 6 root root 0 Apr 26 06:32 macsmc_reboot
drwxr-xr-x. 6 root root 0 Apr 26 06:32 macsmc_rtkit
drwxr-xr-x. 6 root root 0 Apr 26 06:32 rtc_macsmc
Found this: https://lore.kernel.org/linux-arm-kernel/E1oVYUX-005CmY-Mr@rmk-PC.armlinux.org.uk/
May I suggest splitting into devices/AppleIntel.js
and devices/AppleArm.js
?
May I suggest splitting into
devices/AppleIntel.js
anddevices/AppleArm.js
? Oh I just named it Asahi.js Ok test this.
Download and Extract and run ./install.sh
If during installation if you run "msgfmt" error. install gettext
sudo apt install gettext
sudo dnf install gettext
Let me know if it works.
if it doesnt send me the logs
journalctl -f -o cat /usr/bin/gnome-shell
Sorry about that it was wrong zip file, so I edited comment and removed it Test this
Oh also I need one more information
ls -l /sys/class/power_supply
Does it have the a filenode for charger? usually it is AC or AC0/1 or ADP0/1
It's macsmc-ac
ok. so probably it should have an file "online" to check if charger is plugged or not.
Can you check if the file is present if it changes state to "1" or "0" when charger is plugged or unplugged?
cat /sys/class/power_supply/macsmc-ac/online
This would be required for the Change battery indicator icon behavior
settings in extension preference to work properly.
Please check and let me know if the online file exist and reads charger status.
Also let me know about the test.zip results.
Can you check if the file is present if it changes state to "1" or "0" when charger is plugged or unplugged?
cat /sys/class/power_supply/macsmc-ac/online
Confirmed working as it should.
Hmm... I'm trying your modified code, but I don't understand why this extension needs to install polkit policy and rules, whereas the other extension works with just plain pkexec tee
:
Does it have anything to do with the way you're executing a separate shell script (batteryhealthchargingctl
)? But why do that when you have the full expressiveness of JavaScript already? :thinking:
Hmm... I'm trying your modified code, but I don't understand why this extension needs to install polkit policy and rules, whereas the other extension works with just plain
pkexec tee
:Does it have anything to do with the way you're executing a separate shell script (
batteryhealthchargingctl
)? But why do that when you have the full expressiveness of JavaScript already? thinking
Most of the device need root privilged to change threshold. So if I implement the same method as in francku extension (without polkit) there are 2 drawbacks.
Using polkit solves this issue with ease of usabilty.
If Asahi linux can change the threshold without root privilegdes (such as sudo, su or pkexec) out of the box (without any additional workaround such as daemon / systemd script) please let me know. I will remove to option of installing polkit for Asahi linux and modify my code not to use pkexec.
Also I will need more information on the charger by running the below command twice. one with charger plugged-powered and second with charger disconnected.
cat /sys/class/power_supply/macsmc-ac/online
This will help me to make this feature working.
To better understand what this setting does read these post below
https://github.com/maniacx/Battery-Health-Charging/issues/11#issuecomment-1493185059
Using polkit solves this issue with ease of usabilty.
Hmm... I get what you mean, but I think this is trying to solve the problem at the wrong level. As a user I would not expect this level of usability from an extension. I would not mind authenticating each time without the polkit changes. (Just like connecting to a new WiFi network requires polkit authentication on openSUSE. It's a minor annoyance; no big deal.)
I'd put the expectation on GNOME / FreeDesktop / etc. to figure this out - it was already rejected by upower since their goal is to be read-only: https://gitlab.freedesktop.org/upower/upower/-/merge_requests/49
Also I will need more information on the charger by running the below command twice. one with charger plugged-powered and second with charger disconnected.
cat /sys/class/power_supply/macsmc-ac/online
As I have reported earlier, it behaves exactly as it should (the same as you've described) - 1
when plugged in, 0
when unplugged.
Hmm... I get what you mean, but I think this is trying to solve the problem at the wrong level.
Until devs at gnome, upower and device kernel maintainers get on the same page, we have no option.
For me, changing threshold once I wouldn't mind to enter password, but I hated the fact that I had to enter password on my Asus laptop to change threshold on every reboot. So this extension was born. Luckily I found this 2 extension using polkit and I just modified my way around it change threshold
https://extensions.gnome.org/extension/4372/shutdowntimer/ https://extensions.gnome.org/extension/945/cpu-power-manager/
@teohhanhui I have included the charging info. Please do this final test for me regarding charging icon as described in part1 here https://github.com/maniacx/Battery-Health-Charging/issues/11#issuecomment-1493185059
Take your time and reply, if and when every is working as it should, so that I can submit it for gnome extension review.
The "Change battery indicator icon behavior" option is really confusing. I had to look at the code to understand what it's meant for.
If I understand correctly, it's the opposite of what the explanation text under the option says:
Battery indicator icon switches to charging in system tray and quick settings panel when charging threshold is enabled and device is powered by charger.
The option in fact forces the use of the "charging" icon even when the device is not charging because of the charge control threshold.
May I suggest changing the wording to:
Switches battery indicator icon to charging in system tray and quick settings panel when device is plugged in to power source, even when charging is disabled due to charge threshold.
EDIT: removed reference to "AC power" to make it make sense for DC-to-DC charging, e.g. USB PD.
Otherwise everything is working as expected. :tada:
Thanks. Your description makes more sense. It was very hard for me to describe what it does. I will add it.
See https://social.treehouse.systems/@AsahiLinux/110073752180666718 and https://github.com/francku/gnome-shell-extension-battery-threshold/pull/11
The relevant commit seems to be https://github.com/AsahiLinux/linux/commit/6eb70e021ccaae0408e5a746b65848b811c23caa