mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
style: clean class
This commit is contained in:
@ -13,7 +13,7 @@ waybar::modules::Battery::Battery()
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
|
||||
_label.get_style_context()->add_class("battery-status");
|
||||
_label.get_style_context()->add_class("battery");
|
||||
|
||||
_thread = [this] {
|
||||
update();
|
||||
@ -31,9 +31,9 @@ auto waybar::modules::Battery::update() -> void
|
||||
std::ifstream(bat / "charge_full") >> full;
|
||||
std::ifstream(bat / "status") >> status;
|
||||
if (status == "Charging") {
|
||||
_label.get_style_context()->add_class("battery-charging");
|
||||
_label.get_style_context()->add_class("charging");
|
||||
} else {
|
||||
_label.get_style_context()->remove_class("battery-charging");
|
||||
_label.get_style_context()->remove_class("charging");
|
||||
}
|
||||
int pct = float(now) / float(full) * 100.f;
|
||||
_label.set_text_with_mnemonic(fmt::format("{}% {}", pct, ""));
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
waybar::modules::Clock::Clock()
|
||||
{
|
||||
_label.get_style_context()->add_class("clock-widget");
|
||||
_label.get_style_context()->add_class("clock");
|
||||
_thread = [this] {
|
||||
auto now = waybar::chrono::clock::now();
|
||||
auto t = std::time(nullptr);
|
||||
|
@ -3,15 +3,15 @@
|
||||
|
||||
waybar::modules::Cpu::Cpu()
|
||||
{
|
||||
_label.get_style_context()->add_class("cpu-widget");
|
||||
_label.get_style_context()->add_class("cpu");
|
||||
_thread = [this] {
|
||||
struct sysinfo info;
|
||||
if (!sysinfo(&info)) {
|
||||
float f_load = 1.f / (1 << SI_LOAD_SHIFT);
|
||||
_label.set_text(fmt::format("{:.{}f}% ",
|
||||
info.loads[0] * f_load * 100 / get_nprocs(), 1));
|
||||
info.loads[0] * f_load * 100 / get_nprocs(), 0));
|
||||
}
|
||||
_thread.sleep_for(chrono::seconds(30));
|
||||
_thread.sleep_for(chrono::seconds(10));
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -3,13 +3,12 @@
|
||||
|
||||
waybar::modules::Memory::Memory()
|
||||
{
|
||||
_label.get_style_context()->add_class("memory-widget");
|
||||
_label.get_style_context()->add_class("memory");
|
||||
_thread = [this] {
|
||||
struct sysinfo info;
|
||||
if (!sysinfo(&info)) {
|
||||
double available = (double)info.freeram / (double)info.totalram;
|
||||
std::cout << available << std::endl;
|
||||
_label.set_text(fmt::format("{:.{}f}% ", available * 100, 1));
|
||||
_label.set_text(fmt::format("{:.{}f}% ", available * 100, 0));
|
||||
}
|
||||
_thread.sleep_for(chrono::seconds(30));
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ static const struct org_kde_kwin_idle_timeout_listener idle_timer_listener = {
|
||||
waybar::modules::WorkspaceSelector::WorkspaceSelector(Bar &bar)
|
||||
: thread(nullptr), _bar(bar), _box(Gtk::manage(new Gtk::Box))
|
||||
{
|
||||
_box->get_style_context()->add_class("workspace-selector");
|
||||
_box->get_style_context()->add_class("workspaces");
|
||||
std::string socketPath = get_socketpath();
|
||||
_ipcSocketfd = ipc_open_socket(socketPath);
|
||||
_ipcEventSocketfd = ipc_open_socket(socketPath);
|
||||
|
Reference in New Issue
Block a user