@@ -329,24 +329,43 @@ auto Workspaces::update() -> void {
329329 } else {
330330 button.get_style_context ()->remove_class (" current_output" );
331331 }
332- std::string output = (*it)[ " name " ]. asString ();
332+
333333 std::string windows = " " ;
334334 if (config_[" window-rewrite" ].isObject ()) {
335335 updateWindows ((*it), windows);
336336 }
337+
338+ auto index = (*it)[" num" ].asInt ();
339+ auto full_name = (*it)[" name" ].asString ();
340+
337341 if (config_[" format" ].isString ()) {
338- auto format = config_[" format" ].asString ();
339- output = fmt::format (
340- fmt::runtime (format), fmt::arg (" icon" , getIcon (output, *it)), fmt::arg (" value" , output),
341- fmt::arg (" name" , trimWorkspaceName (output)), fmt::arg (" index" , (*it)[" num" ].asString ()),
342- fmt::arg (" windows" ,
343- windows.substr (0 , windows.length () - m_formatWindowSeparator.length ())),
344- fmt::arg (" output" , (*it)[" output" ].asString ()));
342+ std::string format;
343+ if (config_[" format-for-negative-index" ].isString () && index < 0 ) {
344+ format = config_[" format-for-negative-index" ].asString ();
345+ } else {
346+ format = config_[" format" ].asString ();
347+ }
348+
349+ auto name = trimWorkspaceName (full_name);
350+ auto output = (*it)[" output" ].asString ();
351+ auto icon = getIcon (full_name, *it);
352+ auto separated_windows = windows.substr (0 , windows.length () - m_formatWindowSeparator.length ());
353+
354+ full_name = fmt::format (
355+ fmt::runtime (format),
356+ fmt::arg (" index" , index),
357+ fmt::arg (" name" , name),
358+ fmt::arg (" value" , full_name),
359+ fmt::arg (" output" , output),
360+ fmt::arg (" icon" , icon),
361+ fmt::arg (" windows" , separated_windows)
362+ );
345363 }
364+
346365 if (!config_[" disable-markup" ].asBool ()) {
347- static_cast <Gtk::Label *>(button.get_children ()[0 ])->set_markup (output );
366+ static_cast <Gtk::Label *>(button.get_children ()[0 ])->set_markup (full_name );
348367 } else {
349- button.set_label (output );
368+ button.set_label (full_name );
350369 }
351370 onButtonReady (*it, button);
352371 }
0 commit comments