NBFC-SERVICE.JSON(5)

๐Ÿ“ฆ
version 0.5.4 ยท 2 versions
, in nixpkgs unstable

๐Ÿ’… NAME ๐Ÿ’…

nbfc_service.json is the Notebook FanControl service configuration, bestie โ€” section 5 energy, and this is the whole config vibe for nbfc_service. Every field is getting its moment. ๐Ÿ’–

โœจ CONFIGURATION โœจ

๐Ÿ’ก NOTE: Comments can be added in any JSON object by using the Comment or the # field.

๐Ÿ› ๏ธ ServiceConfig

Main configuration file of nbfc_service (/nix/store/48mhb6ci6w735jxaz60mhn63p4ccn956-nbfc-linux-0.5.4/etc/nbfc/nbfc.json).

  • SelectedConfigId: String โ€” The selected config model. This equals the basename of a notebook model configuration file. Absolute file paths can also be specified.
  • EmbeddedControllerType: String โ€” Selects the implementation used to access the embedded controller.
    • ec_sys โ€” Use the ec_sys kernel module.
    • acpi_ec โ€” Use the acpi_ec kernel module.
    • dev_port โ€” Access the embedded controller via /dev/port.
    • dummy โ€” Do not access the embedded controller at all.

If not given, the embedded controller type will be automatically selected.

  • FanTemperatureSources: Array of FanTemperatureSourceConfig โ€” Used for configuring which sensors are attached to a fan.

๐ŸŒธ FanTemperatureSourceConfig ๐ŸŒธ

Configures which sensors are attached to a fan.

  • FanIndex: Integer >= 0 && Integer <= 255 โ€” Specify which fan should be configured.
  • TemperatureAlgorithmType: String โ€” See FanConfiguration->TemperatureAlgorithmType.
  • Sensors: Array of String โ€” See FanConfiguration->Sensors.

๐Ÿฆ‹ ServiceState ๐Ÿฆ‹

State file of the service (/var/lib/nbfc/state.json).

  • TargetFanSpeeds: Array of Float โ€” This holds the fixed speed of the fans. A value of -1 means the fan should be left in auto mode.

๐ŸŽ€ ModelConfig ๐ŸŽ€

  • NotebookModel: String โ€” The Notebook Model as described in your BIOS. See nbfc get-model-name.
  • Author: String โ€” The Author of the config file. Enter whatever you want.
  • LegacyTemperatureThresholdsBehaviour: Boolean โ€” This option was introduced for being backwards compatible with configuration files from the original NBFC project. The default is false. Do not use this option for new configuration files.
  • EcPollInterval: Integer > 0 โ€” Defines how often NBFC polls the EC for changes (in milliseconds).
  • CriticalTemperature: Integer โ€” If the temperature exceeds this threshold, NBFC will ignore all Temperature threshold elements and set the fan to 100% speed until the temperature drops below (CriticalTemperature minus CriticalTemperatureOffset).

Can be overwritten by FanConfiguration's CriticalTemperature.

  • CriticalTemperatureOffset: Integer > 0 โ€” See CriticalTemperature.

Can be overwritten by FanConfiguration's CriticalTemperatureOffset.

  • ReadWriteWords: Boolean โ€” If true, NBFC will combine two 8 bit registers to one 16-bit register when reading from or writing to the EC registers.

DEPRECATED. Use FanConfiguration->ReadWords and FanConfiguration->WriteWords instead.

  • LuaLibraries: Array of String โ€” Import additional Lua libraries.

Example: "LuaLibraries": ["math"]

Available libraries:

  • base โ€” Provides core global functions.
  • math โ€” Provides standard mathematical functions and constants.
  • string โ€” Provides functions for pattern matching and basic string manipulation.
  • table โ€” Provides utilities for creating and manipulating tables (arrays and dictionaries).
  • io โ€” Provides file input/output facilities and stream-based I/O operations.
  • os โ€” Provides operating system interface functions such as time, environment, and process control.
  • FirmwareFingerprint: Array of String โ€” See FIRMWARE FINGERPRINTING.
  • FanConfigurations: Array of FanConfiguration โ€” Array of at least one FanConfiguration
  • RegisterWriteConfigurations: Array of RegisterWriteConfiguration โ€” Array of RegisterWriteConfiguration

