phragment / tp-battery-icon Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
On newer kernels the battery charging thresholds don't work producing an exception. I am not sure when this started, but I think it was with 3.10. I have tested 3.10.7 & 3.10.10. I am using ArchLinux with acpi_call-git
from AUR, with the AUR patch disabled since it was already included upstream.
The exception occurs upon right-clicking the tray icon, since it tries to determine current thresholds and fails. Here's the exception text:
$ tp-battery-icon
Traceback (most recent call last):
File "./tp-battery-icon.py", line 369, in on_popup_menu
self.get_menu()
File "./tp-battery-icon.py", line 318, in get_menu
start = Gtk.MenuItem("Start Threshold " + str(ctrl.get_start_threshold()) + "%")
File "./tp-battery-icon.py", line 158, in get_start_threshold
return int(result, 16) - (3 * 256)
ValueError: null byte in argument for int()
This happens because /proc/acpi/call
returns some weird result:
$ echo "\_SB.PCI0.LPC.EC.HKEY.BCSG 0x1" | sudo tee /proc/acpi/call
$ hexdump -C /proc/acpi/call
00000000 30 78 33 33 32 00 6c 6c 65 64 00 |0x332.lled.|
0000000b
So the returning value is essentially two null-terminated strings. The good news is that the first string still contains the proper threshold value, and writing to /proc/acpi/call still changes it correctly.
I will send a patch shortly that strips out the first string from acpi_call. There should be no regression on older kernels. Let me know if this is an acceptable approach or you want to understand why this happens (I have not seen any appropriate description of this change in behaviour upstream). I also have no idea what happens on systems supported by ControlTPsmapi
. Some kind of testing of these systems as well as systems with older kernels would be good.
Currently the path of sysfs is /sys/devices/platform/smapi
, but i think this path exists only on thinkpads.
A more general approach would be following path: /sys/class/power_supply
(see https://wiki.archlinux.org/index.php/ACPI_modules#Updates_since_2.6.24)
OR:
This acpi command could be executed: acpi -i
import subprocess
subprocess.call(["acpi", "-i"])
Apparently there has been some change in your python gtk3 bindings since since
loop = GObject.MainLoop(None,False)
no longer requires/takes the second argument. Removing it seems fine...
Traceback (most recent call last):
File "/usr/bin/tp-battery-icon", line 547, in <module>
loop = GObject.MainLoop(None,False)
File "/usr/lib/python3.3/site-packages/gi/overrides/__init__.py", line 86, in wrapped
return fn(*args, **kwargs)
TypeError: __new__() takes from 1 to 2 positional arguments but 3 were given
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.