Compare commits
18 Commits
e4e47cad5c
...
23727eed8a
| Author | SHA1 | Date | |
|---|---|---|---|
| 23727eed8a | |||
| 0a42b6c706 | |||
| 688197c8c8 | |||
|
|
6fa8ad3430 | ||
|
|
54e7451cf0 | ||
|
|
d31b131f80 | ||
|
|
9c871c90a7 | ||
|
|
a74adc54e5 | ||
|
|
14a30cd4b7 | ||
|
|
f1140f00f9 | ||
|
|
6f9dee979b | ||
|
|
2337d308ce | ||
|
|
4ac539206f | ||
|
|
7110c455e2 | ||
|
|
3bcadfdf5a | ||
| 9af70bfe42 | |||
| 0acc5a1405 | |||
| d59e7c98d5 |
@@ -182,6 +182,7 @@ Every entry in the *events* object consists of a *<event-name>* (typeof: *string
|
|||||||
|
|
||||||
- *on-<status>-<state>*
|
- *on-<status>-<state>*
|
||||||
- *on-<status>-<capacity>*
|
- *on-<status>-<capacity>*
|
||||||
|
- *on-<status>*
|
||||||
|
|
||||||
Where:
|
Where:
|
||||||
|
|
||||||
@@ -203,7 +204,9 @@ Where:
|
|||||||
"events": {
|
"events": {
|
||||||
"on-discharging-warning": "notify-send -u normal 'Low Battery'",
|
"on-discharging-warning": "notify-send -u normal 'Low Battery'",
|
||||||
"on-discharging-critical": "notify-send -u critical 'Very Low Battery'",
|
"on-discharging-critical": "notify-send -u critical 'Very Low Battery'",
|
||||||
"on-charging-100": "notify-send -u normal 'Battery Full!'"
|
"on-charging-100": "notify-send -u normal 'Battery Full!'",
|
||||||
|
"on-discharging": "notify-send -u normal 'Power Switch' Discharging",
|
||||||
|
"on-charging": "notify-send -u normal 'Power Switch' Charging'"
|
||||||
},
|
},
|
||||||
"format": "{capacity}% {icon}",
|
"format": "{capacity}% {icon}",
|
||||||
"format-icons": ["", "", "", "", ""],
|
"format-icons": ["", "", "", "", ""],
|
||||||
|
|||||||
12
meson.build
12
meson.build
@@ -505,18 +505,6 @@ cava = dependency('libcava',
|
|||||||
|
|
||||||
eproxy = dependency('epoxy', required: false)
|
eproxy = dependency('epoxy', required: false)
|
||||||
|
|
||||||
if cava.found()
|
|
||||||
add_project_arguments('-DHAVE_LIBCAVA', language: 'cpp')
|
|
||||||
src_files += files('src/modules/cava/cavaRaw.cpp',
|
|
||||||
'src/modules/cava/cava_backend.cpp')
|
|
||||||
man_files += files('man/waybar-cava.5.scd')
|
|
||||||
|
|
||||||
if eproxy.found()
|
|
||||||
add_project_arguments('-DHAVE_LIBCAVAGLSL', language: 'cpp')
|
|
||||||
src_files += files('src/modules/cava/cavaGLSL.cpp')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if libgps.found()
|
if libgps.found()
|
||||||
add_project_arguments('-DHAVE_LIBGPS', language: 'cpp')
|
add_project_arguments('-DHAVE_LIBGPS', language: 'cpp')
|
||||||
src_files += files('src/modules/gps.cpp')
|
src_files += files('src/modules/gps.cpp')
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void AAppIconLabel::updateAppIconName(const std::string& app_identifier,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AAppIconLabel::updateAppIcon() {
|
void AAppIconLabel::updateAppIcon() {
|
||||||
if (update_app_icon_) {
|
if (update_app_icon_ || (!iconEnabled() && image_.get_visible())) {
|
||||||
update_app_icon_ = false;
|
update_app_icon_ = false;
|
||||||
if (app_icon_name_.empty()) {
|
if (app_icon_name_.empty()) {
|
||||||
image_.set_visible(false);
|
image_.set_visible(false);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
#ifdef HAVE_LIBGPS
|
#ifdef HAVE_LIBGPS
|
||||||
#include "modules/gps.hpp"
|
#include "modules/gps.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include "modules/cava/cava_frontend.hpp"
|
// #include "modules/cava/cava_frontend.hpp"
|
||||||
#include "modules/cffi.hpp"
|
#include "modules/cffi.hpp"
|
||||||
#include "modules/custom.hpp"
|
#include "modules/custom.hpp"
|
||||||
#include "modules/image.hpp"
|
#include "modules/image.hpp"
|
||||||
@@ -339,9 +339,6 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
|||||||
return new waybar::modules::Wireplumber(id, config_[name]);
|
return new waybar::modules::Wireplumber(id, config_[name]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ref == "cava") {
|
|
||||||
return waybar::modules::cava::getModule(id, config_[name]);
|
|
||||||
}
|
|
||||||
#ifdef HAVE_SYSTEMD_MONITOR
|
#ifdef HAVE_SYSTEMD_MONITOR
|
||||||
if (ref == "systemd-failed-units") {
|
if (ref == "systemd-failed-units") {
|
||||||
return new waybar::modules::SystemdFailedUnits(id, config_[name]);
|
return new waybar::modules::SystemdFailedUnits(id, config_[name]);
|
||||||
|
|||||||
@@ -790,16 +790,19 @@ void waybar::modules::Battery::processEvents(std::string& state, std::string& st
|
|||||||
if (!events.isObject() || events.empty()) {
|
if (!events.isObject() || events.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string event_name = fmt::format("on-{}-{}", status == "discharging" ? status : "charging",
|
auto exec = [](Json::Value const& event) {
|
||||||
state.empty() ? std::to_string(capacity) : state);
|
if (!event.isString()) return;
|
||||||
|
if (auto command = event.asString(); !command.empty()) {
|
||||||
|
util::command::exec(command, "");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::string status_name = status == "discharging" ? "on-discharging" : "on-charging";
|
||||||
|
std::string event_name = status_name + '-' + (state.empty() ? std::to_string(capacity) : state);
|
||||||
if (last_event_ != event_name) {
|
if (last_event_ != event_name) {
|
||||||
spdlog::debug("battery: triggering event {}", event_name);
|
spdlog::debug("battery: triggering event {}", event_name);
|
||||||
if (events[event_name].isString()) {
|
exec(events[event_name]);
|
||||||
std::string exec = events[event_name].asString();
|
if (!last_event_.empty() && last_event_[3] != event_name[3]) {
|
||||||
// Execute the command if it is not empty
|
exec(events[status_name]);
|
||||||
if (!exec.empty()) {
|
|
||||||
util::command::exec(exec, "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
last_event_ = event_name;
|
last_event_ = event_name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ void waybar::modules::cava::Cava::pause_resume() { backend_->doPauseResume(); }
|
|||||||
auto waybar::modules::cava::Cava::onUpdate(const std::string& input) -> void {
|
auto waybar::modules::cava::Cava::onUpdate(const std::string& input) -> void {
|
||||||
Glib::signal_idle().connect_once([this, input]() {
|
Glib::signal_idle().connect_once([this, input]() {
|
||||||
if (silence_) {
|
if (silence_) {
|
||||||
|
silence_ = false;
|
||||||
label_.get_style_context()->remove_class("silent");
|
label_.get_style_context()->remove_class("silent");
|
||||||
if (!label_.get_style_context()->has_class("updated"))
|
if (!label_.get_style_context()->has_class("updated"))
|
||||||
label_.get_style_context()->add_class("updated");
|
label_.get_style_context()->add_class("updated");
|
||||||
@@ -38,7 +39,6 @@ auto waybar::modules::cava::Cava::onUpdate(const std::string& input) -> void {
|
|||||||
label_.show();
|
label_.show();
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
});
|
});
|
||||||
silence_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto waybar::modules::cava::Cava::onSilence() -> void {
|
auto waybar::modules::cava::Cava::onSilence() -> void {
|
||||||
@@ -26,9 +26,7 @@ auto waybar::modules::Cpu::update() -> void {
|
|||||||
auto [load1, load5, load15] = Load::getLoad();
|
auto [load1, load5, load15] = Load::getLoad();
|
||||||
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()) {
|
|
||||||
label_.set_tooltip_markup(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];
|
||||||
auto state = getState(total_usage);
|
auto state = getState(total_usage);
|
||||||
@@ -56,6 +54,15 @@ auto waybar::modules::Cpu::update() -> void {
|
|||||||
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));
|
label_.set_markup(fmt::vformat(format, store));
|
||||||
|
|
||||||
|
if (tooltipEnabled()) {
|
||||||
|
if (config_["tooltip-format"].isString()) {
|
||||||
|
tooltip = config_["tooltip-format"].asString();
|
||||||
|
label_.set_tooltip_markup(fmt::vformat(tooltip, store));
|
||||||
|
} else {
|
||||||
|
label_.set_tooltip_markup(tooltip);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call parent update
|
// Call parent update
|
||||||
|
|||||||
@@ -20,12 +20,7 @@ waybar::modules::CpuFrequency::CpuFrequency(const std::string& id, const Json::V
|
|||||||
auto waybar::modules::CpuFrequency::update() -> void {
|
auto waybar::modules::CpuFrequency::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 [max_frequency, min_frequency, avg_frequency] = CpuFrequency::getCpuFrequency();
|
auto [max_frequency, min_frequency, avg_frequency] = CpuFrequency::getCpuFrequency();
|
||||||
if (tooltipEnabled()) {
|
|
||||||
auto tooltip =
|
|
||||||
fmt::format("Minimum frequency: {}\nAverage frequency: {}\nMaximum frequency: {}\n",
|
|
||||||
min_frequency, avg_frequency, max_frequency);
|
|
||||||
label_.set_tooltip_markup(tooltip);
|
|
||||||
}
|
|
||||||
auto format = format_;
|
auto format = format_;
|
||||||
auto state = getState(avg_frequency);
|
auto state = getState(avg_frequency);
|
||||||
if (!state.empty() && config_["format-" + state].isString()) {
|
if (!state.empty() && config_["format-" + state].isString()) {
|
||||||
@@ -43,6 +38,18 @@ auto waybar::modules::CpuFrequency::update() -> void {
|
|||||||
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));
|
label_.set_markup(fmt::vformat(format, store));
|
||||||
|
|
||||||
|
if (tooltipEnabled()) {
|
||||||
|
std::string tooltip;
|
||||||
|
if (config_["tooltip-format"].isString()) {
|
||||||
|
tooltip = config_["tooltip-format"].asString();
|
||||||
|
label_.set_tooltip_markup(fmt::vformat(tooltip, store));
|
||||||
|
} else {
|
||||||
|
tooltip = "Minimum frequency: {}\nAverage frequency: {}\nMaximum frequency: {}\n";
|
||||||
|
label_.set_tooltip_markup(
|
||||||
|
fmt::format(fmt::runtime(tooltip), min_frequency, avg_frequency, max_frequency));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call parent update
|
// Call parent update
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ waybar::modules::CpuUsage::CpuUsage(const std::string& id, const Json::Value& co
|
|||||||
auto waybar::modules::CpuUsage::update() -> void {
|
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()) {
|
|
||||||
label_.set_tooltip_markup(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];
|
||||||
auto state = getState(total_usage);
|
auto state = getState(total_usage);
|
||||||
@@ -46,6 +44,15 @@ auto waybar::modules::CpuUsage::update() -> void {
|
|||||||
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));
|
label_.set_markup(fmt::vformat(format, store));
|
||||||
|
|
||||||
|
if (tooltipEnabled()) {
|
||||||
|
if (config_["tooltip-format"].isString()) {
|
||||||
|
tooltip = config_["tooltip-format"].asString();
|
||||||
|
label_.set_tooltip_markup(fmt::vformat(tooltip, store));
|
||||||
|
} else {
|
||||||
|
label_.set_tooltip_markup(tooltip);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call parent update
|
// Call parent update
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ void Workspace::updateTaskbar(const std::string& workspace_icon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
|
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
|
||||||
window_box->set_tooltip_markup(window_repr.window_title);
|
window_box->set_tooltip_text(window_repr.window_title);
|
||||||
window_box->get_style_context()->add_class("taskbar-window");
|
window_box->get_style_context()->add_class("taskbar-window");
|
||||||
if (window_repr.isActive) {
|
if (window_repr.isActive) {
|
||||||
window_box->get_style_context()->add_class("active");
|
window_box->get_style_context()->add_class("active");
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include <fmt/chrono.h>
|
#include <fmt/chrono.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
#include <string>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <util/sanitize_str.hpp>
|
#include <util/sanitize_str.hpp>
|
||||||
@@ -118,7 +120,7 @@ void waybar::modules::MPD::setLabel() {
|
|||||||
|
|
||||||
auto format = format_;
|
auto format = format_;
|
||||||
Glib::ustring artist, album_artist, album, title;
|
Glib::ustring artist, album_artist, album, title;
|
||||||
std::string date, filename, uri;
|
std::string date, filename, uri, titleSmart;
|
||||||
int song_pos = 0, queue_length = 0, volume = 0;
|
int song_pos = 0, queue_length = 0, volume = 0;
|
||||||
std::chrono::seconds elapsedTime, totalTime;
|
std::chrono::seconds elapsedTime, totalTime;
|
||||||
|
|
||||||
@@ -152,6 +154,21 @@ void waybar::modules::MPD::setLabel() {
|
|||||||
date = sanitize_string(getTag(MPD_TAG_DATE));
|
date = sanitize_string(getTag(MPD_TAG_DATE));
|
||||||
filename = sanitize_string(getFilename());
|
filename = sanitize_string(getFilename());
|
||||||
uri = mpd_song_get_uri(song_.get());
|
uri = mpd_song_get_uri(song_.get());
|
||||||
|
|
||||||
|
if (title == "n/a" || artist == "n/a") {
|
||||||
|
titleSmart = std::regex_replace(filename, std::regex(R"((\s*$$.*?$$)|(\.(mp3|m4a|opus|ogx))$)"), "");
|
||||||
|
} else {
|
||||||
|
// Remove content within parentheses from the title
|
||||||
|
std::string cleanedTitle = std::regex_replace(static_cast<std::string>(title),
|
||||||
|
std::regex(R"(\([^)]*\))"),
|
||||||
|
"");
|
||||||
|
|
||||||
|
// Also trim any trailing spaces that might be left after removing parentheses
|
||||||
|
cleanedTitle = std::regex_replace(cleanedTitle, std::regex(R"(\s+$)"), "");
|
||||||
|
|
||||||
|
titleSmart = static_cast<std::string>(artist) + " - " + cleanedTitle;
|
||||||
|
}
|
||||||
|
|
||||||
song_pos = mpd_status_get_song_pos(status_.get()) + 1;
|
song_pos = mpd_status_get_song_pos(status_.get()) + 1;
|
||||||
volume = mpd_status_get_volume(status_.get());
|
volume = mpd_status_get_volume(status_.get());
|
||||||
if (volume < 0) {
|
if (volume < 0) {
|
||||||
@@ -175,6 +192,7 @@ void waybar::modules::MPD::setLabel() {
|
|||||||
album_artist = album_artist.substr(0, config_["album-artist-len"].asInt());
|
album_artist = album_artist.substr(0, config_["album-artist-len"].asInt());
|
||||||
if (config_["album-len"].isInt()) album = album.substr(0, config_["album-len"].asInt());
|
if (config_["album-len"].isInt()) album = album.substr(0, config_["album-len"].asInt());
|
||||||
if (config_["title-len"].isInt()) title = title.substr(0, config_["title-len"].asInt());
|
if (config_["title-len"].isInt()) title = title.substr(0, config_["title-len"].asInt());
|
||||||
|
if (config_["title-len"].isInt()) titleSmart = titleSmart.substr(0, config_["title-len"].asInt());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto text = fmt::format(
|
auto text = fmt::format(
|
||||||
@@ -185,7 +203,8 @@ void waybar::modules::MPD::setLabel() {
|
|||||||
fmt::arg("songPosition", song_pos), fmt::arg("queueLength", queue_length),
|
fmt::arg("songPosition", song_pos), fmt::arg("queueLength", queue_length),
|
||||||
fmt::arg("stateIcon", stateIcon), fmt::arg("consumeIcon", consumeIcon),
|
fmt::arg("stateIcon", stateIcon), fmt::arg("consumeIcon", consumeIcon),
|
||||||
fmt::arg("randomIcon", randomIcon), fmt::arg("repeatIcon", repeatIcon),
|
fmt::arg("randomIcon", randomIcon), fmt::arg("repeatIcon", repeatIcon),
|
||||||
fmt::arg("singleIcon", singleIcon), fmt::arg("filename", filename), fmt::arg("uri", uri));
|
fmt::arg("singleIcon", singleIcon), fmt::arg("filename", filename), fmt::arg("uri", uri),
|
||||||
|
fmt::arg("titleSmart", titleSmart));
|
||||||
if (text.empty()) {
|
if (text.empty()) {
|
||||||
label_.hide();
|
label_.hide();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -174,11 +174,11 @@ std::string Workspaces::getIcon(const std::string& value, const Json::Value& ws)
|
|||||||
|
|
||||||
if (ws["is_urgent"].asBool() && icons["urgent"]) return icons["urgent"].asString();
|
if (ws["is_urgent"].asBool() && icons["urgent"]) return icons["urgent"].asString();
|
||||||
|
|
||||||
if (ws["active_window_id"].isNull() && icons["empty"]) return icons["empty"].asString();
|
if (ws["is_active"].asBool() && icons["active"]) return icons["active"].asString();
|
||||||
|
|
||||||
if (ws["is_focused"].asBool() && icons["focused"]) return icons["focused"].asString();
|
if (ws["is_focused"].asBool() && icons["focused"]) return icons["focused"].asString();
|
||||||
|
|
||||||
if (ws["is_active"].asBool() && icons["active"]) return icons["active"].asString();
|
if (ws["active_window_id"].isNull() && icons["empty"]) return icons["empty"].asString();
|
||||||
|
|
||||||
if (ws["name"]) {
|
if (ws["name"]) {
|
||||||
const auto& name = ws["name"].asString();
|
const auto& name = ws["name"].asString();
|
||||||
|
|||||||
0
subprojects/.wraplock
Normal file
0
subprojects/.wraplock
Normal file
Reference in New Issue
Block a user