adjustor 3.7.7__tar.gz → 3.8.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. {adjustor-3.7.7/src/adjustor.egg-info → adjustor-3.8.0}/PKG-INFO +1 -1
  2. {adjustor-3.7.7 → adjustor-3.8.0}/pyproject.toml +1 -1
  3. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/asus/__init__.py +8 -45
  4. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/asus/settings.yml +0 -15
  5. adjustor-3.8.0/src/adjustor/drivers/battery/__init__.py +173 -0
  6. adjustor-3.8.0/src/adjustor/drivers/battery/battery.yml +28 -0
  7. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/hhd.py +4 -4
  8. {adjustor-3.7.7 → adjustor-3.8.0/src/adjustor.egg-info}/PKG-INFO +1 -1
  9. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor.egg-info/SOURCES.txt +2 -0
  10. {adjustor-3.7.7 → adjustor-3.8.0}/LICENSE +0 -0
  11. {adjustor-3.7.7 → adjustor-3.8.0}/MANIFEST.in +0 -0
  12. {adjustor-3.7.7 → adjustor-3.8.0}/readme.md +0 -0
  13. {adjustor-3.7.7 → adjustor-3.8.0}/setup.cfg +0 -0
  14. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/__init__.py +0 -0
  15. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/__main__.py +0 -0
  16. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/__init__.py +0 -0
  17. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/acpi.py +0 -0
  18. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/alib.py +0 -0
  19. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/const.py +0 -0
  20. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/fan/__init__.py +0 -0
  21. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/fan/__main__.py +0 -0
  22. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/fan/alg.py +0 -0
  23. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/fan/core.py +0 -0
  24. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/fan/utils.py +0 -0
  25. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/lenovo.py +0 -0
  26. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/core/platform.py +0 -0
  27. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/__init__.py +0 -0
  28. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/amd/__init__.py +0 -0
  29. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/amd/power-profiles-daemon.dbus.xml.in +0 -0
  30. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/amd/ppd.py +0 -0
  31. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/amd/settings.yml +0 -0
  32. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/general/__init__.py +0 -0
  33. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/general/settings.yml +0 -0
  34. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/lenovo/__init__.py +0 -0
  35. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/lenovo/settings.yml +0 -0
  36. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/smu/__init__.py +0 -0
  37. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/smu/qam.yml +0 -0
  38. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/drivers/smu/smu.yml +0 -0
  39. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/events.py +0 -0
  40. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/fuse/__init__.py +0 -0
  41. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/fuse/driver.py +0 -0
  42. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/fuse/gpu.py +0 -0
  43. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/fuse/utils.py +0 -0
  44. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/i18n.py +0 -0
  45. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor/settings.yml +0 -0
  46. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor.egg-info/dependency_links.txt +0 -0
  47. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor.egg-info/entry_points.txt +0 -0
  48. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor.egg-info/requires.txt +0 -0
  49. {adjustor-3.7.7 → adjustor-3.8.0}/src/adjustor.egg-info/top_level.txt +0 -0
  50. {adjustor-3.7.7 → adjustor-3.8.0}/usr/share/dbus-1/system.d/hhd-net.hadess.PowerProfiles.conf +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: adjustor
3
- Version: 3.7.7
3
+ Version: 3.8.0
4
4
  Summary: Adjustor, a userspace program for managing the TDP of handheld devices.
5
5
  Author-email: Kapenekakis Antheas <pypi@antheas.dev>
6
6
  Project-URL: Homepage, https://github.com/hhd-dev/adjustor
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "adjustor"
3
- version = "3.7.7"
3
+ version = "3.8.0"
4
4
  authors = [
5
5
  { name="Kapenekakis Antheas", email="pypi@antheas.dev" },
6
6
  ]
@@ -51,20 +51,6 @@ MIN_CURVE = [2, 5, 17, 17, 17, 17, 17, 17]
51
51
  DEFAULT_CURVE = [5, 10, 20, 35, 55, 75, 75, 75]
52
52
 
53
53
 
54
- def set_charge_limit(lim: int):
55
- try:
56
- # FIXME: Hardcoded path, should match using another characteristic
57
- logger.info(f"Setting charge limit to {lim:d} %.")
58
- with open(
59
- "/sys/class/power_supply/BAT0/charge_control_end_threshold", "w"
60
- ) as f:
61
- f.write(f"{lim}\n")
62
- return True
63
- except Exception as e:
64
- logger.error(f"Failed to write battery limit with error:\n{e}")
65
- return False
66
-
67
-
68
54
  def set_tdp(pretty: str, fn: str, val: int):