๐ŸŒˆ FanConfiguration ๐ŸŒˆ

Defines how NBFC controls a fan.

  • FanDisplayName: String โ€” Sets the fan display name.
  • CriticalTemperature: Integer โ€” If the temperature exceeds this threshold, NBFC will ignore all Temperature threshold elements and set the fan to 100% speed until the temperature drops below (CriticalTemperature minus CriticalTemperatureOffset).
  • CriticalTemperatureOffset: Integer > 0 โ€” See CriticalTemperature.
  • ReadWords: Boolean โ€” If true, NBFC will combine two 8 bit registers to one 16-bit register when reading from the EC.

Overrides ModelConfig->ReadWriteWords.

  • WriteWords: Boolean โ€” If true, NBFC will combine two 8 bit registers to one 16-bit register when writing to the EC.

Overrides ModelConfig->ReadWriteWords.

  • ReadRegister: Integer >= 0 && Integer <= 255 โ€” The register from which NBFC reads the fan speed.

This option is mutually exclusive to ReadAcpiMethod and ReadLuaCode. Only one of them can be set at a time.

  • ReadAcpiMethod: String โ€” The ACPI method for reading the fan speed.

Example:

"ReadAcpiMethod": "\\_SB.PCI0.LPCB.EC0.GFSD"

This option is mutually exclusive to ReadRegister and ReadLuaCode. Only one of them can be set at a time.

  • ReadLuaCode: String or Array of String โ€” The Lua code to be executed for reading the fan speed. See LUA CODE.

Example:

