fix(backlight): Use 'brightness' with amdgpu_bl0
The amdgpu driver seems to set 'actual_brightness' wrong. Fixes #1870 Ref: https://github.com/Alexays/Waybar/issues/335
This commit is contained in:
parent
fea579ec85
commit
2b31a3f112
@ -67,10 +67,8 @@ set(SETTING_CONNECTION_TEST_IP "8.8.8.8"
|
|||||||
CACHE STRING "Address to ping when testing network connection")
|
CACHE STRING "Address to ping when testing network connection")
|
||||||
set(SETTING_PATH_ADAPTER "/sys/class/power_supply/%adapter%"
|
set(SETTING_PATH_ADAPTER "/sys/class/power_supply/%adapter%"
|
||||||
CACHE STRING "Path to adapter")
|
CACHE STRING "Path to adapter")
|
||||||
set(SETTING_PATH_BACKLIGHT_MAX "/sys/class/backlight/%card%/max_brightness"
|
set(SETTING_PATH_BACKLIGHT "/sys/class/backlight/%card%"
|
||||||
CACHE STRING "Path to file containing the maximum backlight value")
|
CACHE STRING "Path to backlight sysfs folder")
|
||||||
set(SETTING_PATH_BACKLIGHT_VAL "/sys/class/backlight/%card%/actual_brightness"
|
|
||||||
CACHE STRING "Path to file containing the current backlight value")
|
|
||||||
set(SETTING_PATH_BATTERY "/sys/class/power_supply/%battery%"
|
set(SETTING_PATH_BATTERY "/sys/class/power_supply/%battery%"
|
||||||
CACHE STRING "Path to battery")
|
CACHE STRING "Path to battery")
|
||||||
set(SETTING_PATH_CPU_INFO "/proc/stat"
|
set(SETTING_PATH_CPU_INFO "/proc/stat"
|
||||||
|
@ -64,8 +64,7 @@ static constexpr const char* BSPWM_SOCKET_PATH{"@SETTING_BSPWM_SOCKET_PATH@"};
|
|||||||
static constexpr const char* BSPWM_STATUS_PREFIX{"@SETTING_BSPWM_STATUS_PREFIX@"};
|
static constexpr const char* BSPWM_STATUS_PREFIX{"@SETTING_BSPWM_STATUS_PREFIX@"};
|
||||||
static constexpr const char* CONNECTION_TEST_IP{"@SETTING_CONNECTION_TEST_IP@"};
|
static constexpr const char* CONNECTION_TEST_IP{"@SETTING_CONNECTION_TEST_IP@"};
|
||||||
static constexpr const char* PATH_ADAPTER{"@SETTING_PATH_ADAPTER@"};
|
static constexpr const char* PATH_ADAPTER{"@SETTING_PATH_ADAPTER@"};
|
||||||
static constexpr const char* PATH_BACKLIGHT_MAX{"@SETTING_PATH_BACKLIGHT_MAX@"};
|
static constexpr const char* PATH_BACKLIGHT{"@SETTING_PATH_BACKLIGHT@"};
|
||||||
static constexpr const char* PATH_BACKLIGHT_VAL{"@SETTING_PATH_BACKLIGHT_VAL@"};
|
|
||||||
static constexpr const char* PATH_BATTERY{"@SETTING_PATH_BATTERY@"};
|
static constexpr const char* PATH_BATTERY{"@SETTING_PATH_BATTERY@"};
|
||||||
static constexpr const char* PATH_CPU_INFO{"@SETTING_PATH_CPU_INFO@"};
|
static constexpr const char* PATH_CPU_INFO{"@SETTING_PATH_CPU_INFO@"};
|
||||||
static constexpr const char* PATH_MEMORY_INFO{"@SETTING_PATH_MEMORY_INFO@"};
|
static constexpr const char* PATH_MEMORY_INFO{"@SETTING_PATH_MEMORY_INFO@"};
|
||||||
|
@ -40,12 +40,21 @@ namespace modules {
|
|||||||
m_ramp = load_ramp(m_conf, name(), TAG_RAMP);
|
m_ramp = load_ramp(m_conf, name(), TAG_RAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build path to the file where the current/maximum brightness value is located
|
// Build path to the sysfs folder the current/maximum brightness values are located
|
||||||
m_val.filepath(string_util::replace(PATH_BACKLIGHT_VAL, "%card%", card));
|
auto path_backlight = string_util::replace(PATH_BACKLIGHT, "%card%", card);
|
||||||
m_max.filepath(string_util::replace(PATH_BACKLIGHT_MAX, "%card%", card));
|
|
||||||
|
/*
|
||||||
|
* amdgpu drivers set the actual_brightness in a different scale than [0, max_brightness]
|
||||||
|
* The only sensible way is to use the 'brightness' file instead
|
||||||
|
* Ref: https://github.com/Alexays/Waybar/issues/335
|
||||||
|
*/
|
||||||
|
auto path_backlight_val = path_backlight + "/" + (card == "amdgpu_bl0"? "brightness" : "actual_brightness");
|
||||||
|
|
||||||
|
m_val.filepath(path_backlight_val);
|
||||||
|
m_max.filepath(path_backlight + "/max_brightness");
|
||||||
|
|
||||||
// Add inotify watch
|
// Add inotify watch
|
||||||
watch(string_util::replace(PATH_BACKLIGHT_VAL, "%card%", card));
|
watch(path_backlight_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void backlight_module::idle() {
|
void backlight_module::idle() {
|
||||||
|
Loading…
Reference in New Issue
Block a user