mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
b16c8972c7
Rewrites window title according to config option "rewrite". "rewrite" is an object where keys are regular expressions and values are rewrite rules if the expression matches. Rules may contain references to captures of the expression. Regex and replacement follow ECMA-script rules. If no regex matches, the title is left unchanged. example: "sway/window": { "rewrite": { "(.*) - Mozilla Firefox": " $1", "(.*) - zsh": " $1", } }
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <fmt/format.h>
|
|
#include <tuple>
|
|
#include "ALabel.hpp"
|
|
#include "bar.hpp"
|
|
#include "client.hpp"
|
|
#include "modules/sway/ipc/client.hpp"
|
|
#include "util/json.hpp"
|
|
|
|
namespace waybar::modules::sway {
|
|
|
|
class Window : public ALabel, public sigc::trackable {
|
|
public:
|
|
Window(const std::string&, const waybar::Bar&, const Json::Value&);
|
|
~Window() = default;
|
|
auto update() -> void;
|
|
|
|
private:
|
|
void onEvent(const struct Ipc::ipc_response&);
|
|
void onCmd(const struct Ipc::ipc_response&);
|
|
std::tuple<std::size_t, int, std::string, std::string> getFocusedNode(const Json::Value& nodes,
|
|
std::string& output);
|
|
void getTree();
|
|
std::string rewriteTitle(const std::string& title);
|
|
|
|
const Bar& bar_;
|
|
std::string window_;
|
|
int windowId_;
|
|
std::string app_id_;
|
|
std::string old_app_id_;
|
|
std::size_t app_nb_;
|
|
util::JsonParser parser_;
|
|
std::mutex mutex_;
|
|
Ipc ipc_;
|
|
};
|
|
|
|
} // namespace waybar::modules::sway
|