"ReadLuaCode": "return
acpi_call(\"\\\\_SB.PCI0.LPCB.EC0.GFSD\")"

This option is mutually exclusive to ReadRegister and ReadAcpiMethod. Only one of them can be set at a time.

  • WriteRegister: Integer >= 0 && Integer <= 255 โ€” The register which NBFC uses to control the fan.

This option is mutually exclusive to WriteAcpiMethod and WriteLuaCode. Only one of them can be set at a time.

  • WriteAcpiMethod: String โ€” The ACPI method for writing the fan speed. The command must contain a placeholder ($) which will be replaced by the fan speed.

Example:

"WriteAcpiMethod": "\\_SB.PCI0.LPCB.EC0.SFSD $"

This option is mutually exclusive to WriteRegister and WriteLuaCode. Only one of them can be set at a time.

  • WriteLuaCode: String or Array of String โ€” The Lua code to execute for writing the fan speed. See LUA CODE.

Example:

"WriteLuaCode": "return
acpi_call(\"\\\\_SB.PCI0.LPCB.EC0.SFSD \" .. get_value())"

This option is mutually exclusive to WriteRegister and WriteAcpiMethod. Only one of them can be set at a time.

  • MinSpeedValue: Integer >= 0 && Integer <= 65535 โ€” The value which puts the fan to the lowest possible speed (usually this stops the fan). Must be an integer between 0 and 255 or 0 and 65535 if ReadWriteWords is true. Note: MinSpeedValue does not necessarily have to be smaller than MaxSpeedValue.
  • MaxSpeedValue: Integer >= 0 && Integer <= 65535 โ€” The value which puts the fan to the highest possible fan speed.
  • MinSpeedValueRead: Integer >= 0 && Integer <= 65535 โ€” The value which corresponds to the lowest possible fan speed. Will be ignored if IndependentReadMinMaxValues is false.
  • MaxSpeedValueRead: Integer >= 0 && Integer <= 65535 โ€” The value which corresponds to the highest possible fan speed. Will be ignored if IndependentReadMinMaxValues is false.
  • IndependentReadMinMaxValues: Boolean โ€” Defines if independent minimum/maximum values should be applied for read operations.

This enables MinSpeedValueRead and MaxSpeedValueRead.

  • ResetRequired: Boolean โ€” Defines if the EC should be reset before the service is shut down.
  • FanSpeedResetValue: Integer >= 0 && Integer <= 65535 โ€” Defines the value which will be written to WriteRegister to reset the EC.

This option is mutually exclusive to ResetAcpiMethod and ResetLuaCode. Only one of them can be set at a time.

  • ResetAcpiMethod: String โ€” The ACPI method to call upon fan reset.

This option is mutually exclusive to FanSpeedResetValue and ResetLuaCode. Only one of them can be set at a time.

  • ResetLuaCode: String or Array of String โ€” The Lua code to be executed upon fan reset. See LUA CODE.

This option is mutually exclusive to FanSpeedResetValue and ResetAcpiMethod. Only one of them can be set at a time.

  • Sensors: Array of String โ€” Defines which sensors shall be used for this fan. This should either be a sensor name or a sensor group.

Available groups:

  • @CPU โ€” Uses all sensors named coretemp, k10temp or zenpower
  • @GPU โ€” Uses all sensors named amdgpu, nvidia, nvidia-ml, nouveau or radeon
  • TemperatureAlgorithmType: String โ€” Specify the algorithm type to compute the temperature.
    • Average โ€” Computes the average temperature from all specified sensors (default)
    • Min โ€” Selects the lowest temperature among all specified sensors
    • Max โ€” Selects the highest temperature among all specified sensors
  • TemperatureThresholds: Array of TemperatureThreshold โ€” Defines how fast the fan runs at different temperatures.
  • FanSpeedPercentageOverrides: Array of FanSpeedPercentageOverride โ€” Overrides the default algorithm to calculate fan speeds.

๐Ÿงš RegisterWriteConfiguration ๐Ÿงš

Allows to write to any EC register.

  • WriteMode: String โ€” Defines how the value will be written:
    • Set โ€” overwrites the register with the specified value (register = value)
    • And โ€” performs a binary AND operation (register = register & value)
    • Or โ€” performs a binary OR operation (register = register | value)
    • Call โ€” calls the ACPI method stored in AcpiMethod or ResetAcpiMethod
    • Lua โ€” executes the Lua code stored in LuaCode or ResetLuaCode
  • WriteOccasion: String โ€” Defines when the value should be written:
    • OnInitialization โ€” writes the value once upon initialization (every time the fan control service starts).
    • OnWriteFanSpeed โ€” writes the value every time the fan speed is set.
  • Register: Integer >= 0 && Integer <= 255 โ€” The register which will be manipulated.
  • Value: Integer >= 0 && Integer <= 255 โ€” The value which will be written.

This one's mutually exclusive to AcpiMethod and LuaCode bestie โ€” only one of them can be set at a time, no cap ๐Ÿ’…

  • AcpiMethod: String โ€” the ACPI method to call. โœจ This option is mutually exclusive to Value and LuaCode. Only one of them can be set at a time.
  • LuaCode: String or Array of String โ€” the Lua code to be executed. Peep LUA CODE below for the deets. ๐Ÿ”ฎ This option is mutually exclusive to Value and AcpiMethod. Only one of them can be set at a time.
  • ResetRequired: Boolean โ€” defines if the register should be reset before the service is shut down. ๐Ÿ’€ lowkey important.
  • ResetValue: Integer >= 0 && Integer <= 255 โ€” the value which will be written upon reset. This option is mutually exclusive to ResetAcpiMethod and ResetLuaCode. Only one of them can be set at a time.
  • ResetAcpiMethod: String โ€” the ACPI method to call upon reset. This option is mutually exclusive to ResetValue and ResetLuaCode. Only one of them can be set at a time.
  • ResetLuaCode: String or Array of String โ€” the Lua code to be executed upon reset. See LUA CODE. This option is mutually exclusive to ResetValue and ResetAcpiMethod. Only one of them can be set at a time.
  • ResetWriteMode: String โ€” see WriteMode. Will only be applied on reset, iykyk โœจ
  • Description: String โ€” a short description of what effect the RegisterWriteConfiguration will have. just a lil blurb ๐ŸŽ€

๐ŸŒธ FanSpeedPercentageOverride ๐ŸŒธ

Overrides the default algorithm to calculate fan speeds. it's giving "I know better than the math" energy ๐Ÿ˜Œ

  • FanSpeedPercentage: Float >= 0.0 && Float <= 100.0 โ€” the fan speed in percent.
  • FanSpeedValue: Integer >= 0 && Integer <= 65535 โ€” the fan speed value which will be written to WriteRegister.
  • TargetOperation: String โ€” defines for which operations the speeds should be overridden:
    • Read: if the value in the EC's ReadRegister is equal to FanSpeedValue, the corresponding percentage will not be calculated, but instead be set to FanSpeedPercentage.
    • Write: if the target fan speed percentage is equal to FanSpeedPercentage, the corresponding value will not be calculated, but instead be set to FanSpeedValue.
    • ReadWrite: applies to both, read and write operations. both is good ๐Ÿซถ

๐ŸŒก๏ธ TemperatureThreshold ๐ŸŒก๏ธ

Defines how fast the fan runs at different temperatures. the whole vibe curve, fr fr ๐ŸŒˆ

  • UpThreshold: Integer โ€” NBFC will select the next upper threshold as soon as the temperature exceeds UpThreshold (in celsius).
  • DownThreshold: Integer โ€” NBFC will select the next lower threshold as soon as the temperature falls below the DownThreshold (in celsius).
  • FanSpeed: Float >= 0.0 && Float <= 100.0 โ€” the fan speed in percent.

๐Ÿงš LUA CODE ๐Ÿงš

NBFC-Linux allows executing Lua code to implement more complex read or write operations. yes bestie, you can write actual logic in here ๐Ÿ”ฅ

Lua code can be specified as either a String or an Array of String.

โญ Return Values โญ

Every Lua code must return exactly two values: Error, Result.

Error is either nil (on success) or a string describing the error (on failure).

Result is an integer and is used for read operations. For write operations this value is ignored (returning 0 is recommended). like, it's not even looking at it ๐Ÿ™ˆ

๐Ÿ’œ Available Lua Functions ๐Ÿ’œ

The following functions are exposed to Lua:

  • acpi_call(method): Executes an ACPI method. Returns error, value (integer).
  • acpi_call_raw(method): Executes an ACPI method and returns the raw result as a string. Returns error, value (string).
  • acpi_get_int(acpi_result, path): Extracts the integer located at path from an ACPI result. Returns error, value (integer).

Example:

result = "{[0x0, 0x0], [0xFF, 0x0]}"
e, v = acpi_get_int(result, "1 0")
-- v is 0xFF
  • ec_read(register): Reads a byte from the embedded controller. Returns error, value.
  • ec_read_word(register): Reads two bytes and combines them into a single value. Returns error, value.
  • ec_write(register, value): Writes a byte to the embedded controller. Returns error, 0.
  • ec_write_word(register, value): Writes a 16-bit value to a two-byte register. Returns error, 0.

๐ŸŽ€ Lua Libraries ๐ŸŽ€

To keep memory usage as low as possible, no Lua libraries are loaded by default. They must be explicitly loaded when needed. See ModelConfig->LuaLibraries for details. ngl, load only what you need, she's on a diet ๐Ÿ’…

๐Ÿฆ‹ Coding Conventions ๐Ÿฆ‹

If possible, use the variables e (error) and v (value) for capturing the result of NBFC functions. it's just cute, okay? ๐Ÿซถ

๐ŸŒธ Testing Configuration ๐ŸŒธ

If a configuration uses Lua code, ensure that it works correctly with nbfc rate-config. During rating, nbfc rate-config replaces all NBFC-specific Lua functions with dummy implementations that always return nil, 1. so like, test it before you commit to it bestie ๐Ÿ˜ญ


๐Ÿ‘‘ FIRMWARE FINGERPRINTING ๐Ÿ‘‘

Firmware fingerprinting can be used to ensure that a configuration file matches a specific notebook firmware.

This is especially important for configurations that invoke WMI methods. Many notebook vendors reuse the same WMI method names across different notebook models while changing the internal implementation and method arguments. As a result, matching method names alone is often insufficient to determine whether a configuration is compatible with a specific firmware. the way that method names are basically catfishing you ๐Ÿ’€

Fingerprinting allows AML methods to be analyzed for specific code patterns.

๐Ÿ” Fingerprint Syntax ๐Ÿ”

Fingerprints are written using AML syntax. A fingerprint always begins with a method definition, followed by AML code that is searched for within the method body.

In addition to regular AML syntax, two wildcard operators are supported:

  • .. โ€” matches any code within the current block scope, but only at the current scope level.
  • ... โ€” matches any code within the current block scope, including code contained in nested scopes.

Example:

Given the following method:

Method (\FOO, 2, Serialized) {
    SMTH()

    Switch (Arg0) {
        Case (0xDEAD) {
            If (Arg1 == 0xBEEF) {
                FMTH()
                Return (One)
            }
        }
    }
}

The following patterns would match:

  • Method(\FOO)
  • Method(\FOO) { ... 0xDEAD
  • Method(\FOO) { ... 0xBEEF
  • Method(\FOO) { ... Switch (Arg0) { .. Case (0xDEAD)
  • Method(\FOO) { ... Switch (Arg0) { .. Case (0xDEAD) { ... If (Arg1 == 0xBEEF)
  • Method(\FOO) { ... Switch (Arg0) { .. Case (0xDEAD) { ... If (Arg1 == 0xBEEF) { ... FMTH()
  • Method(\FOO) { ... Switch (Arg0) { .. Case (0xDEAD) { ... FMTH()

The following patterns would not match:

  • Method(\FOO) { .. 0xDEAD
  • Method(\FOO) { Switch (Arg0)

๐Ÿงš Matching Rules ๐Ÿงš

  • Whitespace is ignored
  • Comments are ignored
  • Only the basename of the identifiers are matched
  • Only scope hierarchy and ordering are considered
  • Intermediate code between matched blocks is ignored

โญ Recommendations โญ

When writing fingerprints:

  • Match magic numbers used by WMI method calls whenever possible
  • Do not use fully qualified identifiers (use FOO instead of _SB.DEV0.FOO)
  • Avoid unnecessary parentheses, as they are ignored during matching (use If (FOO == 0x0) instead of If ((Foo == 0x0)))
  • The .. operator should only be used when matching a direct child block is required. A common example is matching Case() blocks within a Switch() statement, where only direct descendants should be considered.

๐Ÿ“ FILES ๐Ÿ“

  • /nix/store/48mhb6ci6w735jxaz60mhn63p4ccn956-nbfc-linux-0.5.4/etc/nbfc/nbfc.json โ€” the main configuration file for nbfc_service. the main character, honestly ๐Ÿ‘‘
  • /run/nbfc_service.pid โ€” file containing the PID of current running nbfc_service.
  • /run/nbfc_service.socket โ€” socket file of nbfc_service.
  • /nix/store/48mhb6ci6w735jxaz60mhn63p4ccn956-nbfc-linux-0.5.4/share/nbfc/configs/*.json โ€” configuration files for various notebook models.
  • /nix/store/48mhb6ci6w735jxaz60mhn63p4ccn956-nbfc-linux-0.5.4/share/nbfc/model_support.json โ€” model support database. This file maps notebook model names to configuration files.
  • /var/lib/nbfc/configs/*.json โ€” configuration files downloaded from the internet. Files in this directory take precedence over those in /nix/store/48mhb6ci6w735jxaz60mhn63p4ccn956-nbfc-linux-0.5.4/share/nbfc/configs. she comes first, periodt ๐Ÿ’…
  • /var/lib/nbfc/model_support.json โ€” model support database downloaded from the internet. Both /var/lib/nbfc/model_support.json and /nix/store/48mhb6ci6w735jxaz60mhn63p4ccn956-nbfc-linux-0.5.4/share/nbfc/model_support.json are taken into account.
  • /var/lib/nbfc/state.json โ€” state file of nbfc_service. This holds the current fan speeds. ๐ŸŒฌ๏ธ

๐Ÿ’– AUTHOR ๐Ÿ’–

Benjamin Abendroth (braph93@gmx.de) โ€” king behavior, honestly ๐Ÿ‘‘

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

nbfc(1), nbfc_service(1), ec_probe(1), fancontrol(1), sensors(1)


okay that's the whole thing bestie, you ate that ๐Ÿ’…โœจ This is Notebook FanControl 0.5.4, dated APRIL 2026 โ€” go forth and keep those fans cute and quiet ๐ŸŽ€๐Ÿฆ‹๐Ÿ’œ
๐Ÿ“ฆ where this page comes from