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