Merge remote-tracking branch 'upstream/master' into tray-child-window
This commit is contained in:
commit
d296d67953
@ -1,6 +1,6 @@
|
||||
---
|
||||
Language: Cpp
|
||||
Standard: Cpp11
|
||||
Standard: c++17
|
||||
BasedOnStyle: Google
|
||||
ColumnLimit: 120
|
||||
NamespaceIndentation: Inner
|
||||
|
@ -14,11 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Build
|
||||
- Respect `CMAKE_INSTALL_PREFIX` when installing default config ([`#2770`](https://github.com/polybar/polybar/pull/2770))
|
||||
- Bump C++ version to C++17 ([`#2847`](https://github.com/polybar/polybar/pull/2847))
|
||||
|
||||
### Deprecated
|
||||
- `custom/text`: The `content` setting and all its properties are deprecated in favor of `format` with the same functionality. ([`#2676`](https://github.com/polybar/polybar/pull/2676))
|
||||
|
||||
### Added
|
||||
- Added support for TAG_LABEL (`<label>`) in ipc module ([`#2841`](https://github.com/polybar/polybar/pull/2841)) by [@madhavpcm](https://github.com/madhavpcm).
|
||||
- Added support for format-i for each hook-i defined in ipc module ([`#2775`](https://github.com/polybar/polybar/issues/2775), [`#2810`](https://github.com/polybar/polybar/pull/2810)) by [@madhavpcm](https://github.com/madhavpcm).
|
||||
- `internal/temperature`: `%temperature-k%` token displays the temperature in kelvin ([`#2774`](https://github.com/polybar/polybar/discussions/2774), [`#2784`](https://github.com/polybar/polybar/pull/2784))
|
||||
- `internal/pulseaudio`: `reverse-scroll` option ([`#2664`](https://github.com/polybar/polybar/pull/2664))
|
||||
@ -28,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `internal/backlight`: `scroll-interval` option ([`#2696`](https://github.com/polybar/polybar/issues/2696), [`#2700`](https://github.com/polybar/polybar/pull/2700))
|
||||
- `internal/temperature`: Added `zone-type` setting ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2752`](https://github.com/polybar/polybar/pull/2752)) by [@xphoniex](https://github.com/xphoniex)
|
||||
- `internal/xwindow`: `%class%` and `%instance%` tokens, which show the contents of the `WM_CLASS` property of the active window ([`#2830`](https://github.com/polybar/polybar/pull/2830))
|
||||
- Added `enable-struts` option in bar section to enable/disable struts ([`#2769`](https://github.com/polybar/polybar/issues/2769), [`#2844`](https://github.com/polybar/polybar/pull/2844)) by [@VanillaViking](https://github.com/VanillaViking).
|
||||
|
||||
### Changed
|
||||
- `internal/fs`: Use `/` as a fallback if no mountpoints are specified ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2705`](https://github.com/polybar/polybar/pull/2705))
|
||||
|
@ -15,13 +15,12 @@ endif()
|
||||
option(CXXLIB_CLANG "Link against libc++" OFF)
|
||||
option(CXXLIB_GCC "Link against stdlibc++" OFF)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
|
||||
|
||||
set(POLYBAR_FLAGS "" CACHE STRING "C++ compiler flags used for compiling polybar")
|
||||
|
||||
list(APPEND cxx_base -Wall -Wextra -Wpedantic -Wdeprecated-copy-dtor)
|
||||
|
@ -197,6 +197,7 @@ struct bar_settings {
|
||||
position offset{0, 0};
|
||||
side_values padding{ZERO_SPACE, ZERO_SPACE};
|
||||
side_values module_margin{ZERO_SPACE, ZERO_SPACE};
|
||||
bool struts{true};
|
||||
struct {
|
||||
int top;
|
||||
int bottom;
|
||||
|
@ -42,7 +42,7 @@ namespace ipc {
|
||||
const logger& m_log;
|
||||
eventloop::loop& m_loop;
|
||||
|
||||
eventloop::pipe_handle_t socket;
|
||||
eventloop::pipe_handle_t m_socket;
|
||||
|
||||
class connection : public non_copyable_mixin, public non_movable_mixin {
|
||||
public:
|
||||
@ -89,7 +89,7 @@ namespace ipc {
|
||||
* Buffer for the currently received IPC message over the named pipe
|
||||
*/
|
||||
string m_pipe_buffer{};
|
||||
void receive_data(string buf);
|
||||
void receive_data(const string& buf);
|
||||
void receive_eof();
|
||||
};
|
||||
} // namespace ipc
|
||||
|
@ -54,12 +54,17 @@ namespace modules {
|
||||
bool has_hook() const;
|
||||
|
||||
void set_hook(int h);
|
||||
|
||||
void update_output() ;
|
||||
private:
|
||||
static constexpr const char* TAG_OUTPUT{"<output>"};
|
||||
static constexpr auto TAG_OUTPUT = "<output>";
|
||||
static constexpr auto TAG_LABEL = "<label>";
|
||||
|
||||
label_t m_label;
|
||||
|
||||
vector<unique_ptr<hook>> m_hooks;
|
||||
map<mousebtn, string> m_actions;
|
||||
string m_output;
|
||||
|
||||
int m_initial{-1};
|
||||
int m_current_hook{-1};
|
||||
void exec_hook();
|
||||
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
#include <cassert>
|
||||
|
||||
#include "components/builder.hpp"
|
||||
|
@ -216,11 +216,22 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
||||
|
||||
m_opts.double_click_interval = m_conf.get(bs, "double-click-interval", m_opts.double_click_interval);
|
||||
|
||||
m_opts.struts = m_conf.get(bs, "enable-struts", m_opts.struts);
|
||||
|
||||
if (only_initialize_values) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load values used to adjust the struts atom
|
||||
|
||||
if (!m_opts.struts) {
|
||||
if (m_conf.has("global/wm", "margin-bottom")) {
|
||||
m_log.warn("Struts are disabled, ignoring margin-bottom");
|
||||
}
|
||||
if (m_conf.has("global/wm", "margin-top")) {
|
||||
m_log.warn("Struts are disabled, ignoring margin-top");
|
||||
}
|
||||
}
|
||||
auto margin_top = m_conf.get("global/wm", "margin-top", percentage_with_offset{});
|
||||
auto margin_bottom = m_conf.get("global/wm", "margin-bottom", percentage_with_offset{});
|
||||
m_opts.strut.top = units_utils::percentage_with_offset_to_pixel(margin_top, m_opts.monitor->h, m_opts.dpi_y);
|
||||
@ -543,6 +554,9 @@ void bar::reconfigure_pos() {
|
||||
* Reconfigure window strut values
|
||||
*/
|
||||
void bar::reconfigure_struts() {
|
||||
if (!m_opts.struts) {
|
||||
return;
|
||||
}
|
||||
window win{m_connection, m_opts.x_data.window};
|
||||
if (m_visible) {
|
||||
auto geom = m_connection.get_geometry(m_connection.root());
|
||||
|
@ -11,11 +11,11 @@ namespace ipc {
|
||||
size_t total_size = HEADER_SIZE + payload.size();
|
||||
std::vector<uint8_t> data(total_size);
|
||||
|
||||
auto* header = reinterpret_cast<ipc::header*>(data.data());
|
||||
std::copy(ipc::MAGIC.begin(), ipc::MAGIC.end(), header->s.magic);
|
||||
header->s.version = ipc::VERSION;
|
||||
header->s.size = payload.size();
|
||||
header->s.type = type;
|
||||
auto* msg_header = reinterpret_cast<header*>(data.data());
|
||||
std::copy(MAGIC.begin(), MAGIC.end(), msg_header->s.magic);
|
||||
msg_header->s.version = VERSION;
|
||||
msg_header->s.size = payload.size();
|
||||
msg_header->s.type = type;
|
||||
|
||||
std::copy(payload.begin(), payload.end(), data.begin() + HEADER_SIZE);
|
||||
return data;
|
||||
|
@ -40,7 +40,7 @@ namespace ipc {
|
||||
* Construct ipc handler
|
||||
*/
|
||||
ipc::ipc(signal_emitter& emitter, const logger& logger, loop& loop)
|
||||
: m_sig(emitter), m_log(logger), m_loop(loop), socket(loop.handle<PipeHandle>()) {
|
||||
: m_sig(emitter), m_log(logger), m_loop(loop), m_socket(loop.handle<PipeHandle>()) {
|
||||
m_pipe_path = string_util::replace(PATH_MESSAGING_FIFO, "%pid%", to_string(getpid()));
|
||||
|
||||
if (file_util::exists(m_pipe_path) && unlink(m_pipe_path.c_str()) == -1) {
|
||||
@ -57,12 +57,12 @@ namespace ipc {
|
||||
|
||||
m_log.info("Opening ipc socket at '%s'", sock_path);
|
||||
m_log.notice("Listening for IPC messages (PID: %d)", getpid());
|
||||
socket->bind(sock_path);
|
||||
socket->listen(
|
||||
m_socket->bind(sock_path);
|
||||
m_socket->listen(
|
||||
4, [this]() { on_connection(); },
|
||||
[this](const auto& e) {
|
||||
m_log.err("libuv error while listening to IPC socket: %s", uv_strerror(e.status));
|
||||
socket->close();
|
||||
m_socket->close();
|
||||
});
|
||||
}
|
||||
|
||||
@ -133,12 +133,12 @@ namespace ipc {
|
||||
});
|
||||
|
||||
auto& c = *connection;
|
||||
socket->accept(*c.client_pipe);
|
||||
m_socket->accept(*c.client_pipe);
|
||||
|
||||
c.client_pipe->read_start(
|
||||
[this, &c](const auto& e) {
|
||||
try {
|
||||
c.dec.on_read((const uint8_t*)e.data, e.len);
|
||||
c.dec.on_read(reinterpret_cast<const uint8_t*>(e.data), e.len);
|
||||
} catch (const decoder::error& e) {
|
||||
m_log.err("ipc: Failed to decode IPC message (reason: %s)", e.what());
|
||||
|
||||
@ -175,7 +175,7 @@ namespace ipc {
|
||||
}
|
||||
|
||||
ipc::fifo::fifo(loop& loop, ipc& ipc, const string& path) : pipe_handle(loop.handle<PipeHandle>()) {
|
||||
int fd;
|
||||
int fd{};
|
||||
if ((fd = open(path.c_str(), O_RDONLY | O_NONBLOCK)) == -1) {
|
||||
throw system_error("Failed to open pipe '" + path + "'");
|
||||
}
|
||||
@ -196,7 +196,7 @@ namespace ipc {
|
||||
/**
|
||||
* Receive parts of an IPC message
|
||||
*/
|
||||
void ipc::receive_data(string buf) {
|
||||
void ipc::receive_data(const string& buf) {
|
||||
m_pipe_buffer += buf;
|
||||
|
||||
m_log.warn("Using the named pipe at '%s' for ipc is deprecated, always use 'polybar-msg'", m_pipe_path);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "drawtypes/label.hpp"
|
||||
#include "modules/meta/base.inl"
|
||||
|
||||
POLYBAR_NS
|
||||
@ -59,11 +60,14 @@ namespace modules {
|
||||
for (auto& hook : m_hooks) {
|
||||
hook->command = pid_token(hook->command);
|
||||
}
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_OUTPUT, {TAG_OUTPUT});
|
||||
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_OUTPUT});
|
||||
|
||||
m_label = load_optional_label(m_conf, name(), TAG_LABEL, "%output%");
|
||||
|
||||
for (size_t i = 0; i < m_hooks.size(); i++) {
|
||||
string format_i = "format-" + to_string(i);
|
||||
m_formatter->add_optional(format_i, {TAG_OUTPUT});
|
||||
m_formatter->add_optional(format_i, {TAG_LABEL});
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,12 +126,14 @@ namespace modules {
|
||||
* Output content retrieved from hook commands
|
||||
*/
|
||||
bool ipc_module::build(builder* builder, const string& tag) const {
|
||||
if (tag == TAG_OUTPUT) {
|
||||
if (tag == TAG_LABEL) {
|
||||
builder->node(m_label);
|
||||
return true;
|
||||
} else if (tag == TAG_OUTPUT) {
|
||||
builder->node(m_output);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,7 +156,7 @@ namespace modules {
|
||||
|
||||
void ipc_module::action_send(const string& data) {
|
||||
m_output = data;
|
||||
broadcast();
|
||||
update_output();
|
||||
}
|
||||
|
||||
void ipc_module::action_hook(const string& data) {
|
||||
@ -185,7 +191,8 @@ namespace modules {
|
||||
} else {
|
||||
m_current_hook = -1;
|
||||
m_output.clear();
|
||||
broadcast();
|
||||
|
||||
update_output();
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,6 +245,14 @@ namespace modules {
|
||||
m_output.clear();
|
||||
}
|
||||
|
||||
update_output();
|
||||
}
|
||||
|
||||
void ipc_module::update_output() {
|
||||
if (m_label) {
|
||||
m_label->reset_tokens();
|
||||
m_label->replace_token("%output%", m_output);
|
||||
}
|
||||
broadcast();
|
||||
}
|
||||
} // namespace modules
|
||||
|
@ -260,13 +260,13 @@ int run(int argc, char** argv) {
|
||||
/*
|
||||
* Index to decoder is captured because reference can be invalidated due to the vector being modified.
|
||||
*/
|
||||
int idx = decoders.size() - 1;
|
||||
auto idx = decoders.size() - 1;
|
||||
|
||||
auto conn = loop.handle<PipeHandle>();
|
||||
conn->connect(
|
||||
channel,
|
||||
[&conn, &decoders, pid, type, payload, channel, idx]() {
|
||||
on_connection(*conn, decoders[idx], pid, type, payload);
|
||||
[&handle = *conn, &decoders, pid, type, payload, channel, idx]() {
|
||||
on_connection(handle, decoders[idx], pid, type, payload);
|
||||
},
|
||||
[&](const auto& e) {
|
||||
fprintf(stderr, "%s: Failed to connect to '%s' (err: '%s')\n", exec, channel.c_str(), uv_strerror(e.status));
|
||||
|
@ -128,7 +128,7 @@ namespace string_util {
|
||||
* Trims all characters that match pred from the left
|
||||
*/
|
||||
string ltrim(string value, function<bool(char)> pred) {
|
||||
value.erase(value.begin(), find_if(value.begin(), value.end(), not1(pred)));
|
||||
value.erase(value.begin(), find_if(value.begin(), value.end(), std::not_fn(pred)));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ namespace string_util {
|
||||
* Trims all characters that match pred from the right
|
||||
*/
|
||||
string rtrim(string value, function<bool(char)> pred) {
|
||||
value.erase(find_if(value.rbegin(), value.rend(), not1(pred)).base(), value.end());
|
||||
value.erase(find_if(value.rbegin(), value.rend(), std::not_fn(pred)).base(), value.end());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user