mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #1651 from TheRealLorenz/master
Feature: sway/window can show 'shell' parameter
This commit is contained in:
commit
e50c246601
@ -21,7 +21,7 @@ class Window : public AIconLabel, public sigc::trackable {
|
|||||||
private:
|
private:
|
||||||
void onEvent(const struct Ipc::ipc_response&);
|
void onEvent(const struct Ipc::ipc_response&);
|
||||||
void onCmd(const struct Ipc::ipc_response&);
|
void onCmd(const struct Ipc::ipc_response&);
|
||||||
std::tuple<std::size_t, int, std::string, std::string, std::string> getFocusedNode(
|
std::tuple<std::size_t, int, std::string, std::string, std::string, std::string> getFocusedNode(
|
||||||
const Json::Value& nodes, std::string& output);
|
const Json::Value& nodes, std::string& output);
|
||||||
void getTree();
|
void getTree();
|
||||||
std::string rewriteTitle(const std::string& title);
|
std::string rewriteTitle(const std::string& title);
|
||||||
@ -35,6 +35,7 @@ class Window : public AIconLabel, public sigc::trackable {
|
|||||||
std::string app_class_;
|
std::string app_class_;
|
||||||
std::string old_app_id_;
|
std::string old_app_id_;
|
||||||
std::size_t app_nb_;
|
std::size_t app_nb_;
|
||||||
|
std::string shell_;
|
||||||
unsigned app_icon_size_{24};
|
unsigned app_icon_size_{24};
|
||||||
bool update_app_icon_{true};
|
bool update_app_icon_{true};
|
||||||
std::string app_icon_name_;
|
std::string app_icon_name_;
|
||||||
|
@ -14,8 +14,8 @@ Addressed by *sway/window*
|
|||||||
|
|
||||||
*format*: ++
|
*format*: ++
|
||||||
typeof: string ++
|
typeof: string ++
|
||||||
default: {} ++
|
default: {title} ++
|
||||||
The format, how information should be displayed. On {} data gets inserted.
|
The format, how information should be displayed.
|
||||||
|
|
||||||
*rotate*: ++
|
*rotate*: ++
|
||||||
typeof: integer ++
|
typeof: integer ++
|
||||||
@ -80,6 +80,15 @@ Addressed by *sway/window*
|
|||||||
default: 24 ++
|
default: 24 ++
|
||||||
Option to change the size of the application icon.
|
Option to change the size of the application icon.
|
||||||
|
|
||||||
|
# FORMAT REPLACEMENTS
|
||||||
|
|
||||||
|
*{title}*: The title of the focused window.
|
||||||
|
|
||||||
|
*{app_id}*: The app_id of the focused window.
|
||||||
|
|
||||||
|
*{shell}*: The shell of the focused window. It's 'xwayland' when the window is
|
||||||
|
running through xwayland, otherwise it's 'xdg-shell'.
|
||||||
|
|
||||||
# REWRITE RULES
|
# REWRITE RULES
|
||||||
|
|
||||||
*rewrite* is an object where keys are regular expressions and values are
|
*rewrite* is an object where keys are regular expressions and values are
|
||||||
|
@ -44,7 +44,7 @@ void Window::onCmd(const struct Ipc::ipc_response& res) {
|
|||||||
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 output = payload["output"].isString() ? payload["output"].asString() : "";
|
auto output = payload["output"].isString() ? payload["output"].asString() : "";
|
||||||
std::tie(app_nb_, windowId_, window_, app_id_, app_class_) =
|
std::tie(app_nb_, windowId_, window_, app_id_, app_class_, shell_) =
|
||||||
getFocusedNode(payload["nodes"], output);
|
getFocusedNode(payload["nodes"], output);
|
||||||
updateAppIconName();
|
updateAppIconName();
|
||||||
dp.emit();
|
dp.emit();
|
||||||
@ -175,8 +175,8 @@ auto Window::update() -> void {
|
|||||||
bar_.window.get_style_context()->remove_class("solo");
|
bar_.window.get_style_context()->remove_class("solo");
|
||||||
bar_.window.get_style_context()->remove_class("empty");
|
bar_.window.get_style_context()->remove_class("empty");
|
||||||
}
|
}
|
||||||
label_.set_markup(
|
label_.set_markup(fmt::format(format_, fmt::arg("title", rewriteTitle(window_)),
|
||||||
fmt::format(format_, fmt::arg("title", rewriteTitle(window_)), fmt::arg("app_id", app_id_)));
|
fmt::arg("app_id", app_id_), fmt::arg("shell", shell_)));
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
label_.set_tooltip_text(window_);
|
label_.set_tooltip_text(window_);
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ int leafNodesInWorkspace(const Json::Value& node) {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<std::size_t, int, std::string, std::string, std::string> gfnWithWorkspace(
|
std::tuple<std::size_t, int, std::string, std::string, std::string, std::string> gfnWithWorkspace(
|
||||||
const Json::Value& nodes, std::string& output, const Json::Value& config_, const Bar& bar_,
|
const Json::Value& nodes, std::string& output, const Json::Value& config_, const Bar& bar_,
|
||||||
Json::Value& parentWorkspace) {
|
Json::Value& parentWorkspace) {
|
||||||
for (auto const& node : nodes) {
|
for (auto const& node : nodes) {
|
||||||
@ -222,31 +222,34 @@ std::tuple<std::size_t, int, std::string, std::string, std::string> gfnWithWorks
|
|||||||
const auto app_class = node["window_properties"]["class"].isString()
|
const auto app_class = node["window_properties"]["class"].isString()
|
||||||
? node["window_properties"]["class"].asString()
|
? node["window_properties"]["class"].asString()
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
|
const auto shell = node["shell"].isString() ? node["shell"].asString() : "";
|
||||||
|
|
||||||
int nb = node.size();
|
int nb = node.size();
|
||||||
if (parentWorkspace != 0) nb = leafNodesInWorkspace(parentWorkspace);
|
if (parentWorkspace != 0) nb = leafNodesInWorkspace(parentWorkspace);
|
||||||
return {nb, node["id"].asInt(), Glib::Markup::escape_text(node["name"].asString()), app_id,
|
return {nb, node["id"].asInt(), Glib::Markup::escape_text(node["name"].asString()),
|
||||||
app_class};
|
app_id, app_class, shell};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// iterate
|
// iterate
|
||||||
if (node["type"] == "workspace") parentWorkspace = node;
|
if (node["type"] == "workspace") parentWorkspace = node;
|
||||||
auto [nb, id, name, app_id, app_class] =
|
auto [nb, id, name, app_id, app_class, shell] =
|
||||||
gfnWithWorkspace(node["nodes"], output, config_, bar_, parentWorkspace);
|
gfnWithWorkspace(node["nodes"], output, config_, bar_, parentWorkspace);
|
||||||
if (id > -1 && !name.empty()) {
|
if (id > -1 && !name.empty()) {
|
||||||
return {nb, id, name, app_id, app_class};
|
return {nb, id, name, app_id, app_class, shell};
|
||||||
}
|
}
|
||||||
// Search for floating node
|
// Search for floating node
|
||||||
std::tie(nb, id, name, app_id, app_class) =
|
std::tie(nb, id, name, app_id, app_class, shell) =
|
||||||
gfnWithWorkspace(node["floating_nodes"], output, config_, bar_, parentWorkspace);
|
gfnWithWorkspace(node["floating_nodes"], output, config_, bar_, parentWorkspace);
|
||||||
if (id > -1 && !name.empty()) {
|
if (id > -1 && !name.empty()) {
|
||||||
return {nb, id, name, app_id, app_class};
|
return {nb, id, name, app_id, app_class, shell};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {0, -1, "", "", ""};
|
return {0, -1, "", "", "", ""};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<std::size_t, int, std::string, std::string, std::string> Window::getFocusedNode(
|
std::tuple<std::size_t, int, std::string, std::string, std::string, std::string>
|
||||||
const Json::Value& nodes, std::string& output) {
|
Window::getFocusedNode(const Json::Value& nodes, std::string& output) {
|
||||||
Json::Value placeholder = 0;
|
Json::Value placeholder = 0;
|
||||||
return gfnWithWorkspace(nodes, output, config_, bar_, placeholder);
|
return gfnWithWorkspace(nodes, output, config_, bar_, placeholder);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user