@@ -41,8 +41,8 @@ void Window::onCmd(const struct Ipc::ipc_response& res) {
41
41
std::lock_guard<std::mutex> lock (mutex_);
42
42
auto payload = parser_.parse (res.payload );
43
43
auto output = payload[" output" ].isString () ? payload[" output" ].asString () : " " ;
44
- std::tie (app_nb_, floating_count_, windowId_, window_, app_id_, app_class_, shell_, layout_) =
45
- getFocusedNode (payload[" nodes" ], output);
44
+ std::tie (app_nb_, floating_count_, windowId_, window_, app_id_, app_class_, shell_, layout_,
45
+ marks_) = getFocusedNode (payload[" nodes" ], output);
46
46
updateAppIconName (app_id_, app_class_);
47
47
dp.emit ();
48
48
} catch (const std::exception & e) {
@@ -96,7 +96,7 @@ auto Window::update() -> void {
96
96
97
97
label_.set_markup (waybar::util::rewriteString (
98
98
fmt::format (fmt::runtime (format_), fmt::arg (" title" , window_), fmt::arg (" app_id" , app_id_),
99
- fmt::arg (" shell" , shell_)),
99
+ fmt::arg (" shell" , shell_), fmt::arg ( " marks " , marks_) ),
100
100
config_[" rewrite" ]));
101
101
if (tooltipEnabled ()) {
102
102
label_.set_tooltip_text (window_);
@@ -108,7 +108,7 @@ auto Window::update() -> void {
108
108
AAppIconLabel::update ();
109
109
}
110
110
111
- void Window::setClass (std::string classname, bool enable) {
111
+ void Window::setClass (const std::string& classname, bool enable) {
112
112
if (enable) {
113
113
if (!bar_.window .get_style_context ()->has_class (classname)) {
114
114
bar_.window .get_style_context ()->add_class (classname);
@@ -169,17 +169,31 @@ std::optional<std::reference_wrapper<const Json::Value>> getSingleChildNode(
169
169
return {getSingleChildNode (child)};
170
170
}
171
171
172
- std::tuple<std::string, std::string, std::string> getWindowInfo (const Json::Value& node) {
172
+ std::tuple<std::string, std::string, std::string, std::string> getWindowInfo (
173
+ const Json::Value& node, bool showHidden) {
173
174
const auto app_id = node[" app_id" ].isString () ? node[" app_id" ].asString ()
174
175
: node[" window_properties" ][" instance" ].asString ();
175
176
const auto app_class = node[" window_properties" ][" class" ].isString ()
176
177
? node[" window_properties" ][" class" ].asString ()
177
178
: " " ;
178
179
const auto shell = node[" shell" ].isString () ? node[" shell" ].asString () : " " ;
179
- return {app_id, app_class, shell};
180
+ std::string marks = " " ;
181
+ if (node[" marks" ].isArray ()) {
182
+ for (const auto & m : node[" marks" ]) {
183
+ if (!m.isString () || (!showHidden && m.asString ().at (0 ) == ' _' )) {
184
+ continue ;
185
+ }
186
+ if (!marks.empty ()) {
187
+ marks += ' ,' ;
188
+ }
189
+ marks += m.asString ();
190
+ }
191
+ }
192
+ return {app_id, app_class, shell, marks};
180
193
}
181
194
182
- std::tuple<std::size_t , int , int , std::string, std::string, std::string, std::string, std::string>
195
+ std::tuple<std::size_t , int , int , std::string, std::string, std::string, std::string, std::string,
196
+ std::string>
183
197
gfnWithWorkspace (const Json::Value& nodes, std::string& output, const Json::Value& config_,
184
198
const Bar& bar_, Json::Value& parentWorkspace,
185
199
const Json::Value& immediateParent) {
@@ -207,15 +221,17 @@ gfnWithWorkspace(const Json::Value& nodes, std::string& output, const Json::Valu
207
221
" " ,
208
222
" " ,
209
223
" " ,
210
- node[" layout" ].asString ()};
224
+ node[" layout" ].asString (),
225
+ " " };
211
226
}
212
227
parentWorkspace = node;
213
228
} else if ((node[" type" ].asString () == " con" || node[" type" ].asString () == " floating_con" ) &&
214
229
(node[" focused" ].asBool ())) {
215
230
// found node
216
231
spdlog::trace (" actual output {}, output found {}, node (focused) found {}" , bar_.output ->name ,
217
232
output, node[" name" ].asString ());
218
- const auto [app_id, app_class, shell] = getWindowInfo (node);
233
+ const auto [app_id, app_class, shell, marks] =
234
+ getWindowInfo (node, config_[" show-hidden-marks" ].asBool ());
219
235
int nb = node.size ();
220
236
int floating_count = 0 ;
221
237
std::string workspace_layout = " " ;
@@ -232,20 +248,21 @@ gfnWithWorkspace(const Json::Value& nodes, std::string& output, const Json::Valu
232
248
app_id,
233
249
app_class,
234
250
shell,
235
- workspace_layout};
251
+ workspace_layout,
252
+ marks};
236
253
}
237
254
238
255
// iterate
239
- auto [nb, f, id, name, app_id, app_class, shell, workspace_layout] =
256
+ auto [nb, f, id, name, app_id, app_class, shell, workspace_layout, marks ] =
240
257
gfnWithWorkspace (node[" nodes" ], output, config_, bar_, parentWorkspace, node);
241
- auto [nb2, f2, id2, name2, app_id2, app_class2, shell2, workspace_layout2] =
258
+ auto [nb2, f2, id2, name2, app_id2, app_class2, shell2, workspace_layout2, marks2 ] =
242
259
gfnWithWorkspace (node[" floating_nodes" ], output, config_, bar_, parentWorkspace, node);
243
260
244
261
// if ((id > 0 || ((id2 < 0 || name2.empty()) && id > -1)) && !name.empty()) {
245
262
if ((id > 0 ) || (id2 < 0 && id > -1 )) {
246
- return {nb, f, id, name, app_id, app_class, shell, workspace_layout};
263
+ return {nb, f, id, name, app_id, app_class, shell, workspace_layout, marks };
247
264
} else if (id2 > 0 && !name2.empty ()) {
248
- return {nb2, f2, id2, name2, app_id2, app_class, shell2, workspace_layout2};
265
+ return {nb2, f2, id2, name2, app_id2, app_class, shell2, workspace_layout2, marks2 };
249
266
}
250
267
}
251
268
@@ -258,10 +275,12 @@ gfnWithWorkspace(const Json::Value& nodes, std::string& output, const Json::Valu
258
275
std::string app_id = " " ;
259
276
std::string app_class = " " ;
260
277
std::string workspace_layout = " " ;
278
+ std::string marks = " " ;
261
279
if (all_leaf_nodes.first == 1 ) {
262
280
const auto single_child = getSingleChildNode (immediateParent);
263
281
if (single_child.has_value ()) {
264
- std::tie (app_id, app_class, workspace_layout) = getWindowInfo (single_child.value ());
282
+ std::tie (app_id, app_class, workspace_layout, marks) =
283
+ getWindowInfo (single_child.value (), config_[" show-hidden-marks" ].asBool ());
265
284
}
266
285
}
267
286
return {all_leaf_nodes.first ,
@@ -273,13 +292,15 @@ gfnWithWorkspace(const Json::Value& nodes, std::string& output, const Json::Valu
273
292
app_id,
274
293
app_class,
275
294
workspace_layout,
276
- immediateParent[" layout" ].asString ()};
295
+ immediateParent[" layout" ].asString (),
296
+ marks};
277
297
}
278
298
279
- return {0 , 0 , -1 , " " , " " , " " , " " , " " };
299
+ return {0 , 0 , -1 , " " , " " , " " , " " , " " , " " };
280
300
}
281
301
282
- std::tuple<std::size_t , int , int , std::string, std::string, std::string, std::string, std::string>
302
+ std::tuple<std::size_t , int , int , std::string, std::string, std::string, std::string, std::string,
303
+ std::string>
283
304
Window::getFocusedNode (const Json::Value& nodes, std::string& output) {
284
305
Json::Value placeholder = Json::Value::null;
285
306
return gfnWithWorkspace (nodes, output, config_, bar_, placeholder, placeholder);
0 commit comments