Skip to content

Commit

Permalink
Merge github.com:alttabber/Waybar
Browse files Browse the repository at this point in the history
Also fixing #3307
  • Loading branch information
alttabber committed May 28, 2024
2 parents 57f2a57 + e67037e commit efa8b30
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/modules/hyprland/workspaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Workspaces : public AModule, public EventHandler {
auto allOutputs() const -> bool { return m_allOutputs; }
auto showSpecial() const -> bool { return m_showSpecial; }
auto activeOnly() const -> bool { return m_activeOnly; }
auto specialVisibleOnly() const -> bool { return m_specialVisibleOnly; }
auto moveToMonitor() const -> bool { return m_moveToMonitor; }

auto getBarOutput() const -> std::string { return m_bar.output->name; }
Expand Down Expand Up @@ -101,6 +102,7 @@ class Workspaces : public AModule, public EventHandler {
std::vector<std::string> getVisibleWorkspaces();
void updateWorkspaceStates(const std::vector<std::string>& visibleWorkspaces);
bool updateWindowsToCreate();
void buttonShowHide();

void extendOrphans(int workspaceId, Json::Value const& clientsJson);
void registerOrphanWindow(WindowCreationPayload create_window_payload);
Expand All @@ -113,6 +115,7 @@ class Workspaces : public AModule, public EventHandler {
bool m_allOutputs = false;
bool m_showSpecial = false;
bool m_activeOnly = false;
bool m_specialVisibleOnly = false;
bool m_moveToMonitor = false;
Json::Value m_persistentWorkspaceConfig;

Expand Down
5 changes: 5 additions & 0 deletions man/waybar-hyprland-workspaces.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Addressed by *hyprland/workspaces*
default: false ++
If set to true, special workspaces will be shown.

*special-visible-only*: ++
typeof: bool ++
default: false ++
If this and show-special are to true, special workspaces will be shown only if visible.

*all-outputs*: ++
typeof: bool ++
default: false ++
Expand Down
13 changes: 13 additions & 0 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void Workspaces::init() {
m_activeWorkspaceName = (gIPC->getSocket1JsonReply("activeworkspace"))["name"].asString();

initializeWorkspaces();
buttonShowHide();
dp.emit();
}

Expand Down Expand Up @@ -132,6 +133,7 @@ void Workspaces::doUpdate() {
std::vector<std::string> visibleWorkspaces = getVisibleWorkspaces();

updateWorkspaceStates(visibleWorkspaces);
buttonShowHide();
updateWindowCount();
sortWorkspaces();

Expand All @@ -142,6 +144,16 @@ void Workspaces::doUpdate() {
}
}

void Workspaces::buttonShowHide(){
for (const auto &workspace : m_workspaces){
if ( (workspace->isActive() || !activeOnly()) && (!workspace->isSpecial() || (showSpecial() && (workspace->isVisible() || !specialVisibleOnly()))) )
workspace->button().show();
else {
workspace->button().hide();
}
}
}

void Workspaces::extendOrphans(int workspaceId, Json::Value const &clientsJson) {
spdlog::trace("Extending orphans with workspace {}", workspaceId);
for (const auto &client : clientsJson) {
Expand Down Expand Up @@ -576,6 +588,7 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void {

populateBoolConfig(config, "all-outputs", m_allOutputs);
populateBoolConfig(config, "show-special", m_showSpecial);
populateBoolConfig(config, "special-visible-only", m_specialVisibleOnly);
populateBoolConfig(config, "active-only", m_activeOnly);
populateBoolConfig(config, "move-to-monitor", m_moveToMonitor);

Expand Down

0 comments on commit efa8b30

Please sign in to comment.