mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
2ee4a51546 | |||
91996a85c1 | |||
460d25ac45 | |||
648eecdd83 | |||
f04ff38567 | |||
d20a586734 | |||
1962caf144 | |||
9dbf057f58 | |||
918146c16b | |||
0b01b35c76 |
@ -29,6 +29,8 @@ class Window : public ALabel, public sigc::trackable {
|
|||||||
std::string window_;
|
std::string window_;
|
||||||
int windowId_;
|
int windowId_;
|
||||||
std::string app_id_;
|
std::string app_id_;
|
||||||
|
std::string old_app_id_;
|
||||||
|
std::size_t app_nb_;
|
||||||
util::JsonParser parser_;
|
util::JsonParser parser_;
|
||||||
|
|
||||||
util::SleeperThread thread_;
|
util::SleeperThread thread_;
|
||||||
|
@ -90,6 +90,8 @@ inline int32_t forkExec(std::string cmd) {
|
|||||||
setpgid(pid, pid);
|
setpgid(pid, pid);
|
||||||
execl("/bin/sh", "sh", "-c", cmd.c_str(), (char*)0);
|
execl("/bin/sh", "sh", "-c", cmd.c_str(), (char*)0);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
} else {
|
||||||
|
signal(SIGCHLD,SIG_IGN);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
project(
|
project(
|
||||||
'waybar', 'cpp', 'c',
|
'waybar', 'cpp', 'c',
|
||||||
version: '0.6.7',
|
version: '0.6.8',
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
default_options : [
|
default_options : [
|
||||||
'cpp_std=c++17',
|
'cpp_std=c++17',
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
window#waybar {
|
window#waybar {
|
||||||
background: rgba(43, 48, 59, 0.5);
|
background-color: rgba(43, 48, 59, 0.5);
|
||||||
border-bottom: 3px solid rgba(100, 114, 125, 0.5);
|
border-bottom: 3px solid rgba(100, 114, 125, 0.5);
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
transition-property: background, background-color;
|
transition-property: background-color;
|
||||||
transition-duration: .5s;
|
transition-duration: .5s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,10 +20,10 @@ window#waybar.hidden {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
window#waybar.empty {
|
window#waybar.empty {
|
||||||
background: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
window#waybar.solo {
|
window#waybar.solo {
|
||||||
background: #FFFFFF;
|
background-color: #FFFFFF;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -39,13 +39,13 @@ window#waybar.chromium {
|
|||||||
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
|
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
|
||||||
#workspaces button {
|
#workspaces button {
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
background: transparent;
|
background-color: transparent;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
border-bottom: 3px solid transparent;
|
border-bottom: 3px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#workspaces button.focused {
|
#workspaces button.focused {
|
||||||
background: #64727D;
|
background-color: #64727D;
|
||||||
border-bottom: 3px solid #ffffff;
|
border-bottom: 3px solid #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ window#waybar.chromium {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#mode {
|
#mode {
|
||||||
background: #64727D;
|
background-color: #64727D;
|
||||||
border-bottom: 3px solid #ffffff;
|
border-bottom: 3px solid #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ window#waybar.chromium {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#battery.critical:not(.charging) {
|
#battery.critical:not(.charging) {
|
||||||
background: #f53c3c;
|
background-color: #f53c3c;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
animation-name: blink;
|
animation-name: blink;
|
||||||
animation-duration: 0.5s;
|
animation-duration: 0.5s;
|
||||||
@ -100,56 +100,56 @@ label:focus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#cpu {
|
#cpu {
|
||||||
background: #2ecc71;
|
background-color: #2ecc71;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#memory {
|
#memory {
|
||||||
background: #9b59b6;
|
background-color: #9b59b6;
|
||||||
}
|
}
|
||||||
|
|
||||||
#backlight {
|
#backlight {
|
||||||
background: #90b1b1;
|
background-color: #90b1b1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#network {
|
#network {
|
||||||
background: #2980b9;
|
background-color: #2980b9;
|
||||||
}
|
}
|
||||||
|
|
||||||
#network.disconnected {
|
#network.disconnected {
|
||||||
background: #f53c3c;
|
background-color: #f53c3c;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pulseaudio {
|
#pulseaudio {
|
||||||
background: #f1c40f;
|
background-color: #f1c40f;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pulseaudio.muted {
|
#pulseaudio.muted {
|
||||||
background: #90b1b1;
|
background-color: #90b1b1;
|
||||||
color: #2a5c45;
|
color: #2a5c45;
|
||||||
}
|
}
|
||||||
|
|
||||||
#custom-media {
|
#custom-media {
|
||||||
background: #66cc99;
|
background-color: #66cc99;
|
||||||
color: #2a5c45;
|
color: #2a5c45;
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-spotify {
|
#custom-media.custom-spotify {
|
||||||
background: #66cc99;
|
background-color: #66cc99;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-vlc {
|
#custom-media.custom-vlc {
|
||||||
background: #ffa000;
|
background-color: #ffa000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#temperature {
|
#temperature {
|
||||||
background: #f0932b;
|
background-color: #f0932b;
|
||||||
}
|
}
|
||||||
|
|
||||||
#temperature.critical {
|
#temperature.critical {
|
||||||
background: #eb4d4b;
|
background-color: #eb4d4b;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tray {
|
#tray {
|
||||||
@ -166,18 +166,18 @@ label:focus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#mpd {
|
#mpd {
|
||||||
background: #66cc99;
|
background-color: #66cc99;
|
||||||
color: #2a5c45;
|
color: #2a5c45;
|
||||||
}
|
}
|
||||||
|
|
||||||
#mpd.disconnected {
|
#mpd.disconnected {
|
||||||
background: #f53c3c;
|
background-color: #f53c3c;
|
||||||
}
|
}
|
||||||
|
|
||||||
#mpd.stopped {
|
#mpd.stopped {
|
||||||
background: #90b1b1;
|
background-color: #90b1b1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#mpd.paused {
|
#mpd.paused {
|
||||||
background: #51a37a;
|
background-color: #51a37a;
|
||||||
}
|
}
|
||||||
|
@ -102,14 +102,14 @@ auto waybar::modules::Custom::update() -> void {
|
|||||||
} else {
|
} else {
|
||||||
parseOutputRaw();
|
parseOutputRaw();
|
||||||
}
|
}
|
||||||
if (text_.empty()) {
|
|
||||||
event_box_.hide();
|
|
||||||
} else {
|
|
||||||
auto str = fmt::format(format_,
|
auto str = fmt::format(format_,
|
||||||
text_,
|
text_,
|
||||||
fmt::arg("alt", alt_),
|
fmt::arg("alt", alt_),
|
||||||
fmt::arg("icon", getIcon(percentage_, alt_)),
|
fmt::arg("icon", getIcon(percentage_, alt_)),
|
||||||
fmt::arg("percentage", percentage_));
|
fmt::arg("percentage", percentage_));
|
||||||
|
if (str.empty()) {
|
||||||
|
event_box_.hide();
|
||||||
|
} else {
|
||||||
label_.set_markup(str);
|
label_.set_markup(str);
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
if (text_ == tooltip_) {
|
if (text_ == tooltip_) {
|
||||||
|
@ -128,6 +128,10 @@ void waybar::modules::Pulseaudio::subscribeCb(pa_context * conte
|
|||||||
pa_subscription_event_type_t type, uint32_t idx,
|
pa_subscription_event_type_t type, uint32_t idx,
|
||||||
void *data) {
|
void *data) {
|
||||||
unsigned facility = type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK;
|
unsigned facility = type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK;
|
||||||
|
unsigned operation = type & PA_SUBSCRIPTION_EVENT_TYPE_MASK;
|
||||||
|
if (operation != PA_SUBSCRIPTION_EVENT_CHANGE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (facility == PA_SUBSCRIPTION_EVENT_SINK) {
|
if (facility == PA_SUBSCRIPTION_EVENT_SINK) {
|
||||||
pa_context_get_sink_info_by_index(context, idx, sinkInfoCb, data);
|
pa_context_get_sink_info_by_index(context, idx, sinkInfoCb, data);
|
||||||
} else if (facility == PA_SUBSCRIPTION_EVENT_SOURCE) {
|
} else if (facility == PA_SUBSCRIPTION_EVENT_SOURCE) {
|
||||||
|
@ -9,7 +9,7 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
|||||||
label_.set_hexpand(true);
|
label_.set_hexpand(true);
|
||||||
label_.set_ellipsize(Pango::EllipsizeMode::ELLIPSIZE_END);
|
label_.set_ellipsize(Pango::EllipsizeMode::ELLIPSIZE_END);
|
||||||
}
|
}
|
||||||
ipc_.subscribe(R"(["window","workspace"])");
|
ipc_.subscribe(R"(["window"])");
|
||||||
ipc_.signal_event.connect(sigc::mem_fun(*this, &Window::onEvent));
|
ipc_.signal_event.connect(sigc::mem_fun(*this, &Window::onEvent));
|
||||||
ipc_.signal_cmd.connect(sigc::mem_fun(*this, &Window::onCmd));
|
ipc_.signal_cmd.connect(sigc::mem_fun(*this, &Window::onCmd));
|
||||||
// Get Initial focused window
|
// Get Initial focused window
|
||||||
@ -24,33 +24,8 @@ void Window::onCmd(const struct Ipc::ipc_response& res) {
|
|||||||
try {
|
try {
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::lock_guard<std::mutex> lock(mutex_);
|
||||||
auto payload = parser_.parse(res.payload);
|
auto payload = parser_.parse(res.payload);
|
||||||
auto [nb, id, name, app_id] = getFocusedNode(payload);
|
std::tie(app_nb_, windowId_, window_, app_id_) = getFocusedNode(payload);
|
||||||
if (!app_id_.empty()) {
|
|
||||||
bar_.window.get_style_context()->remove_class(app_id_);
|
|
||||||
}
|
|
||||||
if (nb == 0) {
|
|
||||||
bar_.window.get_style_context()->remove_class("solo");
|
|
||||||
if (!bar_.window.get_style_context()->has_class("empty")) {
|
|
||||||
bar_.window.get_style_context()->add_class("empty");
|
|
||||||
}
|
|
||||||
} else if (nb == 1) {
|
|
||||||
bar_.window.get_style_context()->remove_class("empty");
|
|
||||||
if (!bar_.window.get_style_context()->has_class("solo")) {
|
|
||||||
bar_.window.get_style_context()->add_class("solo");
|
|
||||||
}
|
|
||||||
if (!app_id.empty() && !bar_.window.get_style_context()->has_class(app_id)) {
|
|
||||||
bar_.window.get_style_context()->add_class(app_id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bar_.window.get_style_context()->remove_class("solo");
|
|
||||||
bar_.window.get_style_context()->remove_class("empty");
|
|
||||||
}
|
|
||||||
app_id_ = app_id;
|
|
||||||
if (windowId_ != id || window_ != name) {
|
|
||||||
windowId_ = id;
|
|
||||||
window_ = name;
|
|
||||||
dp.emit();
|
dp.emit();
|
||||||
}
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
spdlog::error("Window: {}", e.what());
|
spdlog::error("Window: {}", e.what());
|
||||||
}
|
}
|
||||||
@ -67,6 +42,27 @@ void Window::worker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto Window::update() -> void {
|
auto Window::update() -> void {
|
||||||
|
if (!old_app_id_.empty()) {
|
||||||
|
bar_.window.get_style_context()->remove_class(old_app_id_);
|
||||||
|
}
|
||||||
|
if (app_nb_ == 0) {
|
||||||
|
bar_.window.get_style_context()->remove_class("solo");
|
||||||
|
if (!bar_.window.get_style_context()->has_class("empty")) {
|
||||||
|
bar_.window.get_style_context()->add_class("empty");
|
||||||
|
}
|
||||||
|
} else if (app_nb_ == 1) {
|
||||||
|
bar_.window.get_style_context()->remove_class("empty");
|
||||||
|
if (!bar_.window.get_style_context()->has_class("solo")) {
|
||||||
|
bar_.window.get_style_context()->add_class("solo");
|
||||||
|
}
|
||||||
|
if (!app_id_.empty() && !bar_.window.get_style_context()->has_class(app_id_)) {
|
||||||
|
bar_.window.get_style_context()->add_class(app_id_);
|
||||||
|
old_app_id_ = app_id_;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bar_.window.get_style_context()->remove_class("solo");
|
||||||
|
bar_.window.get_style_context()->remove_class("empty");
|
||||||
|
}
|
||||||
label_.set_markup(fmt::format(format_, window_));
|
label_.set_markup(fmt::format(format_, window_));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(window_);
|
label_.set_tooltip_text(window_);
|
||||||
|
Reference in New Issue
Block a user