File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ turbo = auto
5151
5252# settings for when using battery power
5353[battery]
54+ # Specify which battery device to use for reading battery information. see available batteries by running: ls /sys/class/power_supply/
55+ # If not set, auto-cpufreq will automatically detect and use the first battery found
56+ # battery_device = BAT1
57+
5458# see available governors by running: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
5559# preferred governor
5660governor = powersave
Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ services.auto-cpufreq.settings = {
5353
5454 # settings for when using battery power
5555 battery = {
56+ # Specify which battery device to use for reading battery information. see available batteries by running: ls /sys/class/power_supply/
57+ # If not set, auto-cpufreq will automatically detect and use the first battery found
58+ # battery_device = BAT1
59+
5660 # see available governors by running: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
5761 # preferred governor
5862 governor = "powersave" ;
Original file line number Diff line number Diff line change @@ -228,6 +228,21 @@ def read_file(path: str) -> Optional[str]:
228228 @staticmethod
229229 def get_battery_path () -> Optional [str ]:
230230
231+ # Check if user has specified a custom battery device in config
232+ if config .has_config ():
233+ conf = config .get_config ()
234+ if conf .has_option ("battery" , "battery_device" ):
235+ battery_device = conf .get ("battery" , "battery_device" ).strip ()
236+ if battery_device :
237+ custom_path = os .path .join (POWER_SUPPLY_DIR , battery_device )
238+ type_path = os .path .join (custom_path , "type" )
239+ # Validate that the specified device exists and is a battery
240+ if os .path .isfile (type_path ):
241+ content = SystemInfo .read_file (type_path )
242+ if content and content .lower () == "battery" :
243+ return custom_path
244+
245+ # Fall back to auto-detection if no custom device specified or if it's invalid
231246 try :
232247 for entry in os .listdir (POWER_SUPPLY_DIR ):
233248 path = os .path .join (POWER_SUPPLY_DIR , entry )
You can’t perform that action at this time.
0 commit comments