69
55
  logger.info(f"Setting tdp value '{pretty}' to {val} by writing to:\n{fn}")
70
56
  try:
@@ -147,7 +133,6 @@ class AsusDriverPlugin(HHDPlugin):
147
133
 
148
134
  self.queue_fan = None
149
135
  self.queue_tdp = None
150
- self.queue_charge_limit = None
151
136
  self.queue_extreme = time.perf_counter() + EXTREME_STARTUP_DELAY
152
137
  self.new_tdp = None
153
138
  self.new_mode = None
@@ -225,34 +210,6 @@ class AsusDriverPlugin(HHDPlugin):
225
210
 
226
211
  curr = time.perf_counter()
227
212
 
228
- # Charge limit
229
- lim = conf["tdp.asus.charge_limit"].to(str)
230
- if (self.startup and lim != "disabled") or (
231
- lim != self.old_conf["charge_limit"].to(str)
232
- ):
233
- self.queue_charge_limit = curr + APPLY_DELAY
234
-
235
- if self.queue_charge_limit and self.queue_charge_limit < curr:
236
- self.queue_charge_limit = None
237
- match lim:
238
- case "p65":
239
- set_charge_limit(65)
240
- case "p70":
241
- set_charge_limit(70)
242
- case "p80":
243
- set_charge_limit(80)
244
- case "p85":
245
- set_charge_limit(85)
246
- case "p90":
247
- set_charge_limit(90)
248
- case "p95":
249
- set_charge_limit(95)
250
- case "disabled":
251
- # Avoid writing charge limit on startup if
252
- # disabled
253
- if not self.startup:
254
- set_charge_limit(100)
255
-
256
213
  #
257
214
  # TDP
258
215
  #
@@ -508,8 +465,14 @@ class AsusDriverPlugin(HHDPlugin):
508
465
  f"Waking up from sleep, resetting TDP after {SLEEP_DELAY} seconds."
509
466
  )
510
467
  self.queue_tdp = time.time() + SLEEP_DELAY
511
- elif ev["type"] == "acpi" and ev["event"] in ("ac", "dc") and not self.queue_tdp:
512
- logger.info(f"Power adapter status switched to '{ev['event']}', resetting TDP.")
468
+ elif (
469
+ ev["type"] == "acpi"
470
+ and ev["event"] in ("ac", "dc")
471
+ and not self.queue_tdp
472
+ ):
473
+ logger.info(
474
+ f"Power adapter status switched to '{ev['event']}', resetting TDP."
475
+ )
513
476
  self.queue_tdp = time.time() + APPLY_DELAY
514
477
  elif self.cycle_tdp and ev["type"] == "special" and ev["event"] == "xbox_y":
515
478
  match self.mode:
@@ -129,21 +129,6 @@ children:
129
129
  default: >-
130
130
  Asus hardware limits the minimum fan curve depending on TDP mode.
131
131
 
132
- charge_limit:
133
- type: multiple
134
- title: Charge Limit (%)
135
- tags: [ non-essential, ordinal ]
136
- hint: >-
137
- Applies a charge limit to the battery, 75% and up.
138
- options:
139
- p70: 70%
140
- p80: 80%
141
- p85: 85%
142
- p90: 90%
143
- p95: 95%
144
- disabled: Unset
145
- default: disabled
146
-
147
132
  extreme_standby:
148
133
  type: multiple
149
134
  title: Extreme Standby Mode
