mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #139 from cjbassi/master
Remove ws index from sway ws names
This commit is contained in:
commit
ab78698ffd
@ -22,6 +22,7 @@ class Workspaces : public IModule {
|
|||||||
bool handleScroll(GdkEventScroll*);
|
bool handleScroll(GdkEventScroll*);
|
||||||
std::string getPrevWorkspace();
|
std::string getPrevWorkspace();
|
||||||
std::string getNextWorkspace();
|
std::string getNextWorkspace();
|
||||||
|
std::string trimWorkspaceName(std::string);
|
||||||
|
|
||||||
const Bar& bar_;
|
const Bar& bar_;
|
||||||
const Json::Value& config_;
|
const Json::Value& config_;
|
||||||
|
@ -87,7 +87,7 @@ auto waybar::modules::sway::Workspaces::update() -> void
|
|||||||
if (config_["format"].isString()) {
|
if (config_["format"].isString()) {
|
||||||
auto format = config_["format"].asString();
|
auto format = config_["format"].asString();
|
||||||
button.set_label(fmt::format(format, fmt::arg("icon", icon),
|
button.set_label(fmt::format(format, fmt::arg("icon", icon),
|
||||||
fmt::arg("name", node["name"].asString()),
|
fmt::arg("name", trimWorkspaceName(node["name"].asString())),
|
||||||
fmt::arg("index", node["num"].asString())));
|
fmt::arg("index", node["num"].asString())));
|
||||||
} else {
|
} else {
|
||||||
button.set_label(icon);
|
button.set_label(icon);
|
||||||
@ -105,7 +105,7 @@ void waybar::modules::sway::Workspaces::addWorkspace(Json::Value node)
|
|||||||
auto icon = getIcon(node["name"].asString(), node);
|
auto icon = getIcon(node["name"].asString(), node);
|
||||||
auto format = config_["format"].isString()
|
auto format = config_["format"].isString()
|
||||||
? fmt::format(config_["format"].asString(), fmt::arg("icon", icon),
|
? fmt::format(config_["format"].asString(), fmt::arg("icon", icon),
|
||||||
fmt::arg("name", node["name"].asString()),
|
fmt::arg("name", trimWorkspaceName(node["name"].asString())),
|
||||||
fmt::arg("index", node["num"].asString()))
|
fmt::arg("index", node["num"].asString()))
|
||||||
: icon;
|
: icon;
|
||||||
auto pair = buttons_.emplace(node["name"].asString(), format);
|
auto pair = buttons_.emplace(node["name"].asString(), format);
|
||||||
@ -235,3 +235,12 @@ std::string waybar::modules::sway::Workspaces::getNextWorkspace()
|
|||||||
waybar::modules::sway::Workspaces::operator Gtk::Widget &() {
|
waybar::modules::sway::Workspaces::operator Gtk::Widget &() {
|
||||||
return box_;
|
return box_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string waybar::modules::sway::Workspaces::trimWorkspaceName(std::string name)
|
||||||
|
{
|
||||||
|
std::size_t found = name.find(":");
|
||||||
|
if (found!=std::string::npos) {
|
||||||
|
return name.substr(found+1);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user