GTK4: Migration CPU
Add documentation for justify option Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>pull/2956/head
parent
7802cab40d
commit
f9b6f665c1
|
@ -1,14 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
|
@ -22,6 +13,7 @@ class Cpu : public ALabel {
|
|||
|
||||
private:
|
||||
std::vector<std::tuple<size_t, size_t>> prev_times_;
|
||||
std::string prev_state_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
};
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
|
|
|
@ -30,7 +30,11 @@ The *backlight* module displays the current backlight level.
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
|
|
|
@ -61,7 +61,11 @@ The *battery* module displays the current capacity and state (eg. charging) of y
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer++
|
||||
|
|
|
@ -66,7 +66,11 @@ Addressed by *bluetooth*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -35,7 +35,11 @@ The *cpu* module displays the current CPU utilization.
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*rotate*: ++
|
||||
typeof: integer ++
|
||||
|
@ -121,3 +125,5 @@ CPU usage per core rendered as icons:
|
|||
# STYLE
|
||||
|
||||
- *#cpu*
|
||||
- *#cpu.<state>*
|
||||
- *<state>* can be defined in the *config*. For more information see *states*.
|
||||
|
|
|
@ -72,7 +72,11 @@ Addressed by *custom/<name>*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -45,7 +45,11 @@ Addressed by *disk*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -31,7 +31,11 @@ Addressed by *hyprland/submap*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -33,7 +33,11 @@ screensaver, also known as "presentation mode".
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -37,7 +37,11 @@ See *systemd-inhibit*(1) for more information.
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -63,7 +63,11 @@ Addressed by *jack*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -45,7 +45,11 @@ Addressed by *memory*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -103,7 +103,11 @@ Addressed by *mpd*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -119,8 +119,11 @@ The *mpris* module displays currently playing media via libplayerctl.
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. ++
|
||||
If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -70,7 +70,11 @@ Addressed by *network*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -56,7 +56,11 @@ Additionally, you can control the volume by scrolling *up* or *down* while the c
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*scroll-step*: ++
|
||||
typeof: float ++
|
||||
|
|
|
@ -33,7 +33,11 @@ Addressed by *river/layout*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -31,7 +31,11 @@ Addressed by *river/mode*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -31,7 +31,11 @@ Addressed by *river/window*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -32,7 +32,11 @@ cursor is over the module, and clicking on the module toggles mute.
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*scroll-step*: ++
|
||||
typeof: int ++
|
||||
|
|
|
@ -31,7 +31,11 @@ Addressed by *sway/mode*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -31,7 +31,11 @@ Addressed by *sway/window*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -71,7 +71,11 @@ Addressed by *temperature*
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*on-click*: ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -47,7 +47,11 @@ The *wireplumber* module displays the current volume reported by WirePlumber.
|
|||
|
||||
*align*: ++
|
||||
typeof: float ++
|
||||
The alignment of the text, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
The alignment of the label within the module, where 0 is left-aligned and 1 is right-aligned. If the module is rotated, it will follow the flow of the text.
|
||||
|
||||
*justify*: ++
|
||||
typeof: string ++
|
||||
The alignment of the text within the module's label, allowing options 'left', 'right', or 'center' to define the positioning.
|
||||
|
||||
*scroll-step*: ++
|
||||
typeof: float ++
|
||||
|
|
41
meson.build
41
meson.build
|
@ -128,7 +128,8 @@ src_files = files(
|
|||
'src/factory.cpp',
|
||||
'src/util/ustring_clen.cpp',
|
||||
'src/group.cpp',
|
||||
'src/ASlider.cpp'
|
||||
'src/ASlider.cpp',
|
||||
'src/modules/load.cpp',
|
||||
)
|
||||
|
||||
man_files = files(
|
||||
|
@ -185,13 +186,37 @@ endif
|
|||
inc_dirs = ['include']
|
||||
|
||||
if is_linux
|
||||
src_files += files('src/modules/battery.cpp')
|
||||
man_files += files('man/waybar-battery.5.scd')
|
||||
endif
|
||||
|
||||
if is_freebsd
|
||||
src_files += files('src/modules/battery.cpp')
|
||||
man_files += files('man/waybar-battery.5.scd')
|
||||
add_project_arguments('-DHAVE_CPU_LINUX', language: 'cpp')
|
||||
src_files += files('src/modules/battery.cpp',
|
||||
'src/modules/cpu.cpp',
|
||||
'src/modules/cpu_frequency/common.cpp',
|
||||
'src/modules/cpu_frequency/linux.cpp',
|
||||
'src/modules/cpu_usage/common.cpp',
|
||||
'src/modules/cpu_usage/linux.cpp')
|
||||
man_files += files('man/waybar-battery.5.scd',
|
||||
'man/waybar-cpu.5.scd')
|
||||
elif is_dragonfly or is_freebsd or is_netbsd or is_openbsd
|
||||
add_project_arguments('-DHAVE_CPU_BSD', language: 'cpp')
|
||||
add_project_arguments('-DHAVE_MEMORY_BSD', language: 'cpp')
|
||||
src_files += files(
|
||||
# 'src/modules/cffi.cpp',
|
||||
'src/modules/cpu.cpp',
|
||||
'src/modules/cpu_frequency/bsd.cpp',
|
||||
'src/modules/cpu_frequency/common.cpp',
|
||||
'src/modules/cpu_usage/bsd.cpp',
|
||||
'src/modules/cpu_usage/common.cpp',
|
||||
# 'src/modules/memory/bsd.cpp',
|
||||
# 'src/modules/memory/common.cpp',
|
||||
)
|
||||
man_files += files(
|
||||
# 'man/waybar-cffi.5.scd',
|
||||
'man/waybar-cpu.5.scd',
|
||||
# 'man/waybar-memory.5.scd',
|
||||
)
|
||||
if is_freebsd
|
||||
src_files += files('src/modules/battery.cpp')
|
||||
man_files += files('man/waybar-battery.5.scd')
|
||||
endif
|
||||
endif
|
||||
|
||||
subdir('protocol')
|
||||
|
|
|
@ -209,7 +209,7 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
|||
if (ref == "memory") {
|
||||
return new waybar::modules::Memory(id, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#endif*/
|
||||
#if defined(HAVE_CPU_LINUX) || defined(HAVE_CPU_BSD)
|
||||
if (ref == "cpu") {
|
||||
return new waybar::modules::Cpu(id, config_[name]);
|
||||
|
@ -226,7 +226,6 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
|||
return new waybar::modules::Load(id, config_[name]);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
if (ref == "clock") {
|
||||
return new waybar::modules::Clock(id, config_[name]);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ auto waybar::modules::Cpu::update() -> void {
|
|||
auto [cpu_usage, tooltip] = CpuUsage::getCpuUsage(prev_times_);
|
||||
auto [max_frequency, min_frequency, avg_frequency] = CpuFrequency::getCpuFrequency();
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(tooltip);
|
||||
Gtk::Label::set_tooltip_text(tooltip);
|
||||
}
|
||||
auto format = format_;
|
||||
auto total_usage = cpu_usage.empty() ? 0 : cpu_usage[0];
|
||||
|
@ -36,10 +36,16 @@ auto waybar::modules::Cpu::update() -> void {
|
|||
format = config_["format-" + state].asString();
|
||||
}
|
||||
|
||||
if (!prev_state_.empty()) {
|
||||
Gtk::Label::get_style_context()->remove_class(prev_state_);
|
||||
}
|
||||
Gtk::Label::get_style_context()->add_class(state);
|
||||
prev_state_ = state;
|
||||
|
||||
if (format.empty()) {
|
||||
event_box_.hide();
|
||||
Gtk::Label::hide();
|
||||
} else {
|
||||
event_box_.show();
|
||||
Gtk::Label::show();
|
||||
auto icons = std::vector<std::string>{state};
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("load", load1));
|
||||
|
@ -55,7 +61,7 @@ auto waybar::modules::Cpu::update() -> void {
|
|||
auto icon_format = fmt::format("icon{}", core_i);
|
||||
store.push_back(fmt::arg(icon_format.c_str(), getIcon(cpu_usage[i], icons)));
|
||||
}
|
||||
label_.set_markup(fmt::vformat(format, store));
|
||||
Gtk::Label::set_markup(fmt::vformat(format, store));
|
||||
}
|
||||
|
||||
// Call parent update
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <cmath> // NAN
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include "modules/cpu_frequency.hpp"
|
||||
|
||||
std::vector<float> waybar::modules::CpuFrequency::parseCpuFrequencies() {
|
||||
static std::vector<float> frequencies;
|
||||
std::vector<float> frequencies;
|
||||
char buffer[256];
|
||||
size_t len;
|
||||
int32_t freq;
|
||||
uint32_t i = 0;
|
||||
|
||||
while (true) {
|
||||
len = 4;
|
||||
snprintf(buffer, 256, "dev.cpu.%u.freq", i);
|
||||
if (sysctlbyname(buffer, &freq, &len, NULL, 0) == -1 || len <= 0) break;
|
||||
frequencies.push_back(freq);
|
||||
++i;
|
||||
}
|
||||
|
||||
if (frequencies.empty()) {
|
||||
spdlog::warn(
|
||||
"cpu/bsd: parseCpuFrequencies is not implemented, expect garbage in {*_frequency}");
|
||||
spdlog::warn("cpu/bsd: parseCpuFrequencies failed, not found in sysctl");
|
||||
frequencies.push_back(NAN);
|
||||
}
|
||||
|
||||
return frequencies;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#include <numeric>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "modules/cpu_frequency.hpp"
|
||||
|
||||
// In the 80000 version of fmt library authors decided to optimize imports
|
||||
|
@ -24,7 +27,7 @@ auto waybar::modules::CpuFrequency::update() -> void {
|
|||
auto tooltip =
|
||||
fmt::format("Minimum frequency: {}\nAverage frequency: {}\nMaximum frequency: {}\n",
|
||||
min_frequency, avg_frequency, max_frequency);
|
||||
label_.set_tooltip_text(tooltip);
|
||||
Gtk::Label::set_tooltip_text(tooltip);
|
||||
}
|
||||
auto format = format_;
|
||||
auto state = getState(avg_frequency);
|
||||
|
@ -33,16 +36,16 @@ auto waybar::modules::CpuFrequency::update() -> void {
|
|||
}
|
||||
|
||||
if (format.empty()) {
|
||||
event_box_.hide();
|
||||
Gtk::Label::hide();
|
||||
} else {
|
||||
event_box_.show();
|
||||
Gtk::Label::show();
|
||||
auto icons = std::vector<std::string>{state};
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("icon", getIcon(avg_frequency, icons)));
|
||||
store.push_back(fmt::arg("max_frequency", max_frequency));
|
||||
store.push_back(fmt::arg("min_frequency", min_frequency));
|
||||
store.push_back(fmt::arg("avg_frequency", avg_frequency));
|
||||
label_.set_markup(fmt::vformat(format, store));
|
||||
Gtk::Label::set_markup(fmt::vformat(format, store));
|
||||
}
|
||||
|
||||
// Call parent update
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include "modules/cpu_frequency.hpp"
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ auto waybar::modules::CpuUsage::update() -> void {
|
|||
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
|
||||
auto [cpu_usage, tooltip] = CpuUsage::getCpuUsage(prev_times_);
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(tooltip);
|
||||
Gtk::Label::set_tooltip_text(tooltip);
|
||||
}
|
||||
auto format = format_;
|
||||
auto total_usage = cpu_usage.empty() ? 0 : cpu_usage[0];
|
||||
|
@ -31,9 +31,9 @@ auto waybar::modules::CpuUsage::update() -> void {
|
|||
}
|
||||
|
||||
if (format.empty()) {
|
||||
event_box_.hide();
|
||||
Gtk::Label::hide();
|
||||
} else {
|
||||
event_box_.show();
|
||||
Gtk::Label::show();
|
||||
auto icons = std::vector<std::string>{state};
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("usage", total_usage));
|
||||
|
@ -45,7 +45,7 @@ auto waybar::modules::CpuUsage::update() -> void {
|
|||
auto icon_format = fmt::format("icon{}", core_i);
|
||||
store.push_back(fmt::arg(icon_format.c_str(), getIcon(cpu_usage[i], icons)));
|
||||
}
|
||||
label_.set_markup(fmt::vformat(format, store));
|
||||
Gtk::Label::set_markup(fmt::vformat(format, store));
|
||||
}
|
||||
|
||||
// Call parent update
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <fmt/format.h>
|
||||
|
||||
#include "modules/load.hpp"
|
||||
|
||||
// In the 80000 version of fmt library authors decided to optimize imports
|
||||
|
@ -22,7 +24,7 @@ auto waybar::modules::Load::update() -> void {
|
|||
auto [load1, load5, load15] = Load::getLoad();
|
||||
if (tooltipEnabled()) {
|
||||
auto tooltip = fmt::format("Load 1: {}\nLoad 5: {}\nLoad 15: {}", load1, load5, load15);
|
||||
label_.set_tooltip_text(tooltip);
|
||||
Gtk::Label::set_tooltip_text(tooltip);
|
||||
}
|
||||
auto format = format_;
|
||||
auto state = getState(load1);
|
||||
|
@ -31,9 +33,9 @@ auto waybar::modules::Load::update() -> void {
|
|||
}
|
||||
|
||||
if (format.empty()) {
|
||||
event_box_.hide();
|
||||
Gtk::Label::hide();
|
||||
} else {
|
||||
event_box_.show();
|
||||
Gtk::Label::show();
|
||||
auto icons = std::vector<std::string>{state};
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("load1", load1));
|
||||
|
@ -42,7 +44,7 @@ auto waybar::modules::Load::update() -> void {
|
|||
store.push_back(fmt::arg("icon1", getIcon(load1, icons)));
|
||||
store.push_back(fmt::arg("icon5", getIcon(load5, icons)));
|
||||
store.push_back(fmt::arg("icon15", getIcon(load15, icons)));
|
||||
label_.set_markup(fmt::vformat(format, store));
|
||||
Gtk::Label::set_markup(fmt::vformat(format, store));
|
||||
}
|
||||
|
||||
// Call parent update
|
||||
|
|
Loading…
Reference in New Issue