@@ -0,0 +1,173 @@
1
+ import logging
2
+ import time
3
+ from threading import Event as TEvent, Lock, Thread
4
+ from typing import Sequence
5
+ import os
6
+
7
+ from hhd.plugins import Context, Event, HHDPlugin, load_relative_yaml
8
+ from hhd.plugins.conf import Config
9
+
10
+ from adjustor.core.alib import AlibParams, DeviceParams, alib
11
+ from adjustor.core.fan import fan_worker, get_fan_info
12
+ from adjustor.core.platform import get_platform_choices, set_platform_profile
13
+ from adjustor.i18n import _
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+ APPLY_DELAY = 0.7
18
+
19
+
20
+ def set_charge_limit(bat: str, lim: int):
21
+ try:
22
+ logger.info(f"Setting charge limit to {lim:d} %.")
23
+ with open(bat, "w") as f:
24
+ f.write(f"{lim}\n")
25
+ return True
26
+ except Exception as e:
27
+ logger.error(f"Failed to write battery limit with error:\n{e}")
28
+ return False
29
+
30
+
31
+ def set_charge_bypass(bat: str, type: str):
32
+ match type:
33
+ case "disabled":
34
+ val = "Standard"
35
+ case "awake":
36
+ val = "BypassS0"
37
+ case "always":
38
+ val = "Bypass"
39
+ case _:
40
+ logger.error(f"Invalid charge bypass type: {type}")
41
+ return
42
+
43
+ try:
44
+ logger.info(f"Setting charge type to '{val}' (for bypass '{type}').")
45
+ with open(bat, "w") as f:
46
+ f.write(f"{val}\n")
47
+ return True
48
+ except Exception as e:
49
+ logger.error(f"Failed to write battery bypass with error:\n{e}")
50
+ return False
51
+
52
+
53
+ class BatteryPlugin(HHDPlugin):
54
+
55
+ def __init__(
56
+ self,
57
+ ) -> None:
58
+ self.name = f"adjustor_battery"
59
+ self.priority = 9
60
+ self.log = "batt"
61
+ self.enabled = False
62
+ self.initialized = False
63
+ self.startup = False
64
+
65
+ self.queue_charge_limit = None
66
+ self.charge_bypass_fn = None
67
+ self.charge_limit_fn = None
68
+ self.charge_bypass_prev = None
69
+ self.charge_limit_prev = None
70
+
71
+ def settings(self):
72
+ if not self.enabled:
73
+ self.initialized = False
74
+ return {}
75
+
76
+ self.initialized = True
77
+ out = {"tdp": {"battery": load_relative_yaml("battery.yml")}}
78
+
79
+ if not self.charge_limit_fn:
80
+ del out["tdp"]["battery"]["children"]["charge_limit"]
81
+ if not self.charge_bypass_fn:
82
+ del out["tdp"]["battery"]["children"]["charge_bypass"]
83
+
84
+ return out
85
+
86
+ def open(
87
+ self,
88
+ emit,
89
+ context: Context,
90
+ ):
91
+ self.emit = emit
92
+ self.startup = True
93
+
94
+ for bat in os.listdir("/sys/class/power_supply"):
95
+ if not bat.startswith("BAT"):
96
+ continue
97
+
98
+ with open(f"/sys/class/power_supply/{bat}/type") as f:
99
+ if "Battery" not in f.read():
100
+ continue
101
+
102
+ base = f"/sys/class/power_supply/{bat}"
103
+ if os.path.exists(f"{base}/charge_control_end_threshold"):
104
+ self.charge_limit_fn = f"{base}/charge_control_end_threshold"
105
+ if os.path.exists(f"{base}/charge_type"):
106
+ try:
107
+ with open("/sys/devices/virtual/dmi/id/sys_vendor") as f:
108
+ supports = "ONE-NETBOOK" in f.read()
109
+ except Exception:
110
+ supports = False
111
+
112
+ if supports:
113
+ self.charge_bypass_fn = f"{base}/charge_type"
114
+ else:
115
+ logger.warning(
116
+ "Found charge type, but charge bypass is only supported on OneXPlayer currently."
117
+ )
118
+ if self.charge_bypass_fn or self.charge_limit_fn:
119
+ logger.info(
120
+ f"Found battery '{bat}' with:\nBattery Bypass:\n{self.charge_bypass_fn}\nBattery Limit:\n{self.charge_limit_fn}."
121
+ )
122
+ break
123
+
124
+ def update(self, conf: Config):
125
+ self.enabled = conf["hhd.settings.tdp_enable"].to(bool)
126
+
127
+ if not self.initialized:
128
+ return
129
+
130
+ curr = time.time()
131
+
132
+ if self.charge_bypass_fn:
133
+ bypass = conf["tdp.battery.charge_bypass"].to(str)
134
+ if self.charge_bypass_prev != bypass:
135
+ self.charge_bypass_prev = bypass
136
+
137
+ if bypass != "disabled" or not self.startup:
138
+ set_charge_bypass(self.charge_bypass_fn, bypass)
139
+
140
+ # Charge limit
141
+ if self.charge_limit_fn:
142
+ lim = conf["tdp.battery.charge_limit"].to(str)
143
+ if lim != self.charge_limit_prev:
144
+ self.queue_charge_limit = curr + APPLY_DELAY
145
+ self.charge_limit_prev = lim
146
+
147
+ if self.startup or (
148
+ self.queue_charge_limit and self.queue_charge_limit < curr
149
+ ):
150
+ self.queue_charge_limit = None
151
+ self.charge_limit_prev = lim
152
+
153
+ match lim:
154
+ case "p65":
155
+ set_charge_limit(self.charge_limit_fn, 65)
156
+ case "p70":
157
+ set_charge_limit(self.charge_limit_fn, 70)
158
+ case "p80":
159
+ set_charge_limit(self.charge_limit_fn, 80)
160
+ case "p85":
161
+ set_charge_limit(self.charge_limit_fn, 85)
162
+ case "p90":
163
+ set_charge_limit(self.charge_limit_fn, 90)
164
+ case "p95":
165
+ set_charge_limit(self.charge_limit_fn, 95)
166
+ case "disabled":
167
+ # Avoid writing charge limit on startup if
168
+ # disabled, so that if user does not use us
169
+ # we do not overwrite their setting.
170
+ if not self.startup:
171
+ set_charge_limit(self.charge_limit_fn, 100)
172
+
173
+ self.startup = False
@@ -0,0 +1,28 @@
1
+ title: Battery Settings
2
+ type: container
3
+ tags: [ hide-title ]
4
+ children:
5
+ charge_limit:
6
+ type: multiple
7
+ title: Charge Limit (%)
8
+ tags: [ non-essential, ordinal ]
9
+ hint: >-
10
+ Applies a charge limit to the battery, 75% and up.
11
+ options:
12
+ p70: 70%
13
+ p80: 80%
14
+ p85: 85%
15
+ p90: 90%
16
+ p95: 95%
17
+ disabled: Unset
18
+ default: disabled
19
+
20
+ charge_bypass:
21
+ type: multiple
22
+ title: Charge Bypass
23
+ tags: [ non-essential, ordinal ]
24
+ options:
25
+ disabled: Unset
26
+ awake: While On
27
+ always: Always
28
+ default: Unset
@@ -243,6 +243,7 @@ def autodetect(existing: Sequence[HHDPlugin]) -> Sequence[HHDPlugin]:
243
243
  from .drivers.lenovo import LenovoDriverPlugin
