Merge remote-tracking branch 'upstream/master' into tray-child-window

This commit is contained in:
patrick96 2022-09-04 11:46:32 +02:00
commit fe9660254c
No known key found for this signature in database
GPG Key ID: 521E5E03AEBCA1A7
9 changed files with 53 additions and 3 deletions

View File

@ -19,18 +19,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `custom/text`: The `content` setting and all its properties are deprecated in favor of `format` with the same functionality. ([`#2676`](https://github.com/polybar/polybar/pull/2676))
### Added
- `internal/temperature`: `%temperature-k%` token displays the temperature in kelvin ([`#2774`](https://github.com/polybar/polybar/discussions/2774), [`#2784`](https://github.com/polybar/polybar/pull/2784))
- `internal/pulseaudio`: `reverse-scroll` option ([`#2664`](https://github.com/polybar/polybar/pull/2664))
- `custom/script`: Repeat interval for script failure (`interval-fail`) and `exec-if` (`interval-if`) ([`#943`](https://github.com/polybar/polybar/issues/943), [`#2606`](https://github.com/polybar/polybar/issues/2606), [`#2630`](https://github.com/polybar/polybar/pull/2630))
- `custom/text`: Loads the `format` setting, which supports the `<label>` tag, if the deprecated `content` is not defined ([`#1331`](https://github.com/polybar/polybar/issues/1331), [`#2673`](https://github.com/polybar/polybar/pull/2673), [`#2676`](https://github.com/polybar/polybar/pull/2676))
- Added experimental support for positioning the tray like a module
- `internal/backlight`: `scroll-interval` option ([`#2696`](https://github.com/polybar/polybar/issues/2696), [`#2700`](https://github.com/polybar/polybar/pull/2700))
- `internal/temperature`: Added `zone-type` setting ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2752`](https://github.com/polybar/polybar/pull/2752)) by [@xphoniex](https://github.com/xphoniex)
### Changed
- `internal/fs`: Use `/` as a fallback if no mountpoints are specified ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2705`](https://github.com/polybar/polybar/pull/2705))
- `internal/backlight`: Detect backlight if none specified ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2728`](https://github.com/polybar/polybar/pull/2728))
- Providing a negative min-width to a token adds right-padding ([`#2789`](https://github.com/polybar/polybar/issues/2789), [`#2801`](https://github.com/polybar/polybar/pull/2801)) by [@VanillaViking](https://github.com/VanillaViking).
### Fixed
- Waiting for double click interval on modules that don't have a double click action ([`#2663`](https://github.com/polybar/polybar/issues/2663), [`#2695`](https://github.com/polybar/polybar/pull/2695))
- renderer: Small gaps when rendering emojis ([`#2785`](https://github.com/polybar/polybar/issues/2785), [`#2802`](https://github.com/polybar/polybar/pull/2802))
- config:
- Error reporting for deprecated config values ([`#2724`](https://github.com/polybar/polybar/issues/2724))
- Also monitor include-files for changes when --reload is set ([`#675`](https://github.com/polybar/polybar/issues/675), [`#2759`](https://github.com/polybar/polybar/pull/2759))

View File

@ -20,3 +20,5 @@ set(SETTING_PATH_MESSAGING_FIFO "/tmp/polybar_mqueue.%pid%"
CACHE STRING "Path to file containing the current temperature")
set(SETTING_PATH_TEMPERATURE_INFO "/sys/class/thermal/thermal_zone%zone%/temp"
CACHE STRING "Path to file containing the current temperature")
set(SETTING_PATH_THERMAL_ZONE_WILDCARD "/sys/class/thermal/thermal_zone*"
CACHE STRING "Wildcard path to different thermal zones")

View File

@ -196,6 +196,12 @@ namespace cairo {
cairo_text_extents_t extents;
f->textwidth(subset, &extents);
/*
* Make sure we don't advance partial pixels, this can cause problems
* later when cairo renders background colors over half-pixels.
*/
extents.x_advance = std::ceil(extents.x_advance);
// Draw the background
if (t.bg_rect.h != 0.0) {
save();

View File

@ -16,6 +16,7 @@ namespace drawtypes {
size_t max{0_z};
string suffix{""s};
bool zpad{false};
bool rpadding{false};
};
class label : public non_copyable_mixin {

View File

@ -30,6 +30,7 @@ namespace modules {
ramp_t m_ramp;
string m_path;
string m_zone_type;
int m_zone = 0;
// Base temperature used for where to start the ramp
int m_tempbase = 0;

View File

@ -66,6 +66,7 @@ extern const char* const PATH_CPU_INFO;
extern const char* const PATH_MEMORY_INFO;
extern const char* const PATH_MESSAGING_FIFO;
extern const char* const PATH_TEMPERATURE_INFO;
extern const char* const PATH_THERMAL_ZONE_WILDCARD;
extern const char* const WIRELESS_LIB;
bool version_details(const std::vector<std::string>& args);

View File

@ -86,8 +86,12 @@ namespace drawtypes {
if (tok.max != 0_z && string_util::char_len(repl) > tok.max) {
repl = string_util::utf8_truncate(std::move(repl), tok.max) + tok.suffix;
} else if (tok.min != 0_z && repl.length() < tok.min) {
if (tok.rpadding) {
repl.append(tok.min - repl.length(), ' ');
} else {
repl.insert(0_z, tok.min - repl.length(), tok.zpad ? '0' : ' ');
}
}
/*
* Only replace first occurence, so that the proper token objects can be used
@ -231,6 +235,10 @@ namespace drawtypes {
text = string_util::replace(text, token_str, token.token);
try {
if (token_str[pos + 1] == '-') {
token.rpadding = true;
pos++;
}
token.min = std::stoul(&token_str[pos + 1], nullptr, 10);
// When the number starts with 0 the string is 0-padded
token.zpad = token_str[pos + 1] == '0';

View File

@ -16,12 +16,33 @@ namespace modules {
temperature_module::temperature_module(const bar_settings& bar, string name_)
: timer_module<temperature_module>(bar, move(name_)) {
m_zone = m_conf.get(name(), "thermal-zone", 0);
m_zone_type = m_conf.get(name(), "zone-type", ""s);
m_path = m_conf.get(name(), "hwmon-path", ""s);
m_tempbase = m_conf.get(name(), "base-temperature", 0);
m_tempwarn = m_conf.get(name(), "warn-temperature", 80);
set_interval(1s);
m_units = m_conf.get(name(), "units", m_units);
if (!m_zone_type.empty()) {
bool zone_found = false;
vector<string> zone_paths = file_util::glob(PATH_THERMAL_ZONE_WILDCARD);
vector<string> available_zones;
for (auto &z: zone_paths) {
string zone_file = z + "/type";
string z_zone_type = string_util::strip_trailing_newline(file_util::contents(zone_file));
available_zones.push_back(z_zone_type);
if (z_zone_type == m_zone_type) {
m_path = z + "/temp";
zone_found = true;
break;
}
}
if (!zone_found) {
throw module_error("zone-type '" + m_zone_type + "' was not found, available zone types: " + string_util::join(available_zones, ", "));
}
}
if (m_path.empty()) {
m_path = string_util::replace(PATH_TEMPERATURE_INFO, "%zone%", to_string(m_zone));
}
@ -51,22 +72,27 @@ namespace modules {
}
bool temperature_module::update() {
m_temp = std::strtol(file_util::contents(m_path).c_str(), nullptr, 10) / 1000.0f + 0.5f;
int temp_f = floor(((1.8 * m_temp) + 32) + 0.5);
float temp = float(std::strtol(file_util::contents(m_path).c_str(), nullptr, 10)) / 1000.0;
m_temp = std::lround( temp );
int temp_f = std::lround( (temp * 1.8) + 32.0 );
int temp_k = std::lround( temp + 273.15 );
string temp_c_string = to_string(m_temp);
string temp_f_string = to_string(temp_f);
string temp_k_string = to_string(temp_k);
// Add units if `units = true` in config
if(m_units) {
temp_c_string += "°C";
temp_f_string += "°F";
temp_k_string += "K";
}
const auto replace_tokens = [&](label_t& label) {
label->reset_tokens();
label->replace_token("%temperature-f%", temp_f_string);
label->replace_token("%temperature-c%", temp_c_string);
label->replace_token("%temperature-k%", temp_k_string);
// DEPRECATED: Will be removed in later release
label->replace_token("%temperature%", temp_c_string);

View File

@ -19,6 +19,7 @@ const char* const PATH_CPU_INFO{"@SETTING_PATH_CPU_INFO@"};
const char* const PATH_MEMORY_INFO{"@SETTING_PATH_MEMORY_INFO@"};
const char* const PATH_MESSAGING_FIFO{"@SETTING_PATH_MESSAGING_FIFO@"};
const char* const PATH_TEMPERATURE_INFO{"@SETTING_PATH_TEMPERATURE_INFO@"};
const char* const PATH_THERMAL_ZONE_WILDCARD{"@SETTING_PATH_THERMAL_ZONE_WILDCARD@"};
const char* const WIRELESS_LIB{"@WIRELESS_LIB@"};
bool version_details(const std::vector<std::string>& args) {