244
244
  from .drivers.smu import SmuDriverPlugin, SmuQamPlugin
245
245
  from .drivers.amd import AmdGPUPlugin
246
+ from .drivers.battery import BatteryPlugin
246
247
 
247
248
  drivers = []
248
249
  with open("/sys/devices/virtual/dmi/id/product_name") as f:
@@ -261,9 +262,7 @@ def autodetect(existing: Sequence[HHDPlugin]) -> Sequence[HHDPlugin]:
261
262
  max_tdp = 30
262
263
 
263
264
  legion_s = prod in LEGION_GO_S_DMIS
264
- if (prod == LEGION_GO_DMI or legion_s) and not bool(
265
- os.environ.get("HHD_ADJ_ALLY")
266
- ):
265
+ if (prod == LEGION_GO_DMI or legion_s) and not bool(os.environ.get("HHD_ADJ_ALLY")):
267
266
  drivers.append(LenovoDriverPlugin(legion_s=legion_s))
268
267
  drivers_matched = True
269
268
  use_acpi_call = True
@@ -338,11 +337,12 @@ def autodetect(existing: Sequence[HHDPlugin]) -> Sequence[HHDPlugin]:
338
337
  logger.info(f"No tdp drivers found for this device, using generic plugin.")
339
338
 
340
339
  is_steamdeck = "Jupiter" in prod or "Galileo" in prod
341
- return [GeneralPowerPlugin(is_steamdeck=is_steamdeck)]
340
+ return [GeneralPowerPlugin(is_steamdeck=is_steamdeck), BatteryPlugin()]
342
341
 
343
342
  return [
344
343
  *drivers,
345
344
  AdjustorInitPlugin(use_acpi_call=use_acpi_call),
346
345
  AdjustorPlugin(min_tdp, default_tdp, max_tdp),
346
+ BatteryPlugin(),
347
347
  AmdGPUPlugin(),
348
348
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: adjustor
3
- Version: 3.7.7
3
+ Version: 3.8.0
4
4
  Summary: Adjustor, a userspace program for managing the TDP of handheld devices.
5
5
  Author-email: Kapenekakis Antheas <pypi@antheas.dev>
6
6
  Project-URL: Homepage, https://github.com/hhd-dev/adjustor
@@ -32,6 +32,8 @@ src/adjustor/drivers/amd/ppd.py
32
32
  src/adjustor/drivers/amd/settings.yml
33
33
  src/adjustor/drivers/asus/__init__.py
34
34
  src/adjustor/drivers/asus/settings.yml
35
+ src/adjustor/drivers/battery/__init__.py
36
+ src/adjustor/drivers/battery/battery.yml
35
37
  src/adjustor/drivers/general/__init__.py
36
38
  src/adjustor/drivers/general/settings.yml
37
39
  src/adjustor/drivers/lenovo/__init__.py
File without changes
File without changes
File without changes
File without changes
